Skip to content

Instantly share code, notes, and snippets.

View lelandbatey's full-sized avatar

Leland Batey lelandbatey

View GitHub Profile
lelandbatey /
Created June 21, 2014 23:53
Auto-compile ffmpeg
# Auto-compiles and installs ffmpeg, as per the official instruction:
# Only up to date as of June 21st, 2014
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev \
lelandbatey /
Created August 1, 2014 01:07
Prints a perfect binary tree of given height, just for fun : )
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
if sys.stdout.isatty():
IS_TERM = True
lelandbatey /
Last active August 29, 2015 14:05
Obfuscated Tree Printer
#!/usr/bin/env python
from __future__ import print_function
import sys
def strip_comments(instr):
outStr = ""
for line in instr.split('\n'):
outStr+= line.split('//')[0] + '\n'
return outStr
lelandbatey / tiny_tree.c
Last active August 29, 2015 14:06
Tiny binary tree printer.
typedef int j;j p(j t,j l){for(;l;--l)putchar(t);}
j main(j c,j**v){j i,h=5;c>1?h=atoi(v[1]):0;h=1<<h;j b=h;for(;b;){b/=2;
//Prints the following:
// @
// @ @
// @ @ @ @
// @ @ @ @ @ @ @ @
function p($i, $l){
for ($x=0;$x<$l; ++$x){
function mk_tree($h=5){
while ($b>1){
ffmpeg -re -i "some_file.mkv" -c:v libx264 -crf 18 -preset veryfast -async 1 -maxrate 1500k -c:a aac -strict experimental -b:a 192k -ar 44100 -ac 2 -bsf:v h264_mp4toannexb -maxrate 1000k -bufsize 3000k -f mpegts udp://
lelandbatey /
Created January 12, 2015 20:24 -- A Rust port of my original tiny_tree.c:
use std::os;
use std::num::Int;
// Helper function to print out single characters repeatedly.
fn repeat_char(ch: char, mut n: i32){
while n > 0 {
print!("{}", ch.to_string());
n = n-1;
lelandbatey /
Last active August 29, 2015 14:13
A minimal example of a problem with the Python static analyzer.
# This is the pseudocode for the actual code where I found this error
def big_function_to_handle_many_different_cases(varA, varB):
temporary_buffer = ""
def do_the_boilerplate():
temporary_buffer = "" # Reset the temporary_buffer
for thing in varA:
lelandbatey /
Last active August 29, 2015 14:18
Emscripten problem


When compiling this[0] C++ file with Emscripten, the compiled javascript file produces incorrect output when run with node (using node v0.12.0 on all platforms). This is not "serious" code, it is a toy minified raytracer, as found here[1]. I have tried to find any information on the Emscripten website regarding less-than-compatible behavior this source file might be doing which makes it run incorrectly, but I have had no luck.

In attempting to narrow the problem, I also constructed a small program which seems to break in a similar way, which can be found here[6].

I come here hoping that it is simply an oversight by me in how this code is written or how I'm compiling it.

Steps to reproduce:

lelandbatey / remove_lf.ps1
Last active August 29, 2015 14:25
Remove errant line-feed characters in Windows csv
# To run this file, change the value below where it says ".\sample.csv" to the
# path to the CSV file you want to change. Then, to have this script write to
# a new csv file, pipe it into the Out-File cmdlet. For example, you might run
# invocation like this:
# .\remove_lf.ps1 | Out-File .\fixed_version.csv -encoding ASCII
# Note the option `-encoding ASCII` above. Leaving this option off might not
# cause any problems, but it may also break the output in some way. See what