Skip to content

Instantly share code, notes, and snippets.

Caleb Madrigal calebmadrigal

Block or report user

Report or block calebmadrigal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

  • I am calebmadrigal on github.
  • I am calebm ( on keybase.
  • I have a public key whose fingerprint is F775 F481 BE72 409E 856C E93E B870 87DD 2D11 1E54

To claim this, I am signing this object:

calebmadrigal /
Created Feb 24, 2015
import random
from collections import deque
queue = deque()
for i in range(10):
print([queue.popleft() for _ in range(len(queue))])
calebmadrigal /
Last active Dec 16, 2015
Function to get the PythonAnywhere gist viewer for a given gist file.
import urllib2
def get_raw_gist(raw_gist_url):
return urllib2.urlopen(raw_gist_url).read()
def python_anywhere_gist_url(gist_num, gist_file, py_version="python2"):
return "{0}/{1}/{2}".format(gist_num, gist_file, py_version)
print get_raw_gist("")
print python_anywhere_gist_url(5504352, "")
calebmadrigal / FourierCoeff.ipynb
Created Dec 18, 2012
iPython Notebook demonstration of how to find Fourier coefficients.
View FourierCoeff.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
calebmadrigal / base64_NSString.m
Created Feb 22, 2012
Objective-C method which takes an NSString* and returns an base64-encoded NSString*
View base64_NSString.m
+ (NSString *)base64String:(NSString *)str
NSData *theData = [str dataUsingEncoding: NSASCIIStringEncoding];
const uint8_t* input = (const uint8_t*)[theData bytes];
NSInteger length = [theData length];
static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
NSMutableData* data = [NSMutableData dataWithLength:((length + 2) / 3) * 4];
uint8_t* output = (uint8_t*)data.mutableBytes;
You can’t perform that action at this time.