Skip to content

Instantly share code, notes, and snippets.

View compwron's full-sized avatar
💭
https://github.com/drop-ice/dear-github-2.0

compwron compwron

💭
https://github.com/drop-ice/dear-github-2.0
View GitHub Profile
class OrbitalCoordinate
def initalize(lat, long, altit)
@lat = lat
@long = long
@altit = altit
# @veloc = veloc # meters per second
# how many seconds it will take to get to another point.
OrbitalVelocity..new(sec, OrbitalCoordinate)
end
end
l = [
"John",
"John",
"John",
"John",
"Adam",
"Adam",
"Adam",
"Linda",
@compwron
compwron / xit_finder.rb
Last active August 29, 2015 14:14
find xits in ruby tests
xits = `grep -Rwn "xit |skip" spec | grep " do"`.split("\n")
skips = `grep -Rwn "skip " spec | grep -v ".js" | grep -v ":skip"`.split("\n")
blame_cmds = (xits + skips).map {|x|
pieces = x.split(":")
file = pieces[0]
line_num = pieces[1]
[x, "git blame -L#{line_num},+1 -- #{file}"]
}
@compwron
compwron / unused_date_format_finder.rb
Created February 7, 2015 06:15
find unused date formats
a = "apache
batch_name
datetime_with_seconds
download_csv_datetime
download_csv_timezone
expiration
mmdd
mmyy
hhmmss
iso8601_milliseconds
@compwron
compwron / gist:b1b7380bf61d8d4f2814
Created February 8, 2015 18:10
modify array in place
class Array
def square!
self.map! {|i| i ** 2}
end
end
a = [1, 2, 3]
a.square!
if a == [1, 4, 9]
class OrbitalCoordinate
def initalize(lat, long, altit)
@lat = lat
@long = long
@altit = altit
# @veloc = veloc # meters per second
# how many seconds it will take to get to another point.
OrbitalVelocity..new(sec, OrbitalCoordinate)
end
end
@compwron
compwron / gist:00c94fc3b92bff925d25
Created March 13, 2015 22:09
nested parameters for enumerable block
irb(main):015:0> (0..4).each_with_index.map.inject(0) {|i, (j, k)| puts "i: #{i} j: #{j} k: #{k}" ; i }
i: 0 j: 0 k: 0
i: 0 j: 1 k: 1
i: 0 j: 2 k: 2
i: 0 j: 3 k: 3
i: 0 j: 4 k: 4
=> 0
irb(main):016:0>
@compwron
compwron / gist:32f4595a22bc5a61a426
Created March 15, 2015 17:28
gmail monitor and filesender
/* PayPal Shop with Apps Script */
/* Written by Amit Agarwal - ctrlq.org */
/* http://www.labnol.org/internet/sell-digital-products-online/28554/ */
PAYPAL = [
["product-001", "useful-websites-book.pdf"],
["product-002", "linux-training-course.mp4"],
module Foo
def bar
"stuff"
end
end
World Foo # world-accessible
# pry(main)> method(:World).owner
# => Cucumber::RbSupport::RbDsl
# http://www.rubydoc.info/github/cucumber/cucumber/Cucumber/RbSupport/RbDsl:World
# Only run the following code when this file is the main file being run
# instead of having been required or loaded by another file
if __FILE__==$0
# Find the parent directory of this file and add it to the front
# of the list of locations to look in when using require
$:.unshift File.expand_path("../../", __FILE__)
end
# http://stackoverflow.com/questions/4687680/what-does-if-file-0-mean-in-ruby