Skip to content

Instantly share code, notes, and snippets.

View lelandbatey's full-sized avatar

Leland Batey lelandbatey

View GitHub Profile
@lelandbatey
lelandbatey / ffmpeg-compile.sh
Created June 21, 2014 23:53
Auto-compile ffmpeg
#!/bin/bash
# Auto-compiles and installs ffmpeg, as per the official instruction:
# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
#
# 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
lelandbatey / treePrint.py
Created August 1, 2014 01:07
Prints a perfect binary tree of given height, just for fun : )
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
IS_TERM=False
if sys.stdout.isatty():
IS_TERM = True
if IS_TERM:
@lelandbatey
lelandbatey / c_white_reducer.py
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
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;
for(i=b?h/b:0;i;i--)p(32,b-1),p(!(i%2)*32+32,1);p(10,1);}}
//Prints the following:
//
// @
// @ @
// @ @ @ @
// @ @ @ @ @ @ @ @
<?php
echo('<pre>');
function p($i, $l){
for ($x=0;$x<$l; ++$x){
echo(chr($i));}
}
function mk_tree($h=5){
$i=0;$h=1<<$h;$b=$h;
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://127.0.0.1:1234
@lelandbatey
lelandbatey / tiny_tree_print.rs
Created January 12, 2015 20:24
tiny_tree.rs -- A Rust port of my original tiny_tree.c: https://gist.github.com/lelandbatey/99f3c4b99c621c12631d
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
lelandbatey / context.py
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():
SOME_GLOBAL_ARRAY.append(temporary_buffer)
temporary_buffer = "" # Reset the temporary_buffer
for thing in varA:
@lelandbatey
lelandbatey / emscripten_problem.md
Last active August 29, 2015 14:18
Emscripten problem

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
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
# this file (AFTER MODIFYING THE PATH TO THE INPUT FILE DOWN BELOW) with an
# 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