Skip to content

Instantly share code, notes, and snippets.

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@agnoster
agnoster / README.md
Last active October 15, 2025 04:02
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@michaelminter
michaelminter / notes.rb
Created October 8, 2012 01:22
Mac command line note management tool
#!/usr/bin/env ruby
require 'json'
require 'time'
class Time
module Units
Second = 1
Minute = Second * 60
Hour = Minute * 60
Day = Hour * 24
@tamouse
tamouse / munge_data.rb
Last active January 19, 2016 15:29
Pull in US Economic data from IMF database, pull out some columns and save as tab-delimited file. Updating to clarify the extraction algo and adding the write data algo.
require 'csv'
module MungeData
# Open a tab-delimited data file converting it into a CSV structure,
# expecting the first row to be headers,
# passing the table to map each row of the table,
# converting each row to a hash and then selecting only
# those items in the array that match the characteristics in the block
def self.extract_years(censusdata, y_start, y_end)
@pamelafox-coursera
pamelafox-coursera / CalendarHelper.class.php
Created April 10, 2013 23:09
Generate iCal files in PHP
<?php
class CalendarEvent {
/**
*
* The event ID
* @var string
*/
private $uid;
@tadast
tadast / Alphasights_technical_challenge.md
Last active April 3, 2024 12:25
A technical challenge we give to our Ruby on Rails applicants in order to evaluate their coding proficiency.Job description: http://www.alphasights.com/positions/ruby-developer-london or http://www.alphasights.com/positions/ruby-developer-new-york

Update: I no longer work for the company and this challenge is no longer used, but I'll leave the gist here in case people want to practice.

Alphasights Technical Challenge

Using Ruby on Rails we would like you to create a simple expert search tool. The application should fulfill the requirements below. The source code must be placed in a public repo on GitHub. The application should be deployable on Heroku.

  • I enter a name and a personal website address and a member is created.
  • When a member is created, all the heading (h1-h3) values are pulled in from the website to that members profile.
  • The website url is shortened (e.g. using http://goo.gl)
  • After the member has been added, I can define their friendships with other existing members. Friendships are bi-directional i.e. If Sasha is a friend of Ash, Ash is always a friend of Sasha as well.
@PWSdelta
PWSdelta / rspec_model_testing_template.rb
Last active July 29, 2025 13:52
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# 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!
#
# This skeleton also assumes you're using the following gems:
#
# rspec-rails: https://github.com/rspec/rspec-rails
@seamusabshere
seamusabshere / hcsv
Last active January 18, 2023 01:40
hcsv - dump id + values from one hstore column
#!/usr/bin/env ruby
# Usage: hcsv DBNAME TBLNAME HSTORECOL
# Output columns will be id + all the hstore keys
dbname, tblname, hstorecol = ARGV[0..2]
# Get hstore keys
out = `psql #{dbname} --tuples --command "SELECT DISTINCT k FROM (SELECT skeys(#{hstorecol}) AS k FROM #{tblname}) AS dt ORDER BY k"`
headers = out.split(/\n/).map(&:strip)
@coldhawaiian
coldhawaiian / practice.rb
Last active May 25, 2016 16:15
Just playing around with some Ruby.
# Eager (non-lazy) sequence generation:
(0..8).each_cons(2).map { |a,b| a + b }
# Another form (of above)
(1..10).each_with_object([1]) { |i,a| a[i] = a[i-1] + 2 }
# Eager Fibonacci (generates n+1 Fibonacci numbers)
(2..10).each_with_object([0,1]) { |i,a| a[i] = a[i-2] + a[i-1] }
# Corrected for n = 1 or 2, and removed extra number
@csm123
csm123 / index.html.haml
Last active April 12, 2017 07:56
React/Fluxxor in Rails Example
:javascript
$(document).ready(function() {
window.loadIngredientSuggestionsEditor(#{@ingredients});
});
%h1 Edit ingredient suggestions
#js-ingredient-suggestions-editor