Skip to content

Instantly share code, notes, and snippets.

@RSully
RSully / regex-pricing.txt
Created December 29, 2014 20:10
Regex to match US pricing (without dollar sign)
^(\d*)(\.(\d{0,2})?)?$/
@RSully
RSully / README
Created June 17, 2011 16:02
Easy to use UIAlertView subclass to get text input
Usage:
-(void)doStuff:(id)sender {
NSString *text = [RSAlertViewTextInput textWithTitle:@"Enter your zipcode" cancelBtn:@"Cancel" submitBtn:@"Submit"];
NSLog(@"nom: %@", text);
}
Easy to use, one line of code. Or you can initialize it and figure it out that way.
@RSully
RSully / .bashrc
Created October 30, 2011 19:46
My basherc file
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
export EDITOR='mate'
export GIT_EDITOR='mate -wl1'
## Aliases
# alias ls="ls --color=always"
alias ls="ls -G"
alias ll="ls -l -h"
@RSully
RSully / challenge1.py
Created February 10, 2012 23:07
Challenged from apply.embed.ly
def nBang(n):
mul = 1
for i in xrange(1,n+1):
mul *= i
return mul
def R(n):
bang = str(nBang(n))
sum = 0
for i in xrange(0, len(bang)):
@RSully
RSully / 6npm1.py
Created February 11, 2012 22:40
6n ± 1
from math import floor
def pp(n):
return (6*(floor(n/2)+1)) + (-1 if n % 2 == 0 else 1)
for i in xrange(0, 50):
print "%d\t\t%d" % (i, pp(i))
@RSully
RSully / primes.py
Created February 12, 2012 00:13
Prime generator - draft concept of 6n±1
prev = []
start = 5
num = start
lastPrime = (0,0)
ctr = 2 # 5 is the 3rd prime
while ctr < 50000:
isPrime = not any(num % n == 0 for n in prev)
if isPrime:
ctr += 1
@RSully
RSully / byte_freq.rb
Created March 3, 2012 02:17
Byte frequency counter in ruby
if ARGV.count != 1
puts "Usage: [command ...] <file>"
exit
end
f = File.new(ARGV[0], 'r')
hash = Hash.new
f.each_byte do |byte|
@RSully
RSully / vector_sum.basic
Created March 9, 2012 11:02
Vector summation calculator
# Get the amount of vectors we need to sum
Input "SUM HOW MANY? ", A
# Clear the previous lists
ClrList lVSUA
ClrList lVSUB
ClrList lVSUX
ClrList lVSUY
# Zero-out each list with A items
@RSully
RSully / generate.sh
Created October 8, 2015 17:56
Generate commands to reinstall homebrew packages
#!/usr/bin/env bash
brew tap | while read tap;
do
echo "brew tap $tap"
done
brew list | while read formula;
do
options=$(brew info --json=v1 $formula | jq '.[0] .installed | sort_by(.version) [0] .used_options | join(" ")' -r)
@RSully
RSully / libcec-sample.cpp
Last active October 26, 2015 22:54
Sample code for libCEC initialization
//
// main.cpp
// Test libCEC
//
// Created by Ryan Sullivan on 10/26/15.
// Copyright © 2015 Ryan Sullivan. All rights reserved.
//
#import <iostream>
#import <cec.h>