Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View formido's full-sized avatar
🥰

Michael Terry formido

🥰
View GitHub Profile
~$ curl https://api.datamarket.azure.com
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://datamarket.azure.com">here</a>.</h2>
</body></html>
~$ erl
Erlang/OTP 19 [erts-8.0.2] [source-753b9b9] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]
// Workaround for https://github.com/highslide-software/highcharts.com/issues/3385
// Uses default bootstrap media query sizes.
// display_heatmap is a function that displays the heatmap once the map data has been downloaded.
// Requires enquire.js (http://wicky.nillia.ms/enquire.js/)
// Download map data and save the jqXHR promise.
var states_promise = jQuery.getJSON('http://blog.statricks.com/media/system/maps/US.min.json', {});
// Use enquire to re-render the heatmap if we change browser width
@formido
formido / gist:7d40e4791391020f2c02
Last active November 13, 2023 09:41
map list of dicts with lambda in python

I like to use higher order functions like map, I like to use lambdas, and I prefer to keep my intermediate data representations in lists of dictionaries. Here's a way to map a list of dictionaries concisely:

>>> favorites = [{'name':'home', 'visited':5}, {'name':'work', 'visited':10}]
>>> map(lambda x: dict(x, **{'visited': x['visited']+1}), favorites)
[{'visited': 6, 'name': 'home'}, {'visited': 11, 'name': 'work'}]
var urls = [
/* Attempt to contact emacs web server from outer context */
'http://localhost:8080/skewer',
/* Wildcard CORS enabled - Works in PhantomJS 1.9.0 */
'http://updates.html5rocks.com',
/* CORS disabled - Fails in PhantomJS 1.9.0 (and every other version) */
'http://www.google.com',
/* Hack workaround? */
/*
function(httpGet, callback) {
@formido
formido / process list of lists
Created February 11, 2011 17:24
list comprehension to flatten and process a list of lists
%% http://stackoverflow.com/questions/4969113/erlang-map-nested-list
List = [["asd", "ddsa"], ["ASD", "ASD"], ["FH", "SDFDF]].
[ F(String) || SubList <- List, String <- SubList ].
@formido
formido / bas64 sha1 encode
Created February 10, 2011 18:11
python: base 64 encode the sha1 hash of a string
>>> import base64
>>> import hashlib
>>> base64.b64encode(hashlib.sha1("test").digest())
'qUqP5cyxm6YcTAhz05Hph5gvu9M='
%% process for signing ec2 api requests:
%% http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html?using-query-api.html
s_query(PLparams) ->
{ok,SaccKeyId} = application:get_env(monitor,amazon_access_key_id),
{{Iyr,Imth,Iday},{Ihr,Imin,Isec}} = erlang:universaltime(),
Sdatetime0 = io_lib:format("~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~2.10.0BZ",
[Iyr,Imth,Iday,Ihr,Imin,Isec]),
Sdatetime1 = lists:flatten(Sdatetime0),
PL0 = [{"SignatureMethod","HmacSHA1"},
{"SignatureVersion","2"},
@import <Foundation/CPObject.j>
@import <AppKit/CPOpenPanel.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero()
=ERROR REPORT==== 22-Jun-2009::14:50:13 ===
** Generic server <0.60.0> terminating
** Last message in was {tcp,#Port<0.2498>,
<<"se for 10GbE information, lists 11 different companies offering 10GbE top-of-rack switches. \\u003cb\\u003e...\\u003c/b\\u003e\"}],\"cursor\":{\"pages\":[{\"start\":\"0\",\"label\":1},{\"start\":\"8\",\"\
label\":2},{\"start\":\"16\",\"label\":3},{\"start\":\"24\",\"label\":4},{\"start\":\"32\",\"label\":5},{\"start\":\"40\",\"label\":6},{\"start\":\"48\",\"label\":7},{\"start\":\"56\",\"label\":8}],\"estimatedResultCount\":\"74600000\",\
\"currentPageIndex\":0,\"moreResultsUrl\":\"http://www.google.com/search?oe\\u003dutf8\\u0026ie\\u003dutf8\\u0026source\\u003duds\\u0026start\\u003d0\\u0026hl\\u003den\\u0026q\\u003d10+gb\"}}, \"responseDetails\": null, \"responseStatus\
\": 200}">>}
** When Server state == {state,
{request,#Ref<0.0.0.1325>,<0.202.0>,0,http,
{"ajax.googleapis.com",80},
// Structure jsm file so EXPORTED_SYMBOLS are compressible
function test() {
// Just a test to make sure jsm files are initialized
// the way I assume, so state is updated properly
hello.what = "there";
var x = 5;
var y = 0;