Skip to content

Instantly share code, notes, and snippets.

View carsonfarmer's full-sized avatar
🏖️
Remote working...

Carson Farmer carsonfarmer

🏖️
Remote working...
View GitHub Profile
@repustate
repustate / robford.py
Created December 3, 2013 01:38
Using Repustate's API to create a data source to monitor Twitter for information about Rob Ford.
import requests
API_KEY = 'YOUR_API_KEY'
BASE_URL = 'http://social.repustate.com/%(api_key)s/%(call)s.json'
# Create a new data source.
kwargs = {'api_key':API_KEY, 'call':'add-datasource'}
response = requests.post(BASE_URL % kwargs, {'name':'Rob Ford', 'language':'en', 'niche':'general'})
datasource_id = response.json()['datasource_id']
@geotheory
geotheory / galaxy
Created March 17, 2012 13:22
Colliding galaxies in Processing
// Galaxy collisions
Star[] Stars;
PVector[] galp;
PVector[] galv;
color[] galcol, galcol2;
boolean paused = false;
int side = 100; // border around Stars' initial positions
int Startot = 300; // number of Stars
int obsize = 10; // size of Stars
@erynofwales
erynofwales / AlmostEquatable.swift
Created November 7, 2015 07:14
An AlmostEquatable protocol for Swift floating point types
import Foundation
public protocol AlmostEquatable {
@warn_unused_result
func ==~(lhs: Self, rhs: Self) -> Bool
}
public protocol EquatableWithinEpsilon: Strideable {
static var Epsilon: Self.Stride { get }
}
@Bluebie
Bluebie / account.js
Created November 2, 2019 09:47
Partially encrypted account model for IPFS app
// Model to represent an account in the distributed database
// Accounts are mainly a place users can store information like their private keys, in a password protected
// vault, so they can login conveniently from other devices and keep hold of their private keys and record
// what blogs they are authors of. It's also a way for other users to lookup an authors public keys to validate
// their other objects when determining if a new version of some data really belongs to the blog it claims to be
// related to.
const nacl = require('tweetnacl')
const cbor = require('borc')
class HSAccount {
const { Transform } = require('stream');
class AppendInitVect extends Transform {
constructor(initVect, opts) {
super(opts);
this.initVect = initVect;
this.appended = false;
}
_transform(chunk, encoding, cb) {
@natecook1000
natecook1000 / openRanges.swift
Last active May 27, 2021 19:37
Open-ended range operators for Swift
// Open-ended range operators
//
// 100... is equivalent to 100...Int.max
// ...-100 is equivalent to Int.min...-100
// ..<3 is equivalent to Int.min..<3
import Swift
/// Conforming types provide static `max` and `min` constants.
protocol MinMaxType {
@Robsteranium
Robsteranium / statistics-distributions.js
Created May 11, 2012 20:20 — forked from benrasmusen/statistics-distributions.js
JavaScript library for calculating critical values and upper probabilities of common statistical distributions
/*
* NAME
*
* statistics-distributions.js - JavaScript library for calculating
* critical values and upper probabilities of common statistical
* distributions
*
* SYNOPSIS
*
*
// Simple example of how to display an image from IPFS on your html web page
// Using ipfs/js-ipfs : https://github.com/ipfs/js-ipfs#use-in-the-browser
// Don't forget to include the scripts into your html page:
// <script src="https://unpkg.com/ipfs/dist/index.min.js"></script>
// <script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.min.js"></script>
function showIPFSImage () {
// Create the IPFS node instance
const node = new Ipfs()
@brentp
brentp / betareg.py
Last active June 24, 2022 11:46
beta regression in statsmodels
# -*- coding: utf-8 -*-
u"""
Beta regression for modeling rates and proportions.
References
----------
Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression
in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in
Economics and Statistics, 2011.
@chris-rock
chris-rock / crypto-stream.js
Last active October 6, 2022 18:38
Encrypt and decrypt streams
// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption of buffers
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
var fs = require('fs');
var zlib = require('zlib');