Skip to content

Instantly share code, notes, and snippets.

View tochman's full-sized avatar
💭
Coding on my own SaaS project (Rails + React)

Thomas Ochman tochman

💭
Coding on my own SaaS project (Rails + React)
View GitHub Profile
@tochman
tochman / fixed_footer.js
Last active July 1, 2016 11:54
Fixed footer code
@tochman
tochman / map.html
Last active December 5, 2015 11:33
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.openstreetmap.org/export/embed.html?bbox=11.96583867073059%2C57.68774908130971%2C11.977425813674927%2C57.692273648867435&amp;layer=hot" style="border: 1px solid black"></iframe><br/><small><a href="http://www.openstreetmap.org/#map=17/57.69001/11.97163&amp;layers=H">Visa större karta</a></small>
require 'csv'
require 'io/console'
def parse_csv(file)
@emails = []
CSV.foreach(file, headers: true, header_converters: :symbol, converters: :all) do |row|
@emails << row[:email]
end
end
@tochman
tochman / you_tube.rb
Created June 16, 2015 08:08
YouTube v3 API call to get videos
require 'google/api_client'
class YouTube
DEVELOPER_KEY = ENV['YOUTUBE_KEY'] || 'YOU API KEY'
YOUTUBE_API_SERVICE_NAME = 'youtube'
YOUTUBE_API_VERSION = 'v3'
def initialize(query, count)
@query = query
@count = count.to_i
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@tochman
tochman / total_time.rb
Created March 31, 2015 07:22
Humanize minutes
#
def total_time(minutes)
seconds_diff = minutes*60
days = seconds_diff / 86400
seconds_diff -= days * 86400
hours = seconds_diff / 3600
seconds_diff -= hours * 3600
@tochman
tochman / export.rb
Created January 27, 2015 21:00
CSV Export
require 'csv'
class CsvExport
def initialize(collection, attributes=[])
@collection, @attributes = collection, attributes
end
def generate
CSV.generate do |csv|
csv << attributes.map(&:to_s)
require 'spec_helper'
describe EventHelper do
it 'cover_for PairProgramming' do
event = mock_model(Event, category: 'PairProgramming')
result = helper.cover_for(event)
expect(result).to match /event-pairwithme-cover\.png/
end
it 'cover_for Scrum' do
@tochman
tochman / _event_pre_month.rb
Created January 6, 2015 09:21
Event instances
<fieldset class="event_option" id="repeats_monthly_options">
<%= f.number_field :repeats_every_n_months %>
<%= f.select :repeats_monthly, Event::RepeatMonthlyOptions %>
<div class="control-group" id="event_repeats_monthly_each">
<label class="control-label">Each</label>
<div class="controls">
<% Event::DaysOfTheMonth.each do |day_of_the_month| %>
<%= label_tag "event_repeats_monthly_each_days_of_the_month_#{day_of_the_month}", day_of_the_month, :class => 'checkbox inline' do %>
<%= check_box_tag "event[repeats_monthly_each_days_of_the_month][#{day_of_the_month}]", day_of_the_month, f.object.repeats_monthly_each_days_of_the_month.include?(day_of_the_month), {:name => "event[repeats_monthly_each_days_of_the_month][]"} %>
<%= day_of_the_month %>
@tochman
tochman / user.rb
Last active August 29, 2015 14:12
Legacy password handling. Could perhaps be used tin the bikeshare project as part of the qr-code validation??
##Methods for legacy password handling with Devise
def valid_password?(password)
if has_legacy_password?
return false unless valid_legacy_password?(password)
convert_legacy_password!(password)
true
else
super(password)
end
end