Skip to content

Instantly share code, notes, and snippets.


Marc Riera mrcasals

Block or report user

Report or block mrcasals

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

An ActiveRecord conundrum

I'm going to describe a weird problem I faced when using ActiveRecord today. To protect the innocent, I'm not going to talk about the app I'm actually working on but will instead discuss a hypothetical but isomorphic database design for a clone of the popular blogging platform Tumblr.

Tumblr lets you publish various different sorts of content. We might be tempted to shove all these types in a big STI table, but the types are all quite different from one another and so we give them their own tables.

chriseidhof /
Last active Jan 19, 2017
Advance Deckset slides every 20 seconds
# Works from Deckset 1.2 upwards. Make sure you have a document opened.
# If you're using the Trial version change "Deckset" to "Deckset Trial"
osascript -e 'repeat' -e 'tell application "Deckset" to tell document 1 to set slideIndex to slideIndex + 1' -e 'delay 20' -e 'end repeat'
View wake_me
# usage: wake_me <command>
echo $@
notification='display notification "'$@'" with title "Finished"'
osascript -e "$notification"
say -v Deranged "it's finally, finally finished. at last."
otobrglez / jaccard_recommendation.rb
Created Mar 24, 2014
Simple recommendation system written in Ruby based on Jaccard index.
View jaccard_recommendation.rb
#!/usr/bin/env ruby
# Please read for more information about this code.
class Book <
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
wbroek / genymotionwithplay.txt
Last active Nov 6, 2019
Genymotion with Google Play Services for ARM
View genymotionwithplay.txt
NOTE: Easier way is the X86 way, described on
Download the following ZIPs:
ARM Translation Installer v1.1 (
Download the correct GApps for your Android version:
Google Apps for Android 6.0 ( -
Google Apps for Android 5.1 ( -
Google Apps for Android 5.0 ( -

rage-quit plugin for oh-my-zsh

based on rage-quit support for bash


Put the files below inside ~/.oh-my-zsh/custom/plugins/fuck

Also chmod a+x the flip command.

bitemyapp / gist:8739525
Last active Sep 10, 2019
Learning Haskell
View gist:8739525
peterc / methods_returning.rb
Last active Aug 14, 2017
Object#methods_returning - to work out which method on an object returns what we want
View methods_returning.rb
require 'stringio'
require 'timeout'
class Object
def methods_returning(expected, *args, &blk)
old_stdout = $>
$> = do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false
txus / .pryrc.rb
Last active Dec 18, 2015
Pry command to trace a method invocation and log backtraces of each invocation to a file.
View .pryrc.rb
def write_backtrace name, backtrace, filename
exceptions = Regexp.union([
backtrace.reject! { |line| line =~ exceptions }
chriscoyier / index.html
Created Jun 6, 2013
A CodePen by Chris Coyier. Track form progress with <progress> - Like a simple version of gamification.
View index.html
<form accept-charset="UTF-8" action="#" class="pro-form" id="pro-form" method="post">
<h1>Progress Form</h1>
<div class="progress-wrap">
<progress max="100" value="0" id="progress"></progress>
<div class="progress-message" id="progress-message">The form, it wants you.</div>
<input id="subscription_plan_id" name="subscription[plan_id]" type="hidden" value="1">
You can’t perform that action at this time.