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
View belongs_to_lambda.md

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
chriseidhof / pechakucha.sh
Last active Jan 19, 2017
Advance Deckset slides every 20 seconds
View pechakucha.sh
#/bin/bash
# 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
#!/bin/zsh
# 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
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 http://otobrglez.opalab.com for more information about this code.
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end
@wbroek
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 https://www.genymotion.com/help/desktop/faq/#google-play-services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
View INSTALL.md

rage-quit plugin for oh-my-zsh

based on rage-quit support for bash

HOW TO INSTALL

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

Also chmod a+x the flip command.

@bitemyapp
bitemyapp / gist:8739525
Last active Sep 10, 2019
Learning Haskell
View gist:8739525
@peterc
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 = $>
$> = StringIO.new
methods.select do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false
@txus
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([
/\.bundle/,
/spec/,
/test/,
/lib\/ruby\/1.9.1/
])
backtrace.reject! { |line| line =~ exceptions }
@chriscoyier
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>
</div>
<input id="subscription_plan_id" name="subscription[plan_id]" type="hidden" value="1">
You can’t perform that action at this time.