This file contains hidden or 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
#this is a simple hack that replace the .com by a regexp for all top level domains | |
regexp = 'http:\\/\\/maps\\.google\\.com\\/maps\\?.*|http:\\/\\/maps\\.google\\.com\\/\\?.*|http:\\/\\/maps\\.google\\.com\\/maps\\/ms\\?.*' | |
regexp.gsub!( 'com', '[a-z]{2,}') |
This file contains hidden or 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
(http|https):\\/\\/maps\\.google\\.(co\\.[a-z]{2}|com\\.[a-z]{2}|([a-z]{2,}))\\/maps\\?.*|(http|https):\\/\\/maps\\.google\\.(co\\.[a-z]{2}|com\\.[a-z]{2}|([a-z]{2,}))\\/\\?.*|(http|https):\\/\\/maps\\.google\\.(co\\.[a-z]{2}|com\\.[a-z]{2}|([a-z]{2,}))\\/maps\\/ms\\?.* |
This file contains hidden or 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
/\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/?)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s\`!()\[\]{};:\'\".,<>?]))/i |
This file contains hidden or 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
jepogjep | |
-------- |
This file contains hidden or 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
#!/usr/bin/env ruby | |
## | |
# This script migrates your Heroku app from a Shared DB to a Postgres `dev` Plan | |
# | |
# Usage: | |
# ruby heroku_migration.rb [apps_name(separated by spaces)] | |
# Example: | |
# $ ruby heroku_migration.rb app_1 app_2 app_3 | |
# |
This file contains hidden or 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
# Terminal Progress Indicators. Four examples are included: percentage, | |
# spinner, progress bar, and combined. This script has been tested on | |
# Mac OS X 10.8 with Ruby 1.8.7, 1.9.1, 1.9.2, and 1.9.3 | |
class Spinner | |
include Enumerable | |
def each | |
loop do | |
yield '|' | |
yield '/' |
This file contains hidden or 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
local_var.method_with_hash_and_block( | |
mandatory_param, | |
option_1: a, | |
option_2: blabla, | |
option_3: blablablablablabla, | |
option_4: bblablablablablablablabla, | |
option_5: bblablablabla, | |
) do |v| | |
d = v.bla | |
e = v.bla |
This file contains hidden or 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 ProjectController < ApplicationController | |
def create | |
service_layer.save(project) | |
end | |
private | |
def service_layer | |
@service_layer ||= ServiceLayer.instance | |
end |
This file contains hidden or 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 StoredProcedureService | |
def self.instance | |
@instance ||= StoredProcedureService.new | |
end | |
def execute(name, *args) | |
results = [] | |
begin | |
connection.execute("CALL #{name}(#{args.join(',')})").each(as: :hash, symbolize_keys: true) do |row| |
This file contains hidden or 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
describe '.check_version' do | |
it 'should be ~> 5.5 for mysql' do | |
definition.check_version('~> 5.5').should be_true | |
end | |
it 'should be >= 5.3 for mysql' do | |
definition.check_version('>= 5.3').should be_true | |
end | |
it 'should be <= 5.6 for mysql' do | |
definition.check_version('<= 5.6').should be_true | |
end |
OlderNewer