Skip to content

Instantly share code, notes, and snippets.

View jbochi's full-sized avatar

Juarez Bochi jbochi

View GitHub Profile
@jbochi
jbochi / skyline.py
Created August 7, 2012 17:12
Solution for dailykata.net - Skyline problem in Python
buildings = [
[1, 11, 5],
[2, 6, 7],
[3, 13, 9],
[12, 7, 16],
[14, 3, 25],
[19, 18, 22],
[23, 13, 29],
[24, 4, 28],
]
@jbochi
jbochi / quicksort.rb
Created August 10, 2012 11:13
Quicksort in Ruby for dailykata.net
# This implementation works, but it does all comparisons twice
# and is not in-place, requiring extra memory and raising
# a stack overflow for large arrays.
def quicksort(array)
return array if array.size <= 1
pivot = array.pop
less = array.select {|x| x <= pivot }
greater = array.select {|x| x > pivot }
quicksort(less) + [pivot] + quicksort(greater)
@jbochi
jbochi / gist:3331737
Created August 12, 2012 13:02
Fibonnaci in C for dailykata.net
#include <stdio.h>;
int fib(int n) {
if (n == 1) {
return 1;
} else if (n == 0) {
return 0;
} else {
return fib(n - 1) + fib(n - 2);
}
@jbochi
jbochi / gist:3716147
Created September 13, 2012 17:47
pypy translation error
[root@videos3s2 goal]# /opt/generic/python27/bin/python translate.py -O2
[platform:msg] Set platform with 'host' cc=None, using cc='gcc'
[translation:info] Translating target as defined by targetpypystandalone
[platform:execute] gcc -c -O3 -pthread -fomit-frame-pointer -Wall -Wno-unused /tmp/usession-release-1.9-8/gcctest.c -o /tmp/usession-release-1.9-8/gcctest.o
[platform:execute] gcc /tmp/usession-release-1.9-8/gcctest.o -pthread -lrt -o /tmp/usession-release-1.9-8/gcctest
[platform:execute] gcc -c -O3 -pthread -fomit-frame-pointer -Wall -Wno-unused /tmp/usession-release-1.9-8/platcheck_0.c -o /tmp/usession-release-1.9-8/platcheck_0.o
[platform:execute] gcc /tmp/usession-release-1.9-8/platcheck_0.o -pthread -lrt -o /tmp/usession-release-1.9-8/platcheck_0
[platform:execute] gcc -c -O3 -pthread -fomit-frame-pointer -Wall -Wno-unused /tmp/usession-release-1.9-8/platcheck_1.c -o /tmp/usession-release-1.9-8/platcheck_1.o
[platform:execute] gcc /tmp/usession-release-1.9-8/platcheck_1.o -pthread -lrt -o /tmp/uses
@jbochi
jbochi / gist:3739698
Created September 17, 2012 20:54
pypy translation error - CentOS 5
[translation:info] written: /tmp/usession-release-1.9-17/testing_1/testing_1.c
[translation:info] Compiling c source...
[platform:execute] make -j 5 in /tmp/usession-release-1.9-17/testing_1
[platform:Error] data_module_cpyext_pyobject.c:133: warning: initialization from incompatible pointer type
[platform:Error] data_module_cpyext_pyobject.c:173: warning: initialization from incompatible pointer type
[platform:Error] data_module_cpyext_pyobject.c:303: warning: initialization from incompatible pointer type
[platform:Error] data_module_cpyext_pyobject.c:323: warning: initialization from incompatible pointer type
[platform:Error] data_module_cpyext_pyobject.c:433: warning: initialization from incompatible pointer type
[platform:Error] data_module_cpyext_pyobject.c:453: warning: initialization from incompatible pointer type
[platform:Error] data_module_cpyext_pyobject.c:548: warning: initialization from incompatible pointer type
/opt/generic/python27/bin/python
Python 2.7.1 (r271:86832, May 19 2011, 15:54:57)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> all
<built-in function all>
@jbochi
jbochi / hlsclient_input_webm.json
Last active June 2, 2016 19:35 — forked from hltbra/hlsclient_input_v2.json
New input JSON for hlsclient
{
"streams": {
"Nasa-high": {
"input-path": "/msfc/Wifi.m3u8",
"servers": ["http://liveips.nasa.gov.edgesuite.net"],
"bandwidth": 1080434
}
},
"actions": [
@jbochi
jbochi / compose.py
Created September 29, 2012 11:29
function composition in python
class O():
def __repr__(self):
return "<" + ' *o* '.join(map(repr, self.funs)) + ">" if self.funs else "<composer>"
def __init__(self, funs=None):
self.funs = funs if funs else []
def __rmul__(self, other):
other_funs = other.funs if isinstance(other, O) else [other]
return O(other_funs + self.funs)
@jbochi
jbochi / merge.scala
Created October 17, 2012 16:42
merge sort in scala
def msort(xs: List[Int]): List[Int] = {
val n = xs.length / 2
if (n == 0) xs
else {
def merge(xs: List[Int], ys: List[Int]): List[Int] = (xs, ys) match {
case (Nil, ys) => ys
case (xs, Nil) => xs
case (x :: xs1, y :: ys1) =>
if (x < y) x :: merge(xs1, ys)
else y :: merge(xs, ys1)
@jbochi
jbochi / pascal.py
Created November 21, 2012 23:01 — forked from hltbra/pascal.py
Pascal triangule using recursion
def print_pascal_triangle(n_lines):
for row in xrange(n_lines):
for col in xrange(row + 1):
print pascal(row, col),
print
def pascal(row, col):
if col == 0 or row == col:
return 1