Skip to content

Instantly share code, notes, and snippets.

@rgo
rgo / gist:1333701
Created November 2, 2011 14:01
Generate timelapse video from jpg images
# Generate timelapse video from jpg images
mencoder -ovc copy -mf w=320:h=240:fps=6:type=jpg 'mf://*.jpg' -o time_lapse-test.avi
@rgo
rgo / gist:1324325
Created October 29, 2011 10:36
Convert files to utf-8 with vim
## From http://stackoverflow.com/questions/2311750/change-file-encoding-to-utf-8-via-vim-in-a-script
#This is the simplest way I know of to do this easily from the command line:
vim +"argdo se bomb | se fileencoding=utf-8 | w" $(find . -type f -name *.rb)
#Or better yet if the number of files is expected to be pretty large:
find . -type f -name *.rb | xargs vim +"argdo se bomb | se fileencoding=utf-8 | w"
@rgo
rgo / change_idle_time_dims_screen.txt
Created October 26, 2011 21:39
Change idle time for dimming screen when run out of AC
1. Install dconf-tools package
2. Run dconf-editor
3. Browse to org.gnome.settings-daemon.plugins.power
4. Change idle-dim-time to your liked value in seconds.
You can run it in a termina:
$ gsettings set org.gnome.settings-daemon.plugins.power idle-dim-time <your_value>
@rgo
rgo / flush_all_memcached.sh
Created October 25, 2011 10:29
Flush all memcached data
#!/bin/sh
echo $'flush_all\r\nquit\r\n' | nc localhost 11211
@rgo
rgo / block_unblock_package_updates.sh
Created September 21, 2011 10:54
Block/unblock package upgrades
# Block package version (don't upgrade it anymore)
echo "package-name hold" | sudo dpkg --set-selections
# Unblock package version (upgrade it again)
echo "package-name install" | sudo dpkg --set-selections
@rgo
rgo / gist:1173243
Created August 26, 2011 11:36 — forked from diecrf/gist:1170410
Delete unused images in a rails project
images = Dir.glob('public/images/*')
images.each do |image|
unless File.directory?(image)
puts "Checking #{image}..."
if IO.popen("ack-grep -1 -G '(app|public)' --ruby --html --css #{File.basename(image)}").eof?
IO.popen("svn delete #{image}")
puts " Deleted"
end
end
@rgo
rgo / test.sh
Created July 6, 2011 14:51
Execute (remote) a ruby script
#!/usr/bin/env ruby
ruby -e "require 'open-uri'; system open('http:// or local file').read"
@rgo
rgo / block_constructor.rb
Created July 1, 2011 14:22
Using &block as constructor
# &block constructors
# From http://www.deploymentzone.com/2011/06/23/block-constructors
# If you need a behavior like this in your class:
Person.new do |p|
p.first_name = "John"
p.last_name = "Brown"
p.dob = Date.parse("5/9/1800")
end
@rgo
rgo / Gemfile
Created April 1, 2011 08:30
Add a gem in Gemfile without disturb your workmates
group :development do
gem 'foo' if Gem.available?('foo')
end
/path/to/rails_apps/*/log/*.log {
daily
missingok
rotate 30
compress
delaycompress
sharedscripts
postrotate
find /path/to/rails_apps/* -name tmp -maxdepth 1 -type d -exec touch {}/restart.txt \;
endscript