Skip to content

Instantly share code, notes, and snippets.

View fizzbuzz.py
#!/usr/bin/python3
pairs = (
(3, "Fizz"),
(5, "Buzz"),
)
View FizzBuzz.hs
pairs = [(3, "Fizz"), (5, "Buzz")]
main = mapM_ (putStrLn . fizzLine) [0..100]
where fizzLine x = if output /= "" then output else show x
where output = concat (map snd matches)
matches = filter (\pair -> x `rem` fst pair == 0) pairs
View gist:3878147
import System.Environment
import Control.Monad
addNumbers strs = zipWith (\a b -> show a ++ " " ++ b) [1..] strs
main = do
args <- getArgs
text <- if length args > 0
then readFile (head args)
else getContents
View gist:6214243
diff --git a/PKGBUILD.buggy b/PKGBUILD
index c4ad354..b8c01ab 100644
--- a/PKGBUILD.buggy
+++ b/PKGBUILD
@@ -31,9 +31,6 @@ prepare() {
# Get the ANT_HOME environment variable
source /etc/profile.d/apache-ant.sh
- mkdir -p $pkgdir/usr/share/eclipse
- mkdir -p $pkgdir/usr/share/vim/vimfiles
View fbmessenger.fb
require 'formula'
class Fbmessenger < Formula
homepage 'https://github.com/oconnor663/fbmessenger'
url 'https://github.com/oconnor663/fbmessenger/archive/master.zip'
version '0.2.0'
# The build won't work without the brew version of python2
depends_on "python"
View udpclient.py
import sys
import socket
import json
import hashlib
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
View udpserver.py
import socket
import hashlib
import json
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
@oconnor663
oconnor663 / imagemagick-for-rmagick.patch
Created Sep 9, 2013
imagemagick PKGBUILD changes for compatibility with rmagick
View imagemagick-for-rmagick.patch
diff --git a/PKGBUILD.old b/PKGBUILD
index 3fd9a4a..ab2a25d 100644
--- a/PKGBUILD.old
+++ b/PKGBUILD
@@ -27,7 +27,7 @@ prepare() {
build() {
cd ImageMagick-${pkgver%.*}-${pkgver##*.}
./configure --prefix=/usr --sysconfdir=/etc --with-modules --disable-static \
- --enable-hdri --with-wmf --with-openexr --with-xml --with-lcms2 --with-jp2 \
+ --with-wmf --with-openexr --with-xml --with-lcms2 --with-jp2 \
@oconnor663
oconnor663 / gist:7934599
Created Dec 12, 2013
fbmessenger crash
View gist:7934599
*** Error in `/usr/bin/python3': malloc(): smallbin double linked list corrupted: 0x00000000041de6a0 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x72e5f)[0x7f3cf3c3ee5f]
/usr/lib/libc.so.6(+0x7862e)[0x7f3cf3c4462e]
/usr/lib/libc.so.6(+0x7a834)[0x7f3cf3c46834]
/usr/lib/libc.so.6(__libc_malloc+0x60)[0x7f3cf3c47c50]
/usr/lib/libcurl.so(+0xc16d)[0x7f3c444cf16d]
/usr/lib/libcurl.so(+0xc383)[0x7f3c444cf383]
/usr/lib/libcurl.so(+0xd53e)[0x7f3c444d053e]
/usr/lib/libcurl.so(+0x11d69)[0x7f3c444d4d69]
@oconnor663
oconnor663 / gist:8063575
Created Dec 21, 2013
How to restore Kingdom Rush game data from backup.ab
View gist:8063575
# This might, maybe, conceivably work as a script. But I suggest executing all
# the commands manually, because I doubt everything will Just Work,
# particularly the 'adb root' command. Setting the '-e' option makes the script
# exit on the first error, in case you do want to run it.
set -e
# First, make a copy of backup.ab, because if we accidentally delete it we're
# screwed.
OUR_TMPDIR=`mktemp -d`
cp backup.ab $OUR_TMPDIR