Skip to content

Instantly share code, notes, and snippets.

@ebeigarts
ebeigarts / bash_debug.md
Created December 19, 2012 22:20
Bash debugging
PS4='+ $(date "+%s.%N") $BASH_SOURCE:$LINENO#$FUNCNAME \011 '
set -x

Example Output:

++ 1355955482.N ./.bashrc:11    source ./.rvm/scripts/rvm
+++ 1355955482.N ./.rvm/scripts/rvm:21 __rvm_has_opt posix
@ebeigarts
ebeigarts / gsed.md
Created December 4, 2012 14:24
GNU Sed
brew install gnu-sed

Replace \t with 2 spaces

find app/{controllers,models,views} db/ lib/ -type f -exec gsed -b -i 's/\t/  /g' {} \;
@ebeigarts
ebeigarts / diff_file_permissions.md
Created November 30, 2012 18:54
Diff file permissions
$ cd a; find . -exec stat -c "%U:%G %a %n" {} \; > ../a-stats.txt; cd ..
$ cd b; find . -exec stat -c "%U:%G %a %n" {} \; > ../b-stats.txt; cd ..
$ diff -ur ./a-stats.txt ./b-stats.txt

Output:

--- ./a-stats.txt	2012-11-30 20:45:43.000000000 +0200
@ebeigarts
ebeigarts / iptables.md
Created August 7, 2012 20:51
iptables

iptables

Port forwarding

sysctl net.ipv4.ip_forward=1

10.57.68.122:6022 => 10.200.5.60:22 (SNAT)

@ebeigarts
ebeigarts / gist:3159994
Last active February 15, 2023 07:05
Icons

729 icons, free, webfont, grayscale

200 icons, free

400 icons, $25

#!/usr/bin/env ruby
#
# Backup
#
# For more information:
#
# View the Git repository at https://github.com/meskyanichi/backup
# View the Wiki/Documentation at https://github.com/meskyanichi/backup/wiki
# View the issue log at https://github.com/meskyanichi/backup/issues
#
@ebeigarts
ebeigarts / nginx.conf
Created April 24, 2012 07:05
Mobile detection - iOS, other mobile platforms and desktop
daemon off;
error_log log/error.log crit;
events {
}
http {
uwsgi_temp_path tmp/;
scgi_temp_path tmp/;
proxy_temp_path tmp/;
@ebeigarts
ebeigarts / gist:2349762
Created April 10, 2012 09:28
I18n logger (one liner)
I18n.instance_eval { alias :_t :t; def t(*args); Rails.logger.debug("I18n: #{args.inspect}"); _t(*args) end; alias :translate :t }
@ebeigarts
ebeigarts / gist:2224295
Created March 28, 2012 06:37
dragonfly.rb
# config/initializers/dragonfly.rb
module Dragonfly
# Supports ImageMagick 6.2.8
module ImageMagick
class Processor
alias_method :_crop, :crop
def crop(temp_object, opts={})
# 6.2.8 doesn't support ^^
@ebeigarts
ebeigarts / exif.md
Last active September 30, 2015 16:27
EXIF

Set file modification time from EXIF time

exiftool '−DateTimeOriginal>FileModifyDate' ./*

Update EXIF dates by -2 hours

exiftool −alldates-=2 ./*