Skip to content

Instantly share code, notes, and snippets.

@ridget
ridget / Brewfile
Created November 12, 2019 21:07
CA Brewfile
tap "homebrew/core"
tap "homebrew/bundle"
tap "homebrew/cask-versions"
tap "mongodb/brew"
cask "java"
brew "autoconf"
brew "coreutils"
brew "direnv"
brew "git"
brew "gnupg"
@ridget
ridget / graphql_tips.md
Last active August 1, 2021 05:11
Useful GraphQL Schema Design Links
@ridget
ridget / keybase.md
Created May 26, 2017 05:28
keybase.md

Keybase proof

I hereby claim:

  • I am ridget on github.
  • I am ridget (https://keybase.io/ridget) on keybase.
  • I have a public key whose fingerprint is 68BB CE34 562F 5D5C F712 52B5 E42D 43A0 8ECE A334

To claim this, I am signing this object:

@ridget
ridget / 20120625030355_add_deleted_at_to_user.rb
Last active September 16, 2015 05:00 — forked from TimFletcher/20120625030355_add_deleted_at_to_user.rb
Trashable 'concern' for Rails models
# db/migrate/20120625030355_add_deleted_at_to_user.rb
class AddDeletedAtToUser < ActiveRecord::Migration
def change
add_column :users, :deleted_at, :datetime
end
end
@ridget
ridget / view_spec.rb
Created January 30, 2015 04:43
view spec sample
# spec/views/products/_product.html.erb_spec.rb
describe 'products/_product.html.erb' do
context 'when the product has a url' do
it 'displays the url' do
assign(:product, build(:product, url: 'http://example.com')
render
expect(rendered).to have_link 'Product', href: 'http://example.com'
@ridget
ridget / group_by_and_map.rb
Last active August 29, 2015 14:04
group by and map on values in group thanks @mattc
# works in ruby 1.9
count.group_by { |o| o.site.name }.inject({}) { |m, (k,v)| m[k] = v.map(&:user_id); m }
# works in ruby 2.0 and above
count.group_by { |o| o.site.name }.map{ |k,v| [k, v.map(&:user_id)]}.to_h
expect{
$SELECTION$
}.to change($MODEL$, :$ATTR$).by($AMOUNT$)
@ridget
ridget / gangnam.sh
Last active December 13, 2015 16:39
gangnam
echo "Oppan Gangnam Style Gangnam Style Op op op op oppan Gangnam Style Gangnam Style Op op op op oppan Gangnam Style hay Sexy lady Op op op op oppan Gangnam Style hay Sexy lady Op op op op Eh eh eh eh eh eh Oppan Gangnam Style" | say -v Junior
@ridget
ridget / Foo.php
Created November 12, 2012 00:54
File protected/controllers/user/Foo.php not loading why..?
<?php
class ChangePassword extends CAction {
... action code here
}
@ridget
ridget / gist:3162048
Created July 23, 2012 05:12
parametizes scope.
public function allInCategory($categoryIds){
$this->getDbCriteria()->mergeWith(array(
'with' => array(
'courseCategories' => array(
'condition' => 'categoryID in (:categoryIds)'
)
),
'params' => array(':categoryIds' => $categoryIds),
));
return $this;