Skip to content

Instantly share code, notes, and snippets.


Marc Riera mrcasals

View GitHub Profile
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."

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.

View html2md.rb
require 'nokogiri'
class Html2Md
class Link <, :title)
class Format <, :head, :body, :opened)
WIDTH = 80
fbeeper /
Last active Aug 29, 2015
Usable accentuation on MacOS Lion and above (including Yosemite!)

Usable accent marks on MacOS Lion and above (including Yosemite!)

Since Mac OS Lion, default "press and hold" of keyboard keys brings an easy access to accents and special characters:

alt text

However, who designed the order of elements in these lists is CLEARLY NOT using them with enough frequency*. Depending with what vowel you invoke this tool, the order of diacritical mark is different:

a à á â ä æ ã å ā
View build.rb
require "erb"
require "pathname"
digraph {
graph [fontname=Helvetica,fontsize=10];
node [fontname=Helvetica,fontsize=10];
txus / wtf.rb
Created Oct 31, 2014
Haskell-like function composition in Ruby - let the mad horses unleash
View wtf.rb
require 'blankslate'
class Proc
def self.comp(f, g)
lambda { |*args| f[g[*args]] }
def *(g)
Proc.comp(self, g)
View gist:51148cebc131daff19de
module RenderToHTML
[title, css, body].join("\n")
def self.title
commit_hash = `git log -1 --pretty="format:%H"`
txus / .gitignore
Created Sep 4, 2011
ShitDB - YAML-backed document-oriented database in pure ruby
txus / memoization_ast_transform.rb
Created Oct 14, 2011
Memoization through Rubinius AST Transforms
View memoization_ast_transform.rb
# This is a Rubinius AST Transform that implements a `memoization` keyword to
# be put before method definitions.
# Inspired by José Valim's talk at RuPy 2011.
# __KNOWN CAVEATS__: It doesn't reset the cache when changing arguments (it just
# memoizes the first call and returns that value forever more).
# Any ideas to make it work better? :D
View springpad_api_test.rb
require 'rest-client'
require 'json'
require 'yaml'
config = YAML.load("~/.springpad")))
user, password = config['user'], config['password']
response = RestClient.get(
You can’t perform that action at this time.