Skip to content

Instantly share code, notes, and snippets.

View sandys's full-sized avatar

Sandeep Srinivasa sandys

View GitHub Profile
@sandys
sandys / clojure-java-interop.md
Created June 19, 2012 08:00
clojure and java interop with repl

#standalone running of clojure and leiningen using only jars and no scripts java -Xbootclasspath/a:../clojure-1.4.0/clojure-1.4.0.jar -cp ../leiningen-2.0.0-preview6-standalone.jar clojure.main -m leiningen.core.main help

@sandys
sandys / IE8_on_ubuntu.md
Created June 20, 2012 06:40
Installing IE8 on Ubuntu 12.04 64-bit (and avoiding the 32/64 bit architecture error)
@sandys
sandys / shell.sh
Created June 28, 2012 11:34
shell utilities
# ls with dates formatted as timestamps
ls -ahltr --time-style=+%Y%m%d%H%M
@sandys
sandys / mp3_combine.sh
Created July 26, 2012 17:50
Combining many mp3s into a single file
sudo apt-get install libavcodec-extra-53
#This method re-encodes the audio. This method is slow, and lossy (mostly noticeable when using low bitrates), but the resulting mp3 file is properly playable in most media players. There are ways to merge mp3s without re-encoding, but the duration of the files can often not be properly detected by most players.
cvlc aa.mp3 bb.mp3 cc.mp3 --sout "#transcode{acodec=mp3,ab=<bitrate>,channels=2}:std{access=file,mux=raw,dst=1.mp3}" --sout-keep
#much faster
sudo apt-get install vbrfix libid3-tools libav-tools
cat 1.mp3 2.mp3 3.mp3 > tmp.mp3
#OR
ffmpeg -i concat:file1.mp3\|file2.mp3 -acodec copy tmp.mp3
@sandys
sandys / schema.json
Created July 27, 2012 05:05
Elasticsearch schema properties
Products
* id : integer
* name : string
* date : date
* price : float
* items_available : integer
I created the index "testindex" using the mapping API, here is what I
find in the logs :
@sandys
sandys / git_gotchas_office.md
Last active October 8, 2015 05:08
Git gotchas for use in an office

For use with git version atleast 1.7.6

  • list your local branches git branch -avv

  • clone using ssh git clone ssh://sss@10.70.15.118/home/user/work/test1

  • very frequently, a common mistake that is made is that you clone from each other and then you might push to the wrong repository. To make sure you are pushing to the right repository,

  • then do git branch -a --contains 8a8abc4978c991d09a321ce692ac3366ea097051

@sandys
sandys / gist:3351411
Created August 14, 2012 18:15 — forked from l0b0/gist:3217470
Simple merge example
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
cd "$(mktemp --directory)"
git init
cat > test.txt <<EOF
alfa
bravo
charlie
@sandys
sandys / java_debugging.md
Created August 17, 2012 09:19
Java debugging howtos

locate /usr/java/tomcat/temp/hsperfdata_tomcat/

to get processid of tomcat jps -J-Djava.io.tmpdir=/usr/java/tomcat/temp

/usr/java/jdk1.6.0_24/bin/jmap -J-Djava.io.tmpdir=/usr/local/tomcat-instance/traduscms/temp -heap 23420

sudo -u root /usr/java/jdk1.6.0_24/bin/jstack -J-Djava.io.tmpdir=/usr/local/tomcat-instance/tradusgv/temp -J-d64 10960

@sandys
sandys / etc_sites_enabled_default.nginx
Created September 4, 2012 06:40
Bulletproof Wordpress installation
proxy_cache_path /var/lib/nginx/cache/staticfiles levels=1:2 keys_zone=staticfilecache:60m inactive=90m max_size=50m;
proxy_temp_path /var/lib/nginx/proxy;
proxy_connect_timeout 30;
proxy_read_timeout 120;
proxy_send_timeout 120;
map $http_cookie $logged_in {
default 0;
~wordpress_logged_in 1; # Wordpress session cookie
@sandys
sandys / fp_ruby_rc4.rb
Created September 20, 2012 10:56
an example of Format Preserving Encryption in Ruby using RC4 and pack. The important thing is to keep key length to be a power of 2
require 'openssl'
c = OpenSSL::Cipher::Cipher.new("rc4-40")
serial = 4000987
puts " *********** SERIAL NUMBER = #{serial}"
c.encrypt
c.key = "fdkjgfdoi4tu45fkgkljfg9485439tkjfgnjdshfghwhe54350gfgklkgje34324nkjdfhk45845843543k5kdjfk3454958439kkfkglgkttpoeoidsad49584305ldkfsdjf42jkndfl"
padded_serial = "%015d" % serial
padded_serial_array = [padded_serial.slice(0,10).to_i, padded_serial.slice(10,15).to_i]