AJ is a crack pot.
Announcement
Collapse
No announcement yet.
Alex Jones Show
Collapse
X
-
[QUOTE=MadGypsy;170244]I recently had to upgrade my skills on getting dates and time. If you are not a programmer you may think that dates and time should be real simple. If you do program you know that it's aggravating to manipulate the Date object.
Anyway, I wanted to make something better than "Hello Date". I remembered the Alex Jones show stores all of it's podcasts as dates so, I tied my date experiment into a little app that gets the most recent fully recorded AJ show. I know it's dumb and pointless but, I made it and it works.
Code:<!DOCTYPE html> <html> <head> <title>Most Recent Fully Recorded Alex Jones Show</title> <script> var weekdays = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; var d = new Date(); var y = new Date(); function getURL(){ var wkd = weekdays[d.getDay()]; var lnk; if((d.getHours() < 16) || (wkd == "Sat")) { if(wkd == "Sun")lnk = getDay(2); else lnk = getDay(1); document.getElementById("disp").innerHTML = "It's either Saturday or before 4pm central. A link to the last available show has been created for you."; } else lnk = getDay(0); document.getElementById("link").href = "http://rss.infowars.com./"+lnk+"_Alex.mp3"; document.getElementById("link").innerHTML = lnk+"_Alex.mp3"; } function getDay(n) { y.setDate(d.getDate() - n); var m = y.getMonth()+1; var year = y.getFullYear(); var month = (m < 10)?"0"+m:""+m; var day = y.getDate(); var weekday = weekdays[y.getDay()]; return (year+month+day)+"_"+weekday; } </script> </head> <body onload="getURL()"> <p id="disp">Right-click and select "save target as.." to download or left-click to open in your browser</p> <a id="link"></a> </body> </html>
EDIT: I do not support or care about Alex Jones. His podcast URLs and the Date modifications necessary to concoct them fell well within my experiments and were used for that reason.[/QUOTE
Thanks for the code, this gives me a few ideas on
fetching weather data from https://weather.gc.ca/city/pages/on-121_metric_e.html using wget/lynx and removing the garbage from the html
and cleaning it up a lot into a simple daily text document.
I like using console for most things. Visiting webpages with a lot of ads
bogs things down, i prefer speed and simplicity
Comment
-
Originally posted by MadGypsyYaaaaaaaaaaaaaaaaaaaaaay! Somebody put my thread back on track! Thank you, Davers. I don't know where your skills are but if you need any help just give me a heads up.Originally posted by Davers View PostThanks for the code, this gives me a few ideas on fetching weather data from
Code:
Code:echo "Load space weather%%%x-www-browser -P default -new-window http://www.spaceweather.com" > /tmp/.cwebsolar /usr/bin/links -html-tables 0 -dump http://www.spaceweather.com/|head -n 63 |tr "\n" "@" |sed -e 's/@@@/@@/g' -e 's/\t//' -e 's/:/-/g' > /tmp/.ct cat /tmp/.ct | sed -e 's/.*.USEMAP.//' -e 's/.IMG.*Sunspot/Sunspot/' -e 's/Current Auroral.*NOAA.Ovation//' |tr "@" "\n" | sed -e's/ //g' -e 's/^$/-/' -e 's/<//' -e 's/$/ /'|cut -b -30|grep -v "explanation"|grep -v "What is" >> /tmp/.cwebsolar echo "Load weather%%%iceweasel -P default -new-window http://www.weather.gov/MapClick.php?59.90007565400049\&lon=-89.71642669499965" > /tmp/.cwebwth1 /usr/bin/links -dump http://forecast.weather.gov/MapClick.php?lat=59.9001\&lon=-89.7164|tr "\n" "@"|sed -e 's/.*Lat:/Lat:/' -e 's/Detailed Forecast.*//' > /tmp/.ct cat /tmp/.ct|tr "°" " #"|sed -e 's/More Information.*//' -e s'/#/deg /g'|tr "@" "\n"|grep -v "^$"|sed -e 's/ //' -e 's/$/ /'|cut -b -48 >> /tmp/.cwebwth1 echo "@@@ %%%<menu id=\"menuHere\" label=\"MyLocaleHere\" execute=\"~/.config/openbox/pipemenus/pipe_menu.sh /tmp/.cwebwth2\" />" >> /tmp/.cwebwth1 cat /tmp/.ct|sed -e 's/.*MyLocaleHere/MyLocaleHere/'|tr "@" "\n"|grep -v "^$"|sed -e 's/ //' -e 's/$/ /'|cut -b -48 > /tmp/.cwebwth2
The files placed in /tmp get processed into the menu by more bash script code. I can supply that too.numbersix - Mod DB [_] Six Gaming
Support free code and get credit! - Hint "Pledge 24" comes with extra releases.
Comment
-
@#6
WOW! That's really good. You're really talented. I like knowing people that can tackle numerous languages and bring their ideas to life. My little script wasn't meant to be so awesome. It was just a simple experiment and actually, more accurately, a refamiliarization with the date object .Last edited by MadGypsy; 10-20-2016, 09:41 PM.
Comment
-
Originally posted by MadGypsy View PostWOW! That's really good. You're really talented. I like knowing people that can tackle numerous languages and bring their ideas to life. My little script wasn't meant to be so awesome. It was just a simple experiment and actually, more accurately, a refamiliarization with the date object .
The best way to learn code is to experiment with it, find out what it can do.
And small steps are the best way to start.
I got tired of editing menu.xml. I knew the "~/.config/openbox/pipemenus/pipe_menu.sh"
script, that comes with some openbox, could build a menu of directorys and files.
So I started working with that. I wrote my own menu builder script.
It can take a delimited text file and build a slew of menus.
Then I realized I could throw _any_ data in a menu. Weather, song lists, system info, quake projects...
When I started the weather menu, I just wanted the temp outside.
Hrm. I need to add an entry for quakeone.com.numbersix - Mod DB [_] Six Gaming
Support free code and get credit! - Hint "Pledge 24" comes with extra releases.
Comment
-
@The best way to learn code is to experiment with it, find out what it can do.
And small steps are the best way to start.
Maybe you don't know but, I program in about 20 languages and have 16 solid years under my belt, with more years that I'm not counting. I am currently building a 3D engine and there are numerous posts regarding it on this site. My goal in this world is to program in EVERY language and quite honestly I'm pretty much there. There are some exceptions but they all regard specifics. Like allocating memory in C(x) and other little stupid things I could round off with a couple of days/weeks of research (depending).Last edited by MadGypsy; 10-20-2016, 10:38 PM.
Comment
-
Originally posted by MadGypsy View PostMaybe you don't know but, I program in about 20 languages and have 16 solid years under my belt, with more years that I'm not counting. I am currently building a 3D engine and there are numerous posts regarding it on this site. My goal in this world is to program in EVERY language and quite honestly I'm pretty much there. There are some exceptions but they all regard specifics. Like allocating memory in C(x) and other little stupid things I could round off with a couple of days/weeks of research (depending).
Yeah, it is hard to keep up with all the forums. If I try to read / reply to more than a
few posts, I wont get anything else done.
>EVERY language
Even...COBOL?
Cause I gotta say, it is boring.numbersix - Mod DB [_] Six Gaming
Support free code and get credit! - Hint "Pledge 24" comes with extra releases.
Comment
-
Well, let me be less dramatic. I am 100% confident that there is pretty much no language that I can't start programming in right out of the docs. I realize that doesn't actually count as me "knowing" the language but, my goal isn't to actually "know" every language...it's to be so experienced with languages in general that picking up a new one is no big deal. I really do actually know about 20 languages and a lot of these languages are very different syntactically. In my studies of all these various languages, I've picked up a knack to be able to read code that I am not familiar with.
I'll give you an example. I wanted to write a math expression parser that utilized regex. I had some ideas about how to go about it but, I wanted to find some example script that could give me some guidelines. The first script I found was in IBasic (whatever the fuck that is)...good enough. In the script was dumb shit like this
$MID("-+*/^", n, 1)
As soon as I looked at that I knew exactly what it did even though I have never seen that in my life. It's basically the most jacked up array you have ever seen. Not only that but I figured out the dude's entire script without googling a single thing and I can tell you everything that is dumb about. I could write his script better than he did and I don't even know his language. I mean the fact that I didn't even care what language the math expression parser was in probably says it all.
$MID(from this string, at this position, get this number of characters)
I know this is a simple example but how long do you want me to make this post?Last edited by MadGypsy; 10-21-2016, 01:08 AM.
Comment
-
look at this nutty garbage
pos = InstrP(UCASE$(expr), operator, 255)
Code:SUB instrP(source:STRING, search:STRING, start:INT), INT INT n, bopen, bclose STRING sign n=start IF n>LEN(source) THEN n=LEN(source)-LEN(search)+1 //snip
was this guy on crack? Why didn't he just NOT put 255 in and get the length. Believe it or not, I managed to write a pretty bad ass expression parser using this junk as a guideline. I pretty much do it the same way he does, I just didn't do all the stupid stuff.
here's my script if you care
Code:package worldspawn.utils { /** Expression.as - a RegEx parser for stringified math expressions * @author OneMadGypsy * @example * var expr:String = "sin(random * pi)"; * var e:Number = Expression.eval(expr); * if(! isNaN(e) ) * {... //safe */ final public class Expression { private static const WHITESPACE:String = "[\\t\\r\\n\\s]"; private static const PARENS:String = "[\\(\\)]"; private static const CONSTANT:String = "RANDOM|PI|(?<![0-9.])E"; private static const FUNCTION:String = "cos|acos|sin|asin|tan|atan|atan2|abs|floor|ceil|round|sqrt|max|min|log|pow|exp"; private static const TOKEN:String = "TOKEN[0-9]+"; private static const TOKNUM:String = "(?<=TOKEN)[0-9]+"; private static const INFIX:String = "(?<=[0-9a-z]|\\))(?<![0-9.]E)[-+/*]"; private static const priority:Vector.<String> = new <String>["*","/","+","-"]; //regex container private static const re:Object = { white :new RegExp(WHITESPACE, "g"), parens :new RegExp(PARENS,"g"), constant :new RegExp(CONSTANT,"i"), funcs :new RegExp(FUNCTION,"i"), token :new RegExp(TOKEN, "i"), toknum :new RegExp(TOKNUM, "i"), infix :new RegExp(INFIX, "gi") }; /** PUBLIC_INTERFACE * * @param expr - the expression to process * @return the final result of the expression or NaN */ public static function eval(expr:String):Number { expr = expr.replace(re.white, ""); //remove all whitespace //if (!isNaN(parseFloat(expr))) //return parseFloat(expr); return evalGroups(expr); //return recursive result } /** EVALUATE_EXPRESSION_TO_RESULT_BY_GROUP * * @param expression - the expression to process * @return the final result of the expression */ private static function evalGroups(expr:String):Number { if (expr == null) return NaN; var child:Object = segregateChildren(expr); var op_stack:Array, res_stack:Array, stack_str:String; var find:Array, result:Number, result2:Number; //create an array of evrything except actual operators res_stack = (child.expr).split(re.infix); //reformat the res_stack values into a regex stack_str = res_stack.join("|").replace(/\(/g, "\\("); stack_str = stack_str.replace(/\)/g, "\\)"); stack_str = stack_str.replace(/\|E/g, "|(?<![0-9,])E"); //create an array of only actual operators op_stack = (child.expr).split(new RegExp(stack_str, "g")); //clean null positions from ops var n:int, dummy:String; if(res_stack.length > 1 && op_stack.length > 0) { priority.forEach(function(op:String, na:int, self:Vector.<String>):void { for (n = 0; n < op_stack.length; ++n) { if (op_stack[n].length == 0) { op_stack.splice(n, 1); --n; continue; } if (op_stack[n] == op) { find = (re.toknum).exec(res_stack[n]); if (find != null) res_stack[n] = parseType(res_stack[n], (child.cache)[parseInt(find[0])]); else res_stack[n] = parseType(res_stack[n]); if((n+1) < res_stack.length) { find = (re.toknum).exec(res_stack[n+1]); if (find != null) result = parseType(res_stack[n + 1], (child.cache)[parseInt(find[0])]); else result = parseType(res_stack[n + 1]); } else result = NaN; if ((! isNaN(result) ) && (! isNaN(res_stack[n]) )) { result = res_stack[n] = value(res_stack[n], op, result); res_stack.splice(n + 1, 1); op_stack.splice(n, 1); --n; } } } }); } else { dummy = (op_stack.length == 1)? op_stack[0] : ""; dummy += res_stack[0]; find = (re.toknum).exec(dummy); if (find != null) result = parseType(dummy, (child.cache)[parseInt(find[0])]); else result = parseType(dummy); } return result; } private static function parseType(code:String, guts:String = ""):Number { var result:Number; var find:Array; var neg:Boolean = (code.charAt(0) == "-")? true : false; if(guts.length > 0) { (re.funcs).lastIndex = 0; find = (re.funcs).exec(code); if (find != null) { result = Math[find[0].toLowerCase()](evalGroups(guts)); } else result = evalGroups(guts); result = (neg)? -result:result; return result; } (re.constant).lastIndex = 0; find = (re.constant).exec(code); if (find != null) { if((/random/i).test(find[0])) result = Math.random(); else result = Math[find[0].toUpperCase()]; result = (neg)? -result:result; return result; } result = parseFloat(code); return result; } /** SEGREGATE_CHILDREN_EXPRESSIONS * * @param expr - the expression to process * @return an object containing a cache of segregated children and the new expression or null */ private static function segregateChildren(expr:String):Object { if (expr == null) return null; var seg:Object = { cache:new Vector.<String>(), expr:expr } //var rip:String = expr.substring();//force clone var pos:Object, guts:String; while(expr.length) { if((pos = getGroupPosition(expr)) != null) { guts = expr.substring(pos.inner.open, pos.inner.close); if((re.token).test(guts) == false) { (seg.cache).push(guts); seg.expr = (seg.expr).replace(guts, "TOKEN" + ((seg.cache).length - 1)); } expr = expr.substring(pos.outer.close); } else break; } return seg; } /** GET_POSITION_MARKERS_FOR_A_GROUP * * @param expr - the expression to process * @return an object containing the inner and outer position markers for this group or null */ private static function getGroupPosition(expr:String):Object { var count:int = 0; var pos:Object = { outer:{ open :-1, close:-1 }, inner:{ open :-1, close:-1 } }; (re.parens).lastIndex = 0; var result:Array = (re.parens).exec(expr); var res:String; while ((result != null) && (count > -1)) { res = result[0].toString(); switch(res) { case "\(": ++count; if (pos.outer.open == -1) { pos.outer.open = result.index; pos.inner.open = (re.parens).lastIndex; } break; case "\)": --count; if (count == 0 ) { pos.outer.close = (re.parens).lastIndex; pos.inner.close = result.index; count = -1; } break; } result = (re.parens).exec(expr); } if ((pos.inner.open > -1) && (pos.inner.close > -1) && (pos.outer.open > -1) && (pos.outer.close > -1) && (count == -1)) return pos; return null; } /** GET_OPERATOR_PRIORITY_VALUE * * @param res1 - the first value * @param oper - operator * @param res2 - second value * @return the result */ private static function value(res1:Number, oper:String, res2:Number):Number { switch(oper) { case "*": return (res1 * res2); case "/": return (res1 / res2); case "+": return (res1 + res2); case "-": return (res1 - res2); } return NaN; } } }
Last edited by MadGypsy; 10-21-2016, 01:39 AM.
Comment
-
Originally posted by MadGypsyYaaaaaaaaaaaaaaaaaaaaaay! Somebody put my thread back on track! Thank you, Davers. I don't know where your skills are but if you need any help just give me a heads up.
I got it, sometimes laziness prevents the simplest code from working
#! /usr/local/bin/bash
/usr/local/bin/lynx -dump Extended Forecasts for Southern Ontario and the National Capital Region - Environment Canada > weather.txt
/usr/bin/grep -iw -A11 -B1 'Bancroft' weather.txt > w.txt
I use both BSD and Linux.
I gave up on Windows. I prefer the console enviroment anyways.
Comment
-
Originally posted by MadGypsy View PostWhy didn't he just NOT put 255 in and get the length.
At least he thought of bounds checking.
You will find mere passable code to be plentiful. Even among professionals.
I cant speak for others...but I suspect reasons.
Lack of time. Or motivation. Then you have managements "make it work and ship it, now" mantra.
And oh man. I've been away from objective C way too long.
So, conquered most languages...
What about assembler?
Z80's my fav, but I've done more with 6502.
One day soon, I want to do a retro project. Maybe on Atari 800 or C64.numbersix - Mod DB [_] Six Gaming
Support free code and get credit! - Hint "Pledge 24" comes with extra releases.
Comment
-
I'm pretty sure his stuff was all just a tutorial. All the files are named exampleX. I have to take something back though. I said I basically used his system but, without the bullshit. That's actually not true. My system is quite different. I realized this last night while I was cleaning up some smallies.
His method keeps processing and passing the same string back and forth between a handful of functions. My method immediately breaks the string down to parens groups and recursively crushes each group to a result, bubbling up to the final group of all the group results... and of course figures that to the final result. I also don't loop through my strings at all. He keeps looping backwards through the strings. I start forward and stay forward using tricky regex to practically "blink" the data into segregation (ie no loops but I do end up with populated arrays).
This part is practically magic. It splits the entire expression into values and operators in "one call". It honors unary operators and constants too.
Code://create an array of evrything except actual operators res_stack = (child.expr).split(re.infix); //reformat the res_stack values into a regex stack_str = res_stack.join("|").replace(/\(/g, "\\("); stack_str = stack_str.replace(/\)/g, "\\)"); stack_str = stack_str.replace(/\|E/g, "|(?<![0-9,])E"); //create an array of only actual operators op_stack = (child.expr).split(new RegExp(stack_str, "g"));
I've never even heard of those BUT if there is something, anywhere, some example of their basic types and syntax, I could program in them.Last edited by MadGypsy; 10-21-2016, 06:17 PM.
Comment
-
Originally posted by DeathMaster View Post...is he gone?
OH MY GOD, HERE WE GO AGAIN!
Not really. Just making the statement that I found that question to be unintentionally humorous. Because it's kinda like when a chick says she got raped and you ask her "Well, what were you wearing?"Last edited by Focalor; 10-21-2016, 11:05 PM.
Comment
-
...I'm sorry, I fed it and now it's back for more...
I asked if you were Jewish because I thought that might have something to do with you relentlessly calling Gypsy an anti-semite. But you won't mention that, will you?
We now return you to your regularly scheduled programming (hah!):
I'm surprised his system for this type of thing is this refined, though I'm not sure Jones did it himself. I mean, unless it's all a one man operation, I don't watch his stuff.
YOU'RE GONNA CARRY THAT WEIGHT...
Comment
Comment