Skip to content

Instantly share code, notes, and snippets.

View ColinEberhardt's full-sized avatar

Colin Eberhardt ColinEberhardt

View GitHub Profile
@rvanbruggen
rvanbruggen / 1-load_gtdb_script.cql
Last active February 18, 2020 13:06
Global Terrorism Database
//load Global Terrorism Database
//Copy/Paste the load script below into your Neo4j-shell command-line utility
//In order to accelerate the loading process, you want to download the CSV file from
//https://www.dropbox.com/s/oequ58lrp8f9w6v/gtdb_transform.csv?dl=1 and then to a local file.
//After that, you would of course need to replace the URL in all of the queries below, and replace it with
//load csv with headers from "file:/path/to/your/file.csv" as csv
//load the countries
load csv with headers from "https://www.dropbox.com/s/oequ58lrp8f9w6v/gtdb_transform.csv?dl=1
@krzyzanowskim
krzyzanowskim / integerWithBytes
Last active May 30, 2018 03:36
integerWithBytes Swift way
// Playground - noun: a place where people can play
import Foundation
typealias Byte = UInt8
protocol GenericIntegerType: IntegerType {
init(_ v: Int)
init(_ v: UInt)
init(_ v: Int8)
@ericelliott
ericelliott / fp-lingo.md
Last active February 2, 2023 23:33
A Guide to Functional Programming Lingo for JavaScripters

A Guide to Functional Programming Lingo for JavaScripters

Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.

The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!

All examples using ES6 syntax. wrap (foo) => bar means:

function wrap (foo) {
func s(x:Int)->[Int]{
return x<2 ?
[]:
// Single line closure has implicit return
// Closure type is Int->[Int]
{[$0]+s(x/$0)}( // Argment to closure
// Filter full range 2 to x and take first factor (non lazy)
// x%x is guaranteed to be 0 so safe to take first element
filter(2...x){x % $0 == 0}[0]
)
struct InputStreamGenerator : Generator {
var inputStream : NSInputStream
var chunkSize : Int
init(inputStream : NSInputStream, chunkSize : Int) {
self.inputStream = inputStream
self.chunkSize = chunkSize
}
var dom = Bloop.dom;
var Box = Bloop.createClass({
getInitialState: function() {
return { number: 0 };
},
updateNumber: function() {
this.state.number++;
},
@willurd
willurd / web-servers.md
Last active May 7, 2024 14:57
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@mbostock
mbostock / README.md
Last active June 7, 2023 18:33
Underscore’s Equivalents in D3

Collections

each(array)

Underscore example:

_.each([1, 2, 3], function(num) { alert(num); });
@prabirshrestha
prabirshrestha / TextFieldChanges.m
Created August 2, 2012 13:53
Reactive Cocoa examples
@synthesize firstName = _firstName;
@synthesize txtFirstName = _txtFirstName;
[RACAbleSelf(self.firstName) subscribeNext:^(id x) { [self firstNameChanged:x]; }];
[self rac_bind:RAC_KEYPATH_SELF(self.firstName) to:self.txtFirstName.rac_textSubscribable];
- (void) firstNameChanged:(id)firstName {
NSLog(@"changed: %@", firstName);
}