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
| def multi_replace(string, *rules) | |
| scanning_pattern = Regexp.union(rules.map{|e| e.first} | [/./]) | |
| string.scan(scanning_pattern).map do |match| | |
| rules.select{|e| match =~ e.first}.flatten.last || match | |
| end.join | |
| end | |
| multi_replace("the first problem is not egal to second problem", [/first problem/, "older problem"], [/second problem/, "first problem"]) |
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
| # >----------------------------[ Initial Setup ]------------------------------< | |
| # generator initializer | |
| initializer 'generators.rb', <<-RUBY | |
| Rails.application.config.generators do |g| | |
| end | |
| RUBY | |
| # say methods | |
| def say_step(name); say "\033[36m" + 'step'.rjust(10) + "\033[0m" + " Running #{name} step..." 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
| #!/bin/bash | |
| # | |
| # Set our bash prompt according to the branch/status of the current git | |
| # repository. | |
| # | |
| # Forked from http://gist.github.com/31967 | |
| RED="\[\033[0;31m\]" | |
| YELLOW="\[\033[0;33m\]" | |
| GREEN="\[\033[0;32m\]" |
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
| cloud-start -s config/clouds.rb | |
| Starting cloud app (/home/yann/.ec2/testpoolparty) | |
| 0 running instances (1 - 1) | |
| /usr/lib/ruby/gems/1.8/gems/grempe-amazon-ec2-0.3.8/lib/EC2.rb:261:in `ec2_error?': The key pair 'testpoolparty' does not exist (EC2::InvalidKeyPairNotFound) | |
| from /usr/lib/ruby/gems/1.8/gems/grempe-amazon-ec2-0.3.8/lib/EC2.rb:199:in `make_request' | |
| from /usr/lib/ruby/1.8/net/http.rb:543:in `start' | |
| from /usr/lib/ruby/gems/1.8/gems/grempe-amazon-ec2-0.3.8/lib/EC2.rb:173:in `make_request' | |
| from /usr/lib/ruby/gems/1.8/gems/grempe-amazon-ec2-0.3.8/lib/EC2.rb:224:in `response_generator' | |
| from /usr/lib/rub |
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
| require 'rake/packagetask' | |
| Rake::PackageTask.new("myapp", "1.2.3") do |p| | |
| p.need_tar_bz2 = true | |
| p.package_files.include("README") | |
| p.package_files.include("lib/**/*.rb") | |
| 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
| Host srv1 | |
| Hostname srv1.client.fr | |
| User root | |
| ProxyCommand ssh firewall nc %h %p | |
| Host srv2 | |
| Hostname srv2.client.fr | |
| User root | |
| ProxyCommand ssh firewall nc %h %p |
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 LifeGame | |
| attr_reader :matrix | |
| def initialize(string) | |
| @matrix = string_to_matrix(string) | |
| end | |
| def iterate | |
| old_matrix = Marshal.load(Marshal.dump(matrix)) | |
| matrix.each_index do |y| |
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
| Dir[Rails.root.join('**', '*.rb')].each do |f| | |
| c = File.open(f).read | |
| File.open(f, 'w').write("# encoding: UTF-8\n" + c) | |
| 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
| var DateHelper = { | |
| // Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time | |
| // Ruby strftime: %b %d, %Y %H:%M:%S GMT | |
| time_ago_in_words_with_parsing: function(from) { | |
| var date = new Date; | |
| date.setTime(Date.parse(from)); | |
| return this.time_ago_in_words(date); | |
| }, | |
| time_ago_in_words: function(from) { |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>io.yalty.update-dnsimple</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>sh</string> | |
| <string>/.../update-dnsimple.sh</string> |
OlderNewer