Skip to content

Instantly share code, notes, and snippets.

View stabenfeldt's full-sized avatar
🎯
Focusing

Martin Stabenfeldt stabenfeldt

🎯
Focusing
View GitHub Profile
@stabenfeldt
stabenfeldt / geo_data.rb
Last active August 29, 2015 14:01
Geodata reverse lookup Ruby client
class GeoData
require 'json'
require 'net/http'
attr_reader :lat, :lon
def initialize(lat: lat, lon: lon)
@lat = lat
@lon = lon
end
@stabenfeldt
stabenfeldt / test.zsh
Created September 19, 2012 07:09
rvm --trace use 1.9.2-p290
Martins-iMac-4429% rvm --trace use 1.9.2-p290
+__rvm_parse_args:637> [[ -n 4.3.11 ]]
+__rvm_parse_args:672> [[ -z '' && -n '' ]]
+__rvm_parse_args:675> [[ error == || 0 -eq 1 || -n '' ]]
+__rvm_parse_args:16> [[ -n use ]]
+__rvm_parse_args:18> rvm_token=use
+__rvm_parse_args:20> (( 1 > 0 ))
+__rvm_parse_args:22> next_token=1.9.2-p290
+__rvm_parse_args:23> shift
+__rvm_parse_args:28> case use ([[:alnum:]]*|@*)
@stabenfeldt
stabenfeldt / mysql_backup.sh
Created June 3, 2012 17:50
MySQL backup oneliner
mysqldump -u USER -p PASSWORD database | gzip -9 > BACKUP/prod-`date +%Y.%m.%d`c.gz
it "can invite others" do
login(@user, @password)
visit group_path(@group)
within '#group_header' do |scope|
scope.click_link 'Invite'
end
require 'rubygems'
require 'active_support/core_ext/date/calculations.rb'
WORKDAY_STOP = 16
module DateCalculation
def weekend?
self.wday.to_s =~ /[6,0]/
end
class Assignment < ActiveRecord::Base
# $LOUD_N_CLEAR = true
# Counts workdays between two Dates (not Time)
def count_weekdays(startdate,stopdate)
@workdays = 0
startdate.to_date.upto(stopdate.to_date) do |date|
if date.wday.to_s =~ /[0,1,2,3,4]/
@workdays +=1