Skip to content

Instantly share code, notes, and snippets.

def friendships
return [] if @relationships[8].blank?
@relationships[8].uniq do |r|
related = @entity.id == r.entity1_id ? r.related : r.entity
related
end
end

I have imported all the 2012 data individual contributions into a database and noticed that there is a microfilm number for all 2012 data except for 15J donations.

Query:

select count(*), transactiontype from donations where microfilm is null group by transactiontype;
| count(*) | transactiontype |
+----------+-----------------+
@aepyornis
aepyornis / crypto_demo.js
Created March 16, 2016 22:45
So you wanna use an HMAC?
const sjcl = require('./sjcl');
// Whereat submits user location data without any personally identifying information.
// In JSON this looks like:
var data = {
lat: 19.446597,
lng: -99.135018,
ttl: 20
};
@aepyornis
aepyornis / Thread_experiments_in_python_part1.md
Created November 2, 2015 03:53
Thread Experiments in Python: Part 1

Thread Experiments in python: part 1

Threads allow multiple concurrent process to occur at once. If not done carefully, this can lead to strange effects.

Here's a program that counts up to 100,000, keeping track of the count in a global variable:

count = 0

def count_to_100000():
var async = require('async');
function big_calculation() {
var count = 0;
for (var i = 0; i < 100000; i++) {
for (var j = 0; j < 100000; j++) {
count += 1;
}
}
return count;
Var fs = require('fs');
var turf = require('turf');
var nyc = JSON.parse(fs.readFileSync('nyc_all5.geojson'));
var bbox = [-74.33624, 40.449037, -73.6688232, 40.981971];
//create hex-grid for NYC area
var hex = turf.hexGrid(bbox, 0.5, "miles");
//extract polygons from feature collections:

A tour of clojure(script) syntax.

Perhaps you will or won't find this interesting, but I think clojure provides some compelling form to work with. I've essentially just going over the bits that are different from languages we are used to, like javascript. Anyways, it's just help for me to write this all down.

data structures: There are are immutable, which is part of the big selling point of clojuire.

Maps:

function doSomething() {
var someValue = "this is an important value";
anotherFuctionDefinedElsewhere();
}
function anotherFuctionDefinedElsewhere () {
// this function can't access someValue
console.log(someValue);
}
@aepyornis
aepyornis / map_array_properties.js
Last active October 6, 2015 15:01
Arrays and Properties
var _ = require('underscore');
var arr = [1,2,3,4]
arr.someProperty = "blah blah blah";
// this prints out only 1,2,3,4
_.each(arr, function(x){
console.log(x);
})

Keybase proof

I hereby claim:

  • I am aepyornis on github.
  • I am zy (https://keybase.io/zy) on keybase.
  • I have a public key whose fingerprint is FFE6 48C8 E335 C52A BB57 1EA7 A40D 8B63 5065 8609

To claim this, I am signing this object: