Skip to content

Instantly share code, notes, and snippets.

View cjhanks's full-sized avatar
🔥

zeekoni cjhanks

🔥
View GitHub Profile
@cjhanks
cjhanks / ffmpeg_parse.cc
Created March 31, 2012 03:12
ffmpeg parsing
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
/**
* This simple argv parser splits a command like:
* ffmpeg -f libx264 -i input.avi -acodec libmp3lame -ab 128k -ar 44100 -vcodec
* mpeg2video -vf scale=160:128 -b 176k -r 15 -strict -1 -ab output.mpg
*
@cjhanks
cjhanks / c_style.cc
Created April 26, 2012 09:48
LtoA and StringStreams
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
using std::string;
char*
@cjhanks
cjhanks / gist:2792832
Created May 26, 2012 07:49
Nested Class
class SomeParentClass:
""" @class SomeParentClass
An arbitrary class.
"""
def __init__(self):
pass
def some_member_function(self, var):
""" This function takes in a variable and places it into a nested
function unload
{
match=$(grep --text --line-number '^PAYLOAD:$' $0 | cut -d ':' -f 1)
pay_start=$((match + 1))
tail -n +$pay_start $0 | tar -xzvf -
}
@cjhanks
cjhanks / gist:2950501
Created June 18, 2012 20:25
Class Member Ref
<?php
class TestAchat
{
var $ref;
public function __construct(&$ref_val)
{
$this->ref = &$ref_val;
$this->ref = "words";
}
@cjhanks
cjhanks / gist:3119269
Created July 15, 2012 23:54
Execution order matters.
if ((write_len = write(out_pipe, buffer,
read_len = read(sock, buffer, BUF_SIZ)))
!= read_len)
fprintf(stderr, "%s\n", "Error!");
IFS=': ' read -a mimetype <<< "`file $0`" ; echo "PIP THE MAGIC ${mimetype[1]}"
IFS=': ' read -a mystery <<< "`file $0`" ; echo "PIP THE MAGIC ${mystery[1]}"
@cjhanks
cjhanks / gist:3306452
Created August 9, 2012 17:50
sys imports & redirection
#!/usr/bin/python
# DOES NOT WORK -------------------------------------------------------------- #
def does_not_work():
from sys import stderr, stdout
_stdout = stdout
stdout = stderr
print('does_not_work()')
@cjhanks
cjhanks / gist:3374043
Created August 16, 2012 22:08
FFMPEG Build
#!/bin/bash
set -e
MAKE_COUNT=4
if [ "`grep -c /etc/apt/sources.list deb-multimedia`" == "0" ];
then
echo "deb http://www.deb-multimedia.org squeeze main non-free" >> /etc/apt/sources.list
apt-get install -y --force-yes deb-multimedia-keyring
@cjhanks
cjhanks / gist:3442547
Created August 23, 2012 22:02
Basic SI
#!/usr/bin/python
def __unit(val):
if not val[-1:].isalpha():
return val
if len(val) <= 1 or val[-2:-1].isalpha():
raise RuntimeError('invalid units')
i = int(val[:-1])