Skip to content

Instantly share code, notes, and snippets.


Chris Barna ctbarna

View GitHub Profile

Department of Education

  • Documentation is clear, if a little poorly formatted.
    • Not the biggest fan of the monospace type as body copy.
    • I like the queries tab but it's not immediately obvious that it's something that I can interact with.
  • Document the data that gets returned!
  • Correct types.
    • Numbers should be unquoted
    • Are all the "note on count/percentage"s the same for every endpoint? If
ctbarna / 0_reuse_code.js
Created Jan 14, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
class ContentTypeForeignKey(models.ForeignKey):
def __init__(self, **kwargs):
if "choices" in kwargs:
kwargs["choices"] = self._process_choices(kwargs["choices"])
# It is possible for `to` to be passed in with **kwargs. Since
# ContentType is hardcoded in for the `to` arg when calling super(),
# this can lead to problems.
if "to" in kwargs:
del kwargs["to"]
ctbarna / m.js
Created Oct 15, 2012
Round orders of magnitude in JS.
View m.js
function m(n, d) {
P = Math.pow;
R = Math.round
d = P(10, d);
i = 7;
while(i) {
(s = P(10, i-- * 3)) <= n && (n = R(n * d / s) / d + "KMGTPE"[i])
ctbarna / createContext.js
Created Oct 9, 2012
Closure to generate a contextual jQuery selector.
View createContext.js
var $createContext = function (context) { return function(selector) { return $(selector, context) }; };
ctbarna /
Created Aug 7, 2012
Abstracting comparisons in Python
import operator
def do_this (operation, a, b):
return getattr(operator, operation)(a, b)
do_this('eq', 1, 1) # returns True
do_this('gt', 1, 0) # returns True
do_this('le', 1, 0) # returns False
ctbarna /
Created Aug 2, 2012
Coffeescript Color Interpolator
root = exports ? window
Number::toPaddedString = (radix, digits=2) ->
str = this.toString(radix)
while str.length < digits
str = "0" + str
Number::toPaddedString = (radix, digits=2) ->
str = this.toString(radix)
while str.length < digits
str = "0" + str
ctbarna / hw4prob1.r
Created May 12, 2012
2d Ising Model
View hw4prob1.r
# hw4prob1.r
# 2d ising model
hamiltonian <- function (E, J, sig, N) {
nearest_neighbor_sum = sum(sig[1:N-1,]*sig[2:N,], sig[,1:N-1]*sig[,2:N])
return(-E * nearest_neighbor_sum - J * sum(sig))
ising <- function (E, J, N, beta, iterations) {
number = N*N
View Install-PARIGP.mkd

Installing PARI/GP on Mac


  • Apple Developer Tools
    • Note: this is like 2GB. You might be better off simply installing the gcc compiler from here. I actually have no idea if this will work but if somebody is brave enough to try, that'd be awesome.
  • Slight knowledge of the command line (or at least a little bravery and some faith).