NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
"""Make video, demonstrating slit-scan photography. | |
Sample is here: https://youtu.be/vz8gplAhDak | |
Both source and result videos are stored as sequences of PNG frames. | |
Source video must be in the current directory, frame names must have format 00001.png, 00002.png, ... etc. | |
Result video is stored in the 'output' folder, frame names having the same format. | |
Requirements: Python 2, PIL | |
Usage: run this script in the folder with soruce frames. |
# convert.rb | |
def titleize(str) | |
str.gsub(/::/, '/') | |
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') | |
.gsub(/([a-z\d])([A-Z])/, '\1_\2') | |
.tr('-', '_') | |
.downcase | |
.gsub(/_id$/, '') | |
.gsub(/_/, ' ').capitalize |
NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
curl -i https://api.github.com/repos/scrooloose/nerdtree/forks |grep -e "git_url" |awk '{gsub(/,/,"");split($2,a,"/"); system("mkdir "a[4]"; cd "a[4]"; git clone " $2);}' |
Install ImageMagick for image conversion:
brew install imagemagick
Install tesseract for OCR:
brew install tesseract --all-languages
Or install without --all-languages
and install them manually as needed.
class ImageUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
storage :file | |
def thumb(size) | |
begun_at = Time.now | |
size.gsub!(/#/, '!') | |
uploader = Class.new(self.class) | |
uploader.versions.clear | |
uploader.version_names = [size] |
#!/usr/bin/env ruby | |
# A simply utility to show character counts for each line of input and | |
# highlight lines longer than 80 characters. | |
# | |
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html | |
# | |
# Examples: | |
# | |
# $ hilong Gemfile |
namespace :app_tasks do | |
desc "create initial paper_trail version for existing records" | |
task(:create_paper_trail_versions => :environment) do | |
#MONKEY PATCH | |
module PaperTrail | |
module Model | |
module InstanceMethods | |
def create_initial_pt_version | |
record_create if versions.blank? |
# | |
# Call git checkout | |
# | |
gco() | |
{ | |
git checkout $* | |
if [[ -s .rvmrc ]] ; then | |
unset rvm_rvmrc_cwd | |
cd . | |
fi |
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
ARGV.reject! { |path| !File.file?(path) } | |
(puts DATA.read.gsub("$0", File.basename($0)); exit 1) if ARGV.empty? | |
ARGV.each do |path| | |
ls = IO.readlines(path) | |
ix = ls[0] !~ /^#!/ ? 0 : 1 | |
next if ls[ix] =~ /#.*?coding\s*[:=]\s*\S/ |