Skip to content

Instantly share code, notes, and snippets.

@sergio-fry
sergio-fry / gist:9930963
Created April 2, 2014 09:35
Conver raster to vector
convert in.png -filter Jinc -resize 400% -threshold 30% \( +clone -negate -morphology Distance Euclidean -level 50%,-50% \) -morphology Distance Euclidean -compose Plus -composite -level 45%,55% -resize 25% out.png

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

def expand_url(url)
if url.first == '/'
url = request.protocol + request.host + (request.port=='80' ? '' : ":#{request.port}") + url
end
url
end
*.swo
*.swp
db/*.sqlite3
log/*.log
mkmf.log
nbproject
public/system/datas/*
tmp/*
#!/usr/bin/ruby
def git_branch
(%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* ([a-z0-9_]+)[[:space:]]+$/i, '\1')
end
def set_color color
"\033[#{color}m"
end
def print_result result
module Paperclip
class Attachment
def geometry(style = :original)
@geometry ||= {}
@geometry[style] ||= Paperclip::Geometry.from_file(path(style))
end
end
end
;(function($){
jQuery.fn.serializeJSON = function(){
var aData = $(this).serializeArray();
var result = {}
for(key in aData){
result[aData[key].name] = aData[key].value;
}
return result;
}
@sergio-fry
sergio-fry / jquery.extra.js
Created June 17, 2010 13:40
jquery.extra.js
;(function($){
jQuery.fn.serializeJSON = function(){
var aData = $(this).serializeArray();
var result = {}
for(key in aData){
result[aData[key].name] = aData[key].value;
}
return result;
}
#!/bin/sh
rsync -a --no-perms --no-owner --no-group -vz --exclude=".git" --exclude="*.swp" --exclude=".gitignore" --exclude="deploy.sh" ./ user@host:/path/to/htdocs/
@sergio-fry
sergio-fry / application_controller.rb
Created July 1, 2010 14:00
inherit_resources with cancan
class ApplicationController < ActionController::Base
# Add this to your application_controller
def self.authorized_inherited_resources
inherit_resources
before_filter :authorize_resource_with_cancan
define_method(:authorize_resource_with_cancan) do
case action_name.to_sym
when :new, :create