Skip to content

Instantly share code, notes, and snippets.

@jasonong
jasonong / gist:6bc765ade3838c9ea7a0
Last active August 29, 2015 14:21
Simple hash conditions for columns in model table.
sql = '1 = 1'
values = {}
if params[:foo].present?
sql << 'AND foo >= :foo'
values[:foo] = params[:foo]
end
if params[:bar].present?
sql << 'AND bar < :bar'
@jasonong
jasonong / mp_profiles.rb
Last active August 29, 2015 13:56
Getting Mixpanel profiles where property "Name" is not set.
require 'rubygems'
require 'mixpanel_client'
config = {api_key: 'FOO', api_secret: 'BAR'}
client = Mixpanel::Client.new(config)
data = client.request('engage', {
where: 'not defined(properties["Name"])'
})
<link rel='canonical' href: '/home' />
@jasonong
jasonong / Assert disabled link
Created December 18, 2012 21:01
Check for a disabled link with Capybara + Rspec.
.count {
border: 1px solid #D4D4D4;
font-size: 11px;
font-weight: bold;
padding: 0px 8px;
line-height: 20px;
margin-left: 10px;
border-radius: 2px;
color: #333;
background-color: white;
@jasonong
jasonong / gist:2300375
Created April 4, 2012 11:03 — forked from choonkeat/gist:2297910
street names of singapore
Abingdon Road
Adam Drive
Adam Park
Adam Road
Adis Road
Admiralty Drive
Admiralty Lane
Admiralty Link
Admiralty Road
Admiralty Road East
@jasonong
jasonong / gist:1002660
Created June 1, 2011 16:13
Show notes from Singapore Ruby Brigade meet up on 1st June 2011
# Talks
* SF/SV communities - Aihui
* Game design with verbs - Matthew Weise
# Links
* http://bit.ly/SiliconValleyStartupScene
* http://gambit.mit.edu/
* http://www.flickr.com/photos/elfgoh/sets/72157626860409700/show/
@jasonong
jasonong / terminology20110524
Created May 25, 2011 15:41
Show notes from Terminology meet up on 24th May 2011
Date: 25th May 2011
Time: 7:30pm
Venue: HackerspaceSG, 70A Bussorah Street
# Patrick:
~/.bashrc
http://haller.ws/projects/bash/
# Ivan:
http://en.wikipedia.org/wiki/The_Mother_of_All_Demos
@jasonong
jasonong / srb14052011
Created May 12, 2011 03:04
Show notes from Singapore Ruby Brigade meet up on 11th May 2011
== Meetup ==
Date: 11th May 2011
Time: 7:30pm
Venue: HackerspaceSG, 70A Bussorah Street
== Food and Beer ==
Many thanks to Carl from Pivotal Labs for providing delicious Arabic snacks and ice cold Wychcrafts, Asahis and Hoegardens from Mabuk Monkey.
And also special thanks to Meng for serving us flame thrown carnival.
namespace :unittest do
task *[:tag, (0..100).map {|i| "t#{i}".to_sym }].flatten do |t, args|
args.each do |key, value|
Dir[File.join(RAILS_ROOT, 'test', 'unit', '*.rb')].each do |file|
File.open(file,'r') do |fh|
tags = fh.grep(/\~(\S+)/).map do |t|
t.strip!