Skip to content

Instantly share code, notes, and snippets.

@bonyiii
bonyiii / gist:4039677
Created November 8, 2012 15:56
git settings
Display what branch i'm on:
~/.bash_profile or .bashrc
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '
~/.gitconfig
[alias]
ci = commit
br = branch
@bonyiii
bonyiii / gist:3666732
Created September 7, 2012 14:38
javscript find duplicates
sorted = window.items.sort((a,b) -> a.track_id - b.track_id)
results = []
for item,i in sorted
if i < sorted.length - 1 && sorted[ i + 1 ].element_id == sorted[i].element_id
results.push sorted[i]
results
@bonyiii
bonyiii / gist:3217229
Created July 31, 2012 13:57
find without .svn dirs
# http://stackoverflow.com/questions/2314643/how-can-i-get-find-to-ignore-svn-directories
find . -path '*/.svn' -prune -o -type f -print0 | xargs -0 grep 'subscribe'
find . | grep -v \.svn
# or maybe
ack
@bonyiii
bonyiii / gist:3182588
Created July 26, 2012 15:04
naming / label a usb_stick partition
or any partition
https://help.ubuntu.com/community/RenameUSBDrive
@bonyiii
bonyiii / gist:3136142
Created July 18, 2012 13:13
checking if a process is running
#https://github.com/javan/whenever/
##### Check if a process is running or not
#!/bin/bash
#http://stackoverflow.com/questions/9336596/rvm-installation-not-working-rvm-is-not-a-function
source ~/.rvm/scripts/rvm
# http://cazatech.wordpress.com/2007/07/07/shell-script-restart-process-if-not-found-running/
http://linuxcommand.org/wss0150.php
http://www.freeos.com/guides/lsst/
http://linuxcommand.org/man_pages/bash1.html
@bonyiii
bonyiii / gist:3128473
Created July 17, 2012 09:55
javascript deminifier and other useful extensions for firebug
http://getfirebug.com/wiki/index.php/Firebug_Extensions#Firepicker
http://jsbeautifier.org/?without-codemirror
@bonyiii
bonyiii / gist:3128362
Created July 17, 2012 09:41
signal handling in linux
http://www.alexonlinux.com/signal-handling-in-linux
@bonyiii
bonyiii / gist:3089831
Created July 11, 2012 11:42
publicize private methods block
# http://stackoverflow.com/questions/267237/whats-the-best-way-to-unit-test-protected-private-methods-in-ruby
class Class
def publicize_methods
saved_private_instance_methods = self.private_instance_methods
self.class_eval { public *saved_private_instance_methods }
begin
yield
ensure
self.class_eval { private *saved_private_instance_methods }
end
@bonyiii
bonyiii / gist:3045895
Created July 4, 2012 07:25
mysql fregmentation remover
#http://blog.softlayer.com/2011/mysql-slow-check-for-fragmentation/
#!/bin/bash
MYSQL_LOGIN='-u root --password=password'
for db in $(echo "SHOW DATABASES;" | mysql | grep -v -e "Database" -e "information_schema" -e "mysql" -e "performance_schema" -e "^test")
#for db in $(echo "SHOW DATABASES;" | mysql $MYSQL_LOGIN | grep -v -e "Database" -e "information_schema")
do
TABLES=$(echo "USE $db; SHOW TABLES;" | mysql $MYSQL_LOGIN | grep -v Tables_in_)