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
| 0 1 * * sun find /tmp -type f -a -mtime +1 -name "*.sql" -exec rm \{\} \; |
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
| <?php | |
| $file = 'C:\\data.csv'; | |
| $fields = array(); | |
| $sqlOutput = ''; | |
| if($f = fopen($file, 'r')) | |
| { | |
| $fields = fgetcsv($f); | |
| fclose($f); | |
| if (!empty($fields)) |
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
| module Enumerable | |
| # clumps adjacent elements together | |
| # >> [2,2,2,3,3,4,2,2,1].cluster{|x| x} | |
| # => [[2, 2, 2], [3, 3], [4], [2, 2], [1]] | |
| def cluster | |
| cluster = [] | |
| each do |element| | |
| if cluster.last && yield(cluster.last.last) == yield(element) | |
| cluster.last << element | |
| else |
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
| birds = ["Golden Eagle", "Gyrfalcon", "American Robin", | |
| "Mountain BlueBird", "Mountain-Hawk Eagle"] | |
| grouped_by_first_letter = birds.group_by { |s| s[0] } |
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
| if $0 == __FILE__ | |
| ARGV.each{|arg| | |
| case arg | |
| when /\A--ruby=(.+)/ | |
| $ruby_program = $1 | |
| when /\A--matzruby=(.+)/ | |
| $matzruby_program = $1 | |
| when /\A--opts=(.+)/ | |
| $opts = $1 | |
| when /\A(-r|--only-ruby)\z/ |
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
| CAMELCASE=WidgetList | |
| GEMNAME=widget_list | |
| rvm gemset create $GEMNAME | |
| rvm gemset use $GEMNAME | |
| gem install bundler | |
| bundle gem $GEMNAME | |
| #chown wcapp:wcapp -R $GEMNAME/* | |
| mkdir -p vendor/assets/{images,javascripts,stylesheets} |
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
| YAML.load(ERB.new(File.new("#{Rails.root}/config/xxxx.yml").read).result)[ENV['RAILS_ENV']] |
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
| Rails.application.class.parent_name.constantize |
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
| connection = ActiveRecord::Base.connection | |
| class << connection | |
| alias :original_exec :execute | |
| def execute(sql, *name) | |
| # try to log sql command but ignore any errors that occur in this block | |
| # we log before executing, in case the execution raises an error | |
| begin | |
| file = File.open(Rails.root + "/log/database.log",'a'){|f| f.puts Time.now.to_s+": "+sql} | |
| rescue Exception => e | |
| ; |
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
| CREATE TABLE IF NOT EXISTS `database_connections` ( | |
| `id` int(11) NOT NULL AUTO_INCREMENT, | |
| `connection_id` int(11) NOT NULL, | |
| `queries` text NOT NULL, | |
| `page` varchar(300) NOT NULL, | |
| `ip_address` varchar(255) NOT NULL, | |
| `t_stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| PRIMARY KEY (`id`), | |
| UNIQUE KEY `connection_unique` (`connection_id`), | |
| KEY `connection_id` (`connection_id`) |