Skip to content

Instantly share code, notes, and snippets.

@joequery
joequery / gist:2486369
Created April 25, 2012 04:31
FFMpeg H264 encode_video function
# encode a video
# arg1: video origin
# arg2: destination
function encode_video(){
ffmpeg -y -i $1 -pass 1 -vcodec libx264 -b 756k -g 15 -bf 3 -refs 6 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method umh -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 3 -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1 -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -acodec libfaac -ab 64k $2
ffmpeg -y -i $1 -pass 2 -vcodec libx264 -b 756k -g 15 -bf 3 -refs 6 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method umh -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 3 -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1 -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -acodec libfaac -ab 64k $2
}
@joequery
joequery / bruteforce.rb
Created May 11, 2012 15:41
How long to brute force a key of length n?
# How long to brute force keys
ks = 1000000000 # A billion keys per second
clusters = 10 # How many computers in the cluster attacking our key?
numChars = 38 # We have 38 characters available to use in the key
n = 100 # Length of the key string
combinations = numChars ** n # This ignores variable length too
# How many years it would take a single computer to brute force.
@joequery
joequery / gist:2870704
Created June 4, 2012 20:34
Stupidtable example
<html>
<head>
<title>Stupid jQuery table sort</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="stupidtable.js?dev"></script>
<script type="text/javascript">
$(function(){
$("table").stupidtable();
console.log($("table tbody tr td").eq(0))
$("table th").bind("click", function(){
@joequery
joequery / gist:3077833
Created July 9, 2012 17:43
Converting a simple website to Python Flask (backup gist!)

Flask is a Python web framework that's steadily increasing in popularity within the webdev world. After reading so many great things about Flask, I decided to try it out myself. I personally find testing out a new framework difficult, because you must find a project complex enough to reveal the framework's quirks, but not so daunting as to take the fun out of the project. Luckily, my PHP/Wordpress powered website filled this role quite nicely - the website simply consists of static content, a contact page, and a blog. If I could not convert such a simple site over to Flask, I would immediately know that Flask and I would not make a good team.

@joequery
joequery / gist:3103138
Created July 13, 2012 06:32
How to Read a Programming Tutorial (gist backup)

Many of us seek to improve ourselves beyond what's required. Many CS students are not content to just make good grades in class; they want to get their hands dirty with real-world projects. Many employees read up on the latest languages and frameworks well beyond office hours, simply because they want to play with technology while learning to build a better product. It's important, however, to ensure our time spent studying new programming techniques does not go to waste.

!(confused) != knowledgeable

@joequery
joequery / gist:3229108
Created August 1, 2012 17:36
Toggl relative line numbers
" use Ctrl+L to toggle the line number counting method
function! g:ToggleNuMode()
if &nu == 1
set rnu
else
set nu
endif
endfunction
nnoremap <C-L> :call g:ToggleNuMode()<cr>
@joequery
joequery / gist:3365121
Created August 16, 2012 00:48
Upgrade fail
/etc/apt$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
libqt4-declarative : Depends: libqt4-sql (= 4:4.8.1-0ubuntu4.2) but 4:4.8.1-0ubuntu4.1 is installed
Depends: libqt4-xmlpatterns (= 4:4.8.1-0ubuntu4.2) but 4:4.8.1-0ubuntu4.1 is installed
libqt4-declarative:i386 : Depends: libqt4-sql:i386 (= 4:4.8.1-0ubuntu4.2) but 4:4.8.1-0ubuntu4.1 is installed
Depends: libqt4-xmlpatterns:i386 (= 4:4.8.1-0ubuntu4.2) but 4:4.8.1-0ubuntu4.1 is installed
@joequery
joequery / gist:3390776
Created August 19, 2012 01:23
Upgrade fail part 2
E: Unmet dependencies. Try using -f.
~/Downloads$ sudo apt-get upgrade -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages have been kept back:
hplip hplip-data libhpmud0 libsane-hpaio linux-generic linux-headers-generic linux-image-generic printer-driver-hpcups printer-driver-hpijs vlc vlc-nox vlc-plugin-notify vlc-plugin-pulse
The following packages will be upgraded:
accountsservice akregator apport apport-kde aptdaemon aptdaemon-data ark banshee banshee-extension-soundmenu base-files bind9-host cron cups cups-bsd cups-client cups-common cups-driver-gutenprint cups-ppdc dconf-gsettings-backend
/Downloads$ sudo apt-get update; lsb_release -a
Ign http://mirror.lstn.net precise InRelease
Ign http://mirror.lstn.net precise-security InRelease
Ign http://mirror.lstn.net precise-updates InRelease
Ign http://mirror.lstn.net precise-proposed InRelease
Ign http://mirror.lstn.net precise-backports InRelease
Hit http://mirror.lstn.net precise Release.gpg
Hit http://mirror.lstn.net precise-security Release.gpg
Hit http:
@joequery
joequery / gist:3398622
Created August 19, 2012 23:40
New Ubuntu Machine
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install chromium-browser
sudo apt-get install git
sudo apt-get install vim
sudo apt-get install screen
ssh-keygen -t rsa
mkdir ~/web
mkdir ~/web/github
mkdir ~/web/lab