This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.hegarc.ig.person.business; | |
public class Person { | |
private Integer number; | |
private String firstName; | |
private String lastName; | |
public Person() { | |
this(null, null, null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.hegarc.ig.person; | |
import ch.hegarc.ig.person.business.Person; | |
public class Main { | |
public static void main(String[] args) { | |
Person p1 = new Person(1, "Bastien", "Gysler"); | |
p1.print(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z $1 ]; then | |
echo "Usage : "$0" http://passenger_address" | |
else | |
echo "address to call: "$1 | |
passenger-status --verbose | grep 'Password:' | cut -d ':' -f2 | while read line; do | |
echo "Calling : "$line # Passenger instance password | |
curl --header "X-Passenger-Connect-Password: "$line $1 > /dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input = "MCMXCIX" # 1999 | |
# Roman to Arabic mapper | |
r2a = {"I" => 1, "V" => 5, "X" => 10, "L" => 50, "C" => 100, "D" => 500, "M" => 1000} | |
# Translate input to an array of arabic numbers | |
numbers = input.split(//).map {|c| r2a[c]} | |
count = numbers.count-1 | |
# Compute result (more infos @ http://en.wikipedia.org/wiki/Roman_numerals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map = { | |
'.-' => 'A', | |
'-...' => 'B', | |
'-.-.' => 'C', | |
'-..' => 'D', | |
'.' => 'E', | |
'..-.' => 'F', | |
'--.' => 'G', | |
'....' => 'H', | |
'..' => 'I', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Tail logs" | |
task :logs => :environment do |t, args| | |
log_files = ['log/searchd.log', 'log/searchd.query.log', 'log/resque.log', 'log/development.log'] | |
system "tail -f -n 2 #{log_files.map {|f| "#{Rails.root}/#{f}"}.join(' ')} | perl -pe 's/^(==>)(.*)(<==)$/\e[1;33;40m$&\e[0m/g'" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/tunnel.yml | |
public_host_username: username_ssh | |
public_host: my_public_domain | |
public_port: 8000 | |
local_host: 0.0.0.0 | |
local_port: 3000 | |
# lib/tasks/tunnel.rake | |
namespace :tunnel do | |
desc "Start a ssh tunnel" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::Base | |
# Retryable transaction | |
# ===================== | |
# | |
# Author : Bastien Gysler (http://www.bastiengysler.com) | |
# | |
# ActiveRecord::Base.retryable_transaction(tries: 1, :when => ActiveRecord::RecordNotUnique) do |on| | |
# on.transaction do | |
# # transaction code here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("img.thumb").error(function() { | |
var path = $(this).data('src'); | |
var img = $(this); | |
// Put back mock image | |
$(img).attr('src', 'http://placehold.it/56x56'); | |
// Increment loading counter | |
var attempt = ($(img).data('attempt') || 0); | |
attempt++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# loop on something .each do |my_model| | |
blob_to_file(my_model.blob_image) do |image_file| | |
my_model.update_attributes(s3_image: image_file) | |
end | |
# end | |
def blob_to_file(blob) | |
tfile = Tempfile.new('blob_to_file') | |
tfile.write(blob.force_encoding("UTF-8")) | |
yield(tfile) if block_given? |
OlderNewer