Skip to content

Instantly share code, notes, and snippets.

@phil303
phil303 / sk6812-matrix.py
Last active February 12, 2021 12:20
Create a matrix of LEDs
#!usr/bin/env python2.7
import pcbnew
"""
LED matrix layout creator.
NOTE: this currently assumes an even matrix, e.g. 16x16 as opposed to 15x15.
Will likely break in the latter case.
@phil303
phil303 / low_high_pass_filters.py
Last active May 16, 2019 03:44
Plot the transfer function for simple RL and RC circuits
#! /usr/bin/env python3
import argparse
import math
from sys import argv
import matplotlib.pyplot as plt
import numpy as np
MIN_FREQ = 1

cProfile

Start with cProfile to get a good overview of what's slow.

$ python -m cProfile -s cumulative your_code.py

-s to order by cumulative time

Example output:

To hunt down memory leaks, you can use heapy.

$ pip install guppy

Example code:

from guppy import hpy
hp = hpy()
h = hp.heap()
@phil303
phil303 / maggiesHW.js
Last active March 7, 2017 06:05
Maggie's homework
<html>
<head>
<script type="text/javascript">
// Step 1: create an object that represents an order
var order = {
customerInfo: {
name: 'maggie'
},
lineItems: [

Keybase proof

I hereby claim:

  • I am phil303 on github.
  • I am philaquilina (https://keybase.io/philaquilina) on keybase.
  • I have a public key whose fingerprint is 1AF2 9D44 E073 EDEF 4811 F5C8 E1DA A821 BDB0 6856

To claim this, I am signing this object:

@phil303
phil303 / gist:688f7fdce9c316d0e48d
Created July 10, 2014 16:27
Lodash vs Underscore Benchmarks
/code Chrome 35.0.1916.153 on OS X 10.9.3
`_(...)` with a number:
lodash.min x 39,094,087 ops/sec ±1.75% (67 runs sampled)
underscore-min x 16,916,505 ops/sec ±1.78% (83 runs sampled)
lodash.min is 131% faster.
`_(...)` with an array:
lodash.min x 51,700,639 ops/sec ±4.95% (82 runs sampled)
underscore-min x 13,862,501 ops/sec ±0.55% (83 runs sampled)
@phil303
phil303 / gist:5992925
Last active December 19, 2015 17:39
curry method
Function.prototype.curry = function () {
var fn = this, args = Array.prototype.slice.call(arguments);
return function () {
return fn.apply(this, args.concat(Array.prototype.slice.call(arguments)));
};
};
var add = (function(a, b) { return a +b; }).curry(2)
@phil303
phil303 / hashtable.c
Created April 15, 2013 16:54
Simple hashtable in c
#include <stdlib.h>
#include <stdio.h>
int HASH_SIZE = 10;
struct Node {
char *key;
char *value;
struct Node *next;
};
@phil303
phil303 / index.html
Created August 10, 2012 18:34
d3 rules.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Per_month_graph</title>
<script src="http://d3js.org/d3.v2.js"></script>
<style type="text/css" media="all">
.chartText {
font: 5px sans-serif;
}