Skip to content

Instantly share code, notes, and snippets.

@rafacv
rafacv / bf-ansic.c
Created September 27, 2010 13:29 — forked from lifthrasiir/bf.c
s[999],*r=s,*d,c;main(a,b){char*v=1[d=b];for(;c=*v++%93;)for(b=c%7?a&&(c&17?c&1?
(*r-=c-44):(r+=c-61):c&2?putchar(*r):(*r=getchar()),0):v;b&&c|a**r;v=d)main(!c,&
b-1);d=v;}
@rafacv
rafacv / list_comprehension.py
Created November 13, 2011 21:36
Comparison between list()'s and lists' comprehension implementation.
my_list = list(range(1000000))
for i in range(100):
other_list = [elem for elem in my_list]
@rafacv
rafacv / index.erb
Created December 13, 2011 21:15
Code to get a hanging post request on windows using webrick over ironruby.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function () {
$("#myb").click(function () {
$.ajax({
url: "/showme",
type: "POST",
data: {nome: "Jose", sobrenome: "Valim"},
@rafacv
rafacv / encoding.rb
Created February 17, 2012 00:09
IronRuby doesn't respect encoding comments when eval'ing
eval <<ENC
# coding: utf-8
def method
puts "".encoding.inspect
end
ENC
eval <<ENC
# coding: big5
def method2
@rafacv
rafacv / pyperclip.py
Created February 27, 2012 16:45
Unified interface to access clipboard across major OSes
# Source: http://coffeeghost.net/2010/10/09/pyperclip-a-cross-platform-clipboard-module-for-python/
# Pyperclip v1.3
# A cross-platform clipboard module for Python. (only handles plain text for now)
# By Al Sweigart al@coffeeghost.net
# Usage:
# import pyperclip
# pyperclip.copy('The text to be copied to the clipboard.')
# spam = pyperclip.paste()
@rafacv
rafacv / skype-search
Created October 18, 2012 01:54 — forked from leandro/skype-search
Search Skype history for given terms
@rafacv
rafacv / apt-init.pp
Created December 24, 2012 13:53 — forked from fnando/apt-init.pp
class apt-get::update {
exec { "apt-get update":
command => "apt-get update"
}
}

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.

@rafacv
rafacv / install_python.sh
Last active December 14, 2015 19:58
Install Py2.7.3 CentOS
cd /tmp
curl -O http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar xf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure --enable-shared --prefix=/usr/local
make
sudo make altinstall
@rafacv
rafacv / event-with-delay.js
Last active October 16, 2015 22:42
Delay responses to events
/*
* Sometimes it's useful to wait for the user to complete the action
* he's engaged on instead of trying to handle it right away. A practical
* example is to avoid flooding servers with tons of autocompletion requests
* for each key stroke the user types in. A more efficient approach is to wait
* until the user feeds enough before attempting make requests for only one or
* two letters.
*
* Usage:
* listenToEventAndDelay(textInput, 'keydown', autoCompleteFunction, 500);