Skip to content

Instantly share code, notes, and snippets.

View jprystowsky's full-sized avatar

Jacob Prystowsky jprystowsky

View GitHub Profile
@jprystowsky
jprystowsky / 0: Start
Last active August 29, 2015 14:07
Hello Shawn, a basic Python Twisted example
1. Install python3 E.g., apt-get install python3, brew install python3, etc.
2. pip3 install twisted
3. python3 app.py
4. GET localhost:8880
@jprystowsky
jprystowsky / GetAuthenticationUriSubstring.cs
Created July 10, 2014 00:38
This is a snippet of code I wrote while writing an API against the Mixpanel API. If you're building a raw http(s, actually -- thanks guys!) API request and you need to generate a signature for an IDictionary<string,string> of your query arguments, then this method will do it. (Simplified from a more generic implementation for readability; reimpl…
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace Mixpanel.Security {
public class MixpanelApiAuthenticator {
private const string MIXPANEL_API_SECRET = @"Here's your secret, son";
public string GetAuthenticationUriSubstring(IDictionary<string, string> queryArguments) {
@jprystowsky
jprystowsky / gist:6357005
Created August 27, 2013 18:11
Demonstrating how to concatenate arrays and then shuffle them (AngularJS).
// This is inside your callbacks, when you have gotten data -- somehow. Replace vars with the correct var names obviously.
$scope.combined = $scope.combined.concat(data);
$scope.combined = shuffle($scope.combined);
// Elsewhere...
function shuffle(array) {
var currentIndex = array.length
,temporaryValue
@jprystowsky
jprystowsky / gist:6174674
Created August 7, 2013 14:43
CPAs in Ohio are assigned to a reporting group, numbered 1-3, based upon the year in which they became certified. To calculate the next year in which a CPA in Ohio will need to report to the ABO, where the CPA is in group reportingYear and the reference point ("now") is referenceYear, this JavaScript may be used.
function getReportingYear(reportingGroup, referenceYear) {
function rotateCyclicGroup(cyclic, x) {
for (var i = 0; i < x; i++) {
cyclic.splice(0, 0, cyclic.pop());
}
}
var cyclicGroup = [0, 1, 2];
switch (referenceYear % 3) {