Skip to content

Instantly share code, notes, and snippets.

@oliland
oliland / today.hs
Created September 4, 2011 14:26
Dawn of the nth Day
module Main where
import System( getArgs )
import Data.Char
import Control.Exception (bracket_)
import qualified UI.HSCurses.Curses as Curses
import qualified UI.HSCurses.CursesHelper as CursesH
import Data.Time.Clock
import Data.Time.Calendar
#!/bin/bash
USERNAME = oliland
for REPO in private-repo-1 private-repo-2 private-repo-N
do
git clone [email protected]:$USERNAME/$REPO.git
sed -i '' -e 's/github\.com/bitbucket\.org/g' "$src/$dir/.git/config"
cd $REPO
git push origin master
@oliland
oliland / bootstrap-fix.css
Created November 13, 2012 18:12
Twitter bootstrap ugliness fix
@media (min-width: 981px) {
body {
/* Fix for the hero unit resizing */
padding-top: 60px;
}
}
@oliland
oliland / gist:4996396
Last active December 14, 2015 00:08
Solution for "Array Addition 1" on coderbyte. We sort the list of numbers, then pop off the largest. We then walk down the reversed array subtracting until we hit 0 or until we go below 0 - if we go below 0 we skip subtracting that number. If we reach the end of the list and haven't hit 0 yet, then we just pop off the largest number and repeat t…
def array_addition(array):
array = sorted(array)
largest = array.pop()
while (True):
result = largest
for x in reversed(array):
result = result - x
if result == 0:
return True
elif result < 0:
@oliland
oliland / gist:5005004
Last active December 14, 2015 01:19
Solution for Array Addition II on coderbyte - allowing negative numbers.
def ArrayAddition(arr):
arr = sorted(arr)
# preprocess array to remove negative numbers
difference = 0
for x in arr:
if x < 0:
x = abs(x)
difference = difference + x
largest = arr.pop() + difference
while (True):
@oliland
oliland / gist:5416438
Created April 18, 2013 21:37
An example of using CIFilters to mess with UIViews on iOS.
- (void)viewDidLoad
{
[super viewDidLoad];
// Great tutorial: http://www.raywenderlich.com/22167/beginning-core-image-in-ios-6
// Official docs: https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/CoreImaging/ci_intro/ci_intro.html#//apple_ref/doc/uid/TP30001185-CH1-TPXREF101
// Alt-click on function names for more!
// Make any old label, with our frame set to the view so we know it's there.
UILabel *label = [[UILabel alloc] initWithFrame:self.view.frame];
@oliland
oliland / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
class Sensor:
def __init__(self, psf):
# helper methods for fourier transforms of a PSF
size = psf.shape[-2:]
# pad image bounds to double PSF size
pad_size = [s * 2 for s in size]
# find coordinates of center in padded image
ys = (pad_size[0] - size[0]) // 2