Skip to content

Instantly share code, notes, and snippets.

View imosquera's full-sized avatar

Isaac Mosquera imosquera

View GitHub Profile
@imosquera
imosquera / testhelper.go
Last active December 24, 2015 00:29
This gist helps re-assign functions during testing
package util
import (
"reflect"
)
// Restorer holds a function that can be used
// to restore some previous state.
type Restorer func()
package main
// Restorer holds a function that can be used
// to restore some previous state.
type Restorer func()
// Restore restores some previous state.
func (r Restorer) Restore() {
r()
}
#!/usr/bin/env node
var attractionService = require("../dataservices/attractions-service.js");
var im = require('imagemagick');
var fs = require('fs');
function createDataDir(page_type) {
dir = "data/" + page_type;
mkdirp(dir);
return dir;
}
10.47.25.209 - - [06/Mar/2013:00:39:07 +0000] "GET /v1/entity/?entity_key=3b0d9bbee9a84e8bb6fa8321303faadb_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=f4513fe0e70c4e7da0e305574256d03f_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=512a5f64a0e64f9dabc9ccadcf7f6045_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=1f3bef7a433744f3ba96a7b50df7f58d_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=76889f864d804978ba35d9396653aba1_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=23210b608b14497dafc49f93f593f5f8_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=004f0cc194d243ccb27e9a6ceef55af0_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=93e4d30adfd349fe87ee08f601be7afa_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=686fc1d0410a4eea8f6e88b1cc85d9fe_http%3A%2F%2Ffeeds.news.com.a
10.47.25.209 - - [06/Mar/2013:00:39:07 +0000] "GET /v1/entity/?entity_key=3b0d9bbee9a84e8bb6fa8321303faadb_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=f4513fe0e70c4e7da0e305574256d03f_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=512a5f64a0e64f9dabc9ccadcf7f6045_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=1f3bef7a433744f3ba96a7b50df7f58d_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=76889f864d804978ba35d9396653aba1_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=23210b608b14497dafc49f93f593f5f8_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=004f0cc194d243ccb27e9a6ceef55af0_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=93e4d30adfd349fe87ee08f601be7afa_http%3A%2F%2Ffeeds.news.com.au%2Fmx%2Frss%2Fmx_news_sport_3218.xml&entity_key=686fc1d0410a4eea8f6e88b1cc85d9fe_http%3A%2F%2Ffeeds.news.com.a
@imosquera
imosquera / gist:4179726
Created December 1, 2012 00:22
tracker
import tracker
meta = {
'ad_id':1234,
'browser': 'Mozilla/5.0',
'cpm': 1.34
}
tracker.track_event('ad-click', meta)
def to_flat_dict(json_obj, flat_keyname="", flat_dict = {}):
#recursive function that turns the json dict into key/values pairs
format = "%s.%s"
if flat_keyname == "": format = "%s%s"
if isinstance(json_obj,dict):
for (k, json_obj) in json_obj.items():
new_flatname = format % (flat_keyname,k)
flat_dict = to_flat_dict(json_obj,new_flatname, flat_dict)
@imosquera
imosquera / Authentication.m
Created March 19, 2012 14:45 — forked from nwg/Authentication.m
SocializeSDK iOS Code Snippets
// invoke the call
[socialize authenticateWithApiKey:@"YourApiKey" apiSecret:@"YourApiSecret"];
#pragma mark SocializeServiceDelegate implementation
// implement the delegate
-(void)didAuthenticate{
NSLog(@"Authenticated");
}
// if the authentication fails the following method is called
index="socialize_events" bucket=mobile_user app_id=2 | timechart span="1day" count by user_id
@imosquera
imosquera / et_pull.py
Created March 14, 2012 20:17
EventTracker Client code
self.tracker_client = EventTrackerClient(host=EventTrackerClient.HOST_PROD)
one_month = timedelta(days=90)
end_date = datetime.now()
start_date = end_date - one_month