Skip to content

Instantly share code, notes, and snippets.

require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
Ruby Quickstart for Refugees:
--
# is a comment.
You don't need semicolons.
Ruby aims to be elegant and readable, so punctuation and boilerplate are
minimal.
--
@chischaschos
chischaschos / .gitignore
Created January 2, 2011 02:23
A callbacks DSL creation example with ruby metaprogramming
*.swp
@presidentbeef
presidentbeef / rubychat.rb
Created January 6, 2011 08:02
Simple Ruby chat with GServer
require 'gserver'
class ChatServer < GServer
def initialize *args
super
#Keep a list for broadcasting messages
@chatters = []
#We'll need this for thread safety
#!/usr/bin/env python2.7
# -*- encoding:utf-8 -*-
import string
class Encotel(object):
def get_number(self, x):
"Retorna os números equivalentes aos caracteres"
saida = ''
mapping = self.get_mapping()
anonymous
anonymous / indicator-sysload.c
Created May 20, 2011 14:01
indicator-sysload is an Ubuntu appindicator that displays the system load (CPU, memory usage, network traffic).
/*
This is an Ubuntu appindicator that displays the system load
(CPU, memory usage, network traffic).
It looks like this: http://imgur.com/W4PCc .
Compile with:
gcc -Wall `pkg-config --cflags --libs gtk+-2.0 appindicator-0.1 libgtop-2.0` -o indicator-sysload ./indicator-sysload.c
@mikelikesbikes
mikelikesbikes / gist:1007228
Created June 3, 2011 21:43
Fibonacci with Inject!
def fib(n)
(0..n).inject([1,0]) { |(a,b), _| [b, a+b] }[0]
end
@brienw
brienw / rake_autocomplete_for_bash.rb
Created June 14, 2011 17:50 — forked from petrblaho/rake_autocomplete_for_bash.rb
bash autocomplete for rake with cache
#!/usr/bin/env ruby
# Complete rake tasks script for bash
# Save it somewhere and then add
# complete -C path/to/script -o default rake
# to your ~/.bashrc
# Xavier Shay (http://rhnh.net), combining work from
# Francis Hwang ( http://fhwang.net/ ) - http://fhwang.net/rb/rake-complete.rb
# Nicholas Seckar <[email protected]> - http://www.webtypes.com/2006/03/31/rake-completion-script-that-handles-namespaces
# Saimon Moore <[email protected]>
@msimpson
msimpson / pipes
Created July 21, 2011 10:40
2D Bash version of the Pipes screensaver.
#!/bin/bash
declare -i f=75 s=13 r=2000 t=0 c=1 n=0 l=0
declare -ir w=$(tput cols) h=$(tput lines)
declare -i x=$((w/2)) y=$((h/2))
declare -ar v=( [00]="\x83" [01]="\x8f" [03]="\x93"
[10]="\x9b" [11]="\x81" [12]="\x93"
[21]="\x97" [22]="\x83" [23]="\x9b"
[30]="\x97" [32]="\x8f" [33]="\x81" )
OPTIND=1
@tsaniel
tsaniel / LICENSE.txt
Created September 2, 2011 12:17 — forked from 140bytes/LICENSE.txt
Konami Code easter egg
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE