Skip to content

Instantly share code, notes, and snippets.

View dladowitz's full-sized avatar

David Ladowitz dladowitz

View GitHub Profile
@dladowitz
dladowitz / payday.rb
Created March 17, 2014 08:00
Given a date, this class is used to find the next payday being the 1st or the 15th. If the payday falls on a weekend or holiday the payday is adjusted to the business day. Note that you'll need to install the gems 'holidays' and 'active_support'. Not sure if this last on if available outside of rails
require 'date'
require 'active_support/core_ext/integer/inflections' # Used for printing date as human text
require 'holidays' # Gives access to holiays
class Payday
def initialize(query_date)
@query_date = query_date
@next_payday = 'unknown'
end
@dladowitz
dladowitz / gist:9595604
Created March 17, 2014 08:11
First Pass at Payday class
require 'date'
require 'active_support/core_ext/integer/inflections'
class Payday
def self.get_next_payday(date)
payday = Payday.get_next_standard_payday(date)
payday = Payday.weekend_adjustment(payday)
"Payday will be " + payday.strftime("%a %b #{payday.day.ordinalize}")
require 'json'
require 'rest-client'
#get a big block of json
github_json = RestClient.get('https://api.github.com/users/rails/repos')
#format the json for ruby to read
ghub_json = JSON.load(github_json)
#loop over all the repos in the formatted json
class Person
attr_accessor :name, :age
def initialize
puts "name: #{name}"
puts "@name: #{@name}"
name = "David"
@name = "Tom"
require 'json'
uri = URI.parse("https://api.admoda.com/v1/advertiser/stats/campaigns.csv?date=2015-03-11")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # read into this
headers = {'Authorization' => 'Token a3446590e8920e90e857f20c3d24479c'}
response = http.get(uri.request_uri, headers)
p "----Response----"
require 'docopt'
class Todo
def initialize
puts "Generating 'To Do' list"
@file = File.open("todo_list.txt", 'w+')
puts "'To Do' list generated"
end
@dladowitz
dladowitz / todo.rb
Created June 24, 2012 07:46
ToDo App
require 'docopt'
#-------------------------------------------------------
class List
# attr_accessor :all_tasks
def initialize
@all_tasks = []
@dladowitz
dladowitz / todo_spec.rb
Created June 28, 2012 00:15
Rspec for Jesse's ToDo app
# require 'spec_helper'
require 'simplecov'
SimpleCov.start
require './list'
require './todo'
require './task'
describe Todo::List do
@dladowitz
dladowitz / InWords.html
Created June 28, 2012 06:16
Numbers to words (up to 99) in Javascript
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
</head>
<body>
@dladowitz
dladowitz / InWords
Created June 28, 2012 06:17
Numbers to Words (up to 999) in ruby
module InWords
def in_words
ones = {
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",