Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / slitscan_demo_video.py
Created January 17, 2016 16:08
Make video, demonstrating slit-scan photography
"""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.
@monkstone
monkstone / convert.rb
Last active May 12, 2017 10:27
Script to convert bare ruby-processing sketches from processing-2.0 to processing-3.0
# 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
@maxim
maxim / rails_load_path_tips.md
Last active January 9, 2025 00:59
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@hhutch
hhutch / fetch-repos.sh
Created September 10, 2012 04:01
find file changes in all forks of a github repo
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);}'
@henrik
henrik / ocr.markdown
Created March 3, 2012 17:07
OCR on OS X with tesseract

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.

@DAddYE
DAddYE / image_uploader.rb
Created December 30, 2011 22:57
CarrierWave on the fly resizer (work as dragonfly)
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]
@jstorimer
jstorimer / hilong.rb
Last active February 18, 2025 18:20
hilong -- A simply utility to show character counts for each line of input and highlight lines longer than 80 characters.
#!/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
@cowboycoded
cowboycoded / create_paper_trail_versions.rb
Created April 19, 2011 18:54
This rake task/monkeypatch creates the inital paper_trail version for existing records.
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?
@wayneeseguin
wayneeseguin / gist:849058
Created March 1, 2011 12:29
Git checkout function that triggers project .rvmrc to be reloaded
#
# Call git checkout
#
gco()
{
git checkout $*
if [[ -s .rvmrc ]] ; then
unset rvm_rvmrc_cwd
cd .
fi
@kch
kch / rb-magic-comment
Created September 27, 2010 20:25
Add the encoding magic comment to the ruby files passed as arguments
#!/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/