Skip to content

Instantly share code, notes, and snippets.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
char *memory;
void signal_handler(int signo)
{

Keybase proof

I hereby claim:

  • I am mumrah on github.
  • I am mumrah (https://keybase.io/mumrah) on keybase.
  • I have a public key whose fingerprint is 557C E8A2 3280 9E50 77A5 FE17 76D0 486F D3CE E771

To claim this, I am signing this object:

@mumrah
mumrah / gist:10488740
Created April 11, 2014 18:07
Javascript to get temperature, humidity, precipitation, wind, and solr radiation from Weather Underground "history" API
function get_weather_history(year, month, day, query, apikey) {
if(month < 10) {
month = "0" + month;
}
if(day < 10) {
day = "0" + day;
}
var ymd = year + "" + month + "" + day;
var url = "http://api.wunderground.com/api/" + apikey + "/history_" + ymd + "/q/" + query + ".json";
[ {
"id" : "12",
"fields" : [ {
"name" : "url",
"value" : [ {
"name" : "url",
"value" : "https://lucidimagination.zendesk.com/api/v2/tickets/12.json"
} ]
}, {
"name" : "id",
@mumrah
mumrah / weather.gs
Created February 19, 2015 15:08
Script used in David's Garden Planner spreadsheet
function get_weather_conditions(year, month, day, query, apikey, cache_buster) {
if(month < 10) {
month = "0" + month;
}
if(day < 10) {
day = "0" + day;
}
var ymd = year + "" + month + "" + day;
var url = "http://api.wunderground.com/api/" + apikey + "/history_" + ymd + "/q/" + query + ".json";
fs.readFile('static/grid.html', 'ascii').addCallback(function(data){
sys.debug('test');
});
#include "stdio.h"
int* foo(){
static int out[2] = {1,2};
return out;
}
int main(int argv, char* argc){
int* bar = foo();
printf("%p\n", bar);
printf("%d %d\n", bar[0], bar[1]);
var fs = require('fs');
var url = require('url');
var sys = require('sys');
var http = require('http');
require('./ejs'); // EJS, http://embeddedjs.com/
/*
* Server-side controller methods
*/
@mumrah
mumrah / gist:477121
Created July 15, 2010 15:37
ObjectId dereferencing in JavaScript for MongoDB
var _deref = function (doc, field, col) {
var oid = ObjectId(doc[field]);
delete doc[field];
doc[field] = db[col].findOne({_id:oid});
return doc;
}
var deref = function(field, collection){
// C-C-C-Closure!!
return function(doc){
>>> x = {'a':1,'b':"foo",'c':ObjectId()}
>>> print x
{'a': 1, 'c': ObjectId('4c4f4f5e2554c813e4000001'), 'b': 'foo'}
>>> print json.dumps(x)
Traceback (most recent call last):
[...]
TypeError: ObjectId('4c4f4f5e2554c813e4000001') is not JSON serializable
>>> print json.dumps(x, cls=MongoEncoder)
'{"a": 1, "c": ObjectId("4c4f4f5e2554c813e4000001"), "b": "foo"}'