Skip to content

Instantly share code, notes, and snippets.

@graham
graham / gist:98e47f064b09ee44047a
Last active August 29, 2015 14:11
Deconstruct the oneliner
oneliner = 'output.writerow(map(lambda x: x[1], filter(lambda x: True if x[0] else False, zip(filter_map,line))))'
# First, we zip two lists together, in this case we take something like:
# x = [ {}, {}, {'one':1} ]
# y = [ [one, one, one], [two, two, two], [three, three, three] ]
# and turn it into:
# z = [ ({}, [one, one, one]), ({}, [two, two, two]), ({'one':1}, [three, three, three]) ]
test_list = zip(filter_map, line)
// to generate the number of days since a date
var days = (new Date() - new Date(2014, 7, 11)) / (1000 * 60 * 60 * 24);
var days_whole = Math.floor(days);
// in order to determine what the date is X days from now (we'll use days_whole)
var now = new Date();
var millis_to_date = days_whole * (1000 * 60 * 60 * 24);
var next_date = new Date(now.getTime() + millis_to_date);
@graham
graham / gist:d67f4959b2dccc2f8637
Created April 29, 2015 19:18
Rebar3 Dependency Issue
===> Compiling eredis
===> erl_opts [debug_info,{d,namespaced_types}]
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace
===> Uncaught error: {'EXIT',
{function_clause,
[{filename,join,
[[]],
[{file,"filename.erl"},{line,392}]},
{rebar_erlc_compiler,expand_include_lib_path,
1,
### Keybase proof
I hereby claim:
* I am graham on github.
* I am grahamabbott (https://keybase.io/grahamabbott) on keybase.
* I have a public key whose fingerprint is 0BAA 821A 77E9 E1E5 867A A206 D9C9 DDED 8B57 A99A
To claim this, I am signing this object:
{
"version":"2.0",
"metadata":{
"apiVersion":"2015-03-31",
"endpointPrefix":"apigateway",
"serviceFullName":"API Gateway",
"signatureVersion":"v4",
"protocol":"rest-json"
},
"documentation":"",
@graham
graham / code_search.bash
Last active December 6, 2015 13:33
Code Search with Bash
function ga_code_search() {
# alias todo='ga_code_search "TODO\(`whoami`\)"'
SCREEN_WIDTH=`stty size | awk '{print $2}'`
SCREEN_WIDTH=$((SCREEN_WIDTH-4))
# Given a spooky name so you can alias to whatever you want.
# (cs for codesearch)
# AG is WAY faster but requires a binary
# (try brew install the_silver_searcher)
// This is likely to break, because I'm sure a gmail update will change some of the tags,
// but it's helpful if people have special css classes on their emails.
function removeChildStyles(dom_element) {
dom_element.style = null;
for(var index=0; index < dom_element.children.length; index++) {
removeChildStyles(dom_element.children[index]);
}
}
/*
Copyright [2014] [Graham Abbott <graham.abbott@gmail.com>]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
//my config file
var padding = 4;
var pushRight = slate.operation("push", {
"direction" : "right",
"style" : "bar-resize:screenSizeX/2"
});
var pushLeft = slate.operation("push", {