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
total= (1..999).reduce(0) do |sum,n| | |
n%3 == 0 || n%5 == 0 ? sum + n : sum | |
end | |
puts total |
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://pragdave.pragprog.com/pragdave/2005/11/symbolto_proc.html | |
#http://ruby-doc.org/core-2.0.0/Symbol.html#method-i-to_proc | |
2.0.0p247 :001 > a = ["first", "second", "third"] | |
=> ["first", "second", "third"] | |
2.0.0p247 :002 > a.collect(&:upcase) | |
=> ["FIRST", "SECOND", "THIRD"] | |
2.0.0p247 :003 > a.collect{ |n| n.upcase } | |
=> ["FIRST", "SECOND", "THIRD"] | |
2.0.0p247 :004 > |
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 self.parse_detail( rows ) | |
details = rows.map do |row| | |
detail = {} | |
[ | |
[:line_item, 0], | |
[:title, 1], | |
[:asin, 2], | |
[:units_sold, 3], | |
[:units_refunded, 4], | |
[:net_units_sold, 5], |
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
a = %q{ Hello World! | |
A lovely day in Santa Clara on April 21st | |
} | |
b = %Q{ #{a} | |
And the sun is shining | |
} | |
puts a | |
puts b |
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://meyerweb.com/eric/tools/css/reset/ | |
v2.0 | 20110126 | |
License: none (public domain) | |
*/ | |
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
font-size: 100%; |
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 | |
# | |
# PostgreSQL Backup Script Ver 1.0 | |
# http://autopgsqlbackup.frozenpc.net | |
# Copyright (c) 2005 Aaron Axelsen <[email protected]> | |
# | |
# This script is based of the AutoMySQLBackup Script Ver 2.2 | |
# It can be found at http://sourceforge.net/projects/automysqlbackup/ | |
# | |
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9 |
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
string = "HOPJYJKCONNECTICUTQZIDAHOKR" | |
states = ["TEXAS", "ALASKA", "IDAHO", "FLORIDA", "MONTANA", "OHIO", "NEWMEXICO", "CONNECTICUT", "COLORADO"] | |
states.select { |s| string[s] } | |
states.select { |s| string.match s } | |
states.select { |s| string.include? s } | |
# => ["IDAHO", "CONNECTICUT"] |
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
irb(main):016:0> a = "aartiparikh" | |
=> "aartiparikh" | |
irb(main):022:0> a.split("").sort.join("") | |
=> "aaahiikprrt" |
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
db = { 7 => ["parikh", "shah"], 5 => ["sinha", "kaur"], 3 => ["sharma", "khan"]} | |
def sort_functional(db) | |
db.keys.sort.reduce({}) { |hash,item| hash.merge( item => db[item].sort ) } | |
end | |
def sort_simple(db) | |
sorted = {} | |
db.keys.sort.each do |n| | |
sorted[n]=db[n].sort |
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
mkdir -p ~/depot | |
git clone --bare ~/dev/aarti/myproject ~/depot/myproject.git | |
cd ~/dev/aarti/myproject | |
git remote add origin ~/dev/aarti/myproject | |
git remote -v | |
git push jenkins master |
OlderNewer