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
YAML.load(ERB.new(File.new("#{Rails.root}/config/xxxx.yml").read).result)[ENV['RAILS_ENV']] |
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
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 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 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 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 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 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 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
function json_encode_non_buggy($array, $return=false) | |
{ | |
//fixes cases where json_decode will crap out. | |
foreach ($array as $k=>$v) | |
{ | |
$array[$k] = str_replace(array("\t",'"'),array(" ","""), utf8_encode($v)); | |
} | |
if($return) | |
{ |
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
;copy the top header columns. save as C:\import.csv and it will build the needed SQL to import | |
While 1 | |
$nMsg = GUIGetMsg() | |
Switch $nMsg | |
Case $cTooltipClick | |
$clipBoardContents = ClipGet() | |
$array1 = StringExplode($clipBoardContents, @TAB, 0) | |
$cols = "" | |
$tableDef = "DROP TABLE IF EXISTS `development`.`import_tmp`; " & @CRLF & @CRLF & "CREATE TABLE `development`.`import_tmp` (" |
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
<?php | |
//It turns out, that it takes more memory and same amount of time to have all your includes in one file. I thought that all the file I/O would be less with one huge compiled include file. This class will combine all your includes into one file. | |
//it could be useful to try to see all your includes top down. But over all is not meant for production | |
//Ended up using spl_autoload_register which took all my production includes from 40MB to 10MB and increased speed by 1 to 3 seconds | |
/* | |
implementation |