Skip to content

Instantly share code, notes, and snippets.

View vesan's full-sized avatar

Vesa Vänskä vesan

View GitHub Profile
@vesan
vesan / factory_doctor.rb
Created August 6, 2017 09:53 — forked from palkan/factory_doctor.rb
FactoryDoc: detect useless data generation in tests
module FactoryGirl
module Doctor
module FloatDuration
refine Float do
def duration
t = self
format("%02d:%02d.%03d", t / 60, t % 60, t.modulo(1) * 1000)
end
end
end
@vesan
vesan / Rails Console Actionmailer test.rb
Last active August 22, 2016 08:49 — forked from tansengming/Rails Console Actionmailer test.rb
Rails Console Actionmailer test
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "vesa@kiskolabs.com"
@from = "must_be_same_as_smpt_account_login@gmail.com"
@subject = "Test from the Rails Console"
@body = "This is a test email"
end
end
@vesan
vesan / routes.rake
Created August 22, 2016 07:25 — forked from masterkain/routes.rake
Journey + Graphviz
namespace :routes do
desc "Writes doc/routes.html. Requires Graphviz (dot)"
task :visualizer => :environment do
File.open(Rails.root.join('doc', 'routes.html'), 'wb') do |f|
f.write Rails.application.routes.router.visualizer
end
end
end
@vesan
vesan / amzn_wish_list_transfer.rb
Last active November 18, 2015 21:46 — forked from polarblau/amzn_wish_list_transfer.rb
Transferring Amazon wish list entries the hard way between international stores.
#!/usr/bin/env ruby
require "rubygems"
require "mechanize"
TARGET_LOGIN_URL = "https://www.amazon.com/ap/signin?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fcss%2Fhomepage.html%3Fie%3DUTF8%26*Version*%3D1%26*entries*%3D0%26ref_%3Dnav_signin"
SOURCE_LOGIN_URL = "https://www.amazon.co.uk/ap/signin?_encoding=UTF8&openid.assoc_handle=gbflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions
require "faraday"
require "faraday_middleware"
require "pp"
connection = Faraday.new 'http://api.hel.fi/linkedevents/v0.1/' do |conn|
conn.response :json, :content_type => /\bjson$/
conn.adapter Faraday.default_adapter
end

A lot of these are outright stolen from Edward O'Campo-Gooding's list of questions. I really like his list.

I'm having some trouble paring this down to a manageable list of questions -- I realistically want to know all of these things before starting to work at a company, but it's a lot to ask all at once. My current game plan is to pick 6 before an interview and ask those.

I'd love comments and suggestions about any of these.

I've found questions like "do you have smart people? Can I learn a lot at your company?" to be basically totally useless -- everybody will say "yeah, definitely!" and it's hard to learn anything from them. So I'm trying to make all of these questions pretty concrete -- if a team doesn't have an issue tracker, they don't have an issue tracker.

I'm also mostly not asking about principles, but the way things are -- not "do you think code review is important?", but "Does all code get reviewed?".

@vesan
vesan / redis_helper.rb
Last active August 29, 2015 14:19 — forked from wxmn/redis_helper.rb
module RedisHelper
# decode Redis value back to Ruby object
def self.decode(json)
self.new(ActiveSupport::JSON.decode(json)["#{self.name.downcase}"])
end
# encode Ruby object for Redis
def encoded
self.updated_at = nil
self.to_json
@vesan
vesan / paypal_bogus_gateway.rb
Created November 23, 2014 21:46
ActiveMerchant testing gateway for Paypal Express
# from: https://github.com/sideshowcoder/active_merchant/blob/192f49762172dc41450d7a3605158d45eb55b83b/lib/active_merchant/billing/gateways/paypal_bogus.rb
require File.dirname(__FILE__) + '/paypal/paypal_common_api'
require File.dirname(__FILE__) + '/paypal/paypal_express_response'
require File.dirname(__FILE__) + '/paypal_express_common'
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PaypalBogusGateway < BogusGateway

Keybase proof

I hereby claim:

  • I am vesan on github.
  • I am vesan (https://keybase.io/vesan) on keybase.
  • I have a public key whose fingerprint is 170B 9C28 719A DB97 3711 EA7B E681 FE54 DF8F C3E3

To claim this, I am signing this object:

@vesan
vesan / action_mailer_localization_helpers.rb
Created August 22, 2013 11:38
Sending emails with different locale than the current user has.
module ActionMailerLocalizationHelpers
def using_locale(locale, &block)
original_locale = I18n.locale
I18n.locale = locale
return_value = yield
I18n.locale = original_locale
return_value
end
end