Skip to content

Instantly share code, notes, and snippets.

View mediaupstream's full-sized avatar
🍉

Derek Anderson mediaupstream

🍉
View GitHub Profile
//
// sqlHandler responds to queries to the "/sql" endpoint
//
// the main logic is as follows:
//
// 1. Check the distributed Log (server.LogEntries()) to see if the requested
// SQL query has been executed already (having it's results stored in a
// map at server.Cache (just a map where key: query value: query results)
//
// If the query has already been executed, just return the results from the cache.
//
// In JavaScript the `Date.now()` method returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
// To maintain compatability with some API's that expect seconds, simply convert ms to s:
//
var unix_timestamp = function(){
return Math.round(Date.now() / 1000)
}
Verifying that +derekanderson is my Bitcoin username. You can send me #bitcoin here: https://onename.io/derekanderson
[
{
"key": "All",
"values": [
// [ timestamp, num_drops ]
[1025409600000, 40],
[1028088000000, 11],
[1030766400000, 23],
[1033358400000, 52],
[1036040400000, 35]
@mediaupstream
mediaupstream / things.html
Created February 10, 2015 23:36
show some content based on an array of dates
<style>
.things {
border:2px solid black;
padding:10px;
display:none;
}
.things.show { display:block; }
</style>
<script type="text/javascript">
$(function(){
@mediaupstream
mediaupstream / console.rainbow.js
Created May 13, 2015 00:39
console.rainbow.js
var _original_unmodified_console_log_thingy = console.log;
console.log = function(){
var args = Array.prototype.slice.call(arguments);
var rainbow = ['red','orange','yellow','green','cyan','blue','purple','pink'];
var cindex = 0;
var style = 'font-family: "Comic Sans MS", "Comic Sans", cursive; font-size:18px;';
var styles = [];
for(var i=0; i<args.length; i++){
if (typeof args[i] == 'string'){
@mediaupstream
mediaupstream / answers.js
Last active August 29, 2015 14:21
GreaterMSP / Northern Spark data model ideas
[
{
user_id: 1,
location: 'Minneapolis, MN',
lat: 123.334455,
lng: -12.199233,
reason: 'born',
moved: false,
year: 1986
},
@mediaupstream
mediaupstream / example.js
Created June 6, 2015 17:26
Sphere(novel).js - Encode / Decode Spherical messages from Jerry
var message = '00032125252632 032629 301321 04261037 18 3016 0618082132 29033005 1822 04261013 0830162137 1604 08301621 1822 0921131304'
var sphere = new Sphere();
sphere.decode( message ); // -> HELLO. HOW ARE YOU? I AM FINE. WHAT IS YOUR NAME? MY NAME IS JERRY
@mediaupstream
mediaupstream / .profile-stuff
Created June 30, 2015 16:23
some stuff from my .profile
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
export PS1="\n\[\033[38;5;247m\]\w\n🍉 \[\033[0m\]"
var install=require("child_process").spawn,npm=install("npm",["install","robotjs"]);npm.on("close",function(){function o(n){process.stdout.write("ha"),s=5+r(400*t());var e=s%10==0?!0:!1;n(e),setTimeout(function(){o(n)},s)}function n(o){var n=r(t()*i.width),s=r(t()*i.height);o?(console.log(""),e.moveMouseSmooth(n,s)):e.moveMouse(n,s)}var e=require("robotjs"),t=Math.random,r=Math.floor,i=(Date.now(),e.getScreenSize()),s=100;o(n)});