Skip to content

Instantly share code, notes, and snippets.

View mrcasals's full-sized avatar
👨‍🚀
🚀

Marc Riera mrcasals

👨‍🚀
🚀
View GitHub Profile
@nihilismus
nihilismus / chruby-ruby-build-mksh.md
Last active January 30, 2017 01:30
chruby + ruby-build / mksh

chruby + ruby-build / mksh

  1. Install chruby and ruby-build with git. I keep their repo at ~/.chrb, their installation inside ~/local and my rubies at ~/.chrb/rubies.
  2. Copy this in your ~/.mkshrc file
# chruby + ruby-build
chrb() {
    source ~/local/share/chruby/chruby.sh
    unset RUBIES
    RUBIES=$(ls -d ~/.chrb/rubies/* 2> /dev/null)
@chriseidhof
chriseidhof / pechakucha.sh
Last active January 19, 2017 11:56
Advance Deckset slides every 20 seconds
#/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'
@txus
txus / .pryrc.rb
Last active December 18, 2015 17:59
Pry command to trace a method invocation and log backtraces of each invocation to a file.
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 June 6, 2013 14:01
A CodePen by Chris Coyier. Track form progress with <progress> - Like a simple version of gamification.
<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">
@avdi
avdi / class-reloading.rb
Created June 12, 2012 19:08
Class reloading breaks type-checking
class Foo
end
Foo.object_id # => 34581480
f = Foo.new # => #<Foo:0x000000041f53c0>
f.class.object_id # => 34581480
# This just prevents the "const redefined" warning
@mrsimo
mrsimo / hack.sh
Created April 4, 2012 08:34 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2299719/hack.sh | sh
#
@txus
txus / springpad_api_test.rb
Created February 27, 2012 10:39
Springpad API test
require 'rest-client'
require 'json'
require 'yaml'
config = YAML.load(File.read(File.expand_path("~/.springpad")))
user, password = config['user'], config['password']
#
response = RestClient.get(
"http://springpadit.com/api/users/txus",
@txus
txus / memoization_ast_transform.rb
Created October 14, 2011 13:29
Memoization through Rubinius AST Transforms
# 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
#
@txus
txus / .gitignore
Created September 4, 2011 19:33
ShitDB - YAML-backed document-oriented database in pure ruby
my_db
module RenderToHTML
def self.book
[title, css, body].join("\n")
end
private
def self.title
commit_hash = `git log -1 --pretty="format:%H"`
%{