Skip to content

Instantly share code, notes, and snippets.

class MyException < StandardError
def initialize(args, action_to_take)
#message d'erreur
puts 'hehe'
#on redirige ou render ou autres..
action_to_take.call
end
end
def foo
@matan23
matan23 / gist:7049690
Created October 18, 2013 23:23
rename file with extension
for f in *.flv; do target=`basename "$f" .flv`; echo $target; mv "$f" "$target.mp3";done;

The Worker Pattern

Contents

  • Introduction
  • Definition
  • Examples
  • Links

Introduction

The Worker Pattern

Contents

  • Introduction
  • Definition
  • Examples
  • Links

Introduction

@matan23
matan23 / gist:8956626
Last active August 29, 2015 13:56
Sinatra Exception Handling
class App < Sinatra::Base
configure :development do
set :raise_errors, true
#when set to true display a nice exception page for dev but prevent exception handler from working
set :show_exceptions, false
end
get '/someroute' do
MyModel.might_generate_an_exception
@matan23
matan23 / psql survival guide
Created February 26, 2014 22:39
psql survival guide
\d list dbs
\c 'mydatabase'
\d -> list tables
\d 'table'
# put this into your config/eydeploy.rb
def bundle
if File.exist?("#{c.release_path}/Gemfile")
info "~> Gemfile detected, bundling gems"
lockfile = File.join(c.release_path, "Gemfile.lock")
bundler_installer = if File.exist?(lockfile)
get_bundler_installer(lockfile)
else
warn_about_missing_lockfile
@matan23
matan23 / gist:9486482dc4f505a1c360
Created April 17, 2015 14:31
Unix - find and open xcode workspace
open `find . -name '*.xcodeproj' -prune -o -name '*.xcworkspace' -print`
@matan23
matan23 / gist:6f78dad59f628437eddf
Created May 28, 2015 21:13
ios custom icon tintColor
UIImage *originalImage = [UIImage imageNamed:@"myiconname"];
UIImage *tintedImage = [originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imageView = [[UIImageView alloc] initWithImage:tintedImage];
imageView.tintColor = [UIColor redColor];
imageView.frame = CGRectMake(?, ?, ?, ?);
[self.view addSubview:imageView];