Skip to content

Instantly share code, notes, and snippets.

@mernen
mernen / octocat.png
Last active December 16, 2015 07:48
git diff octocat.png This was an attempt to use GitHub's image diff to show what changed on their new Octocat. Unfortunately, it doesn't work on Gists :(
octocat.png
# let's define this (bash) function to help us see what's happening:
args() { echo "${#@} arguments:"; for arg in "$@"; do echo "-> $arg"; done; }
# now let's see the differences between $@ and $*:
# $*: expands into a series of words, basically ignoring all the quotes
# you'll hardly ever want to do this
test() { args $*; }
test a "b b" c
@mernen
mernen / tactics.js
Created July 26, 2010 03:52
Nerdson Labs: algoritmo de movimento estilo jogo TBS
$(document).ready(function(){
$("#tactics form").submit(function(e){
e.preventDefault();
});
//syntax highlight
ChiliBook.recipeFolder = "./";
//observação: criei variáveis globais aqui a nivel de exemplo, mas isso não é recomendado. O ideal é criar objetos para armazenar esses valores. ;)
diff --git i/vm/llvm/jit_operations.hpp w/vm/llvm/jit_operations.hpp
index f55a771..aa15021 100644
--- i/vm/llvm/jit_operations.hpp
+++ w/vm/llvm/jit_operations.hpp
@@ -293,7 +293,7 @@ namespace rubinius {
Value* ptrtoint(Value* ptr) {
return CastInst::Create(
Instruction::PtrToInt,
- ptr, Type::Int32Ty, "ptr2int", block_);
+ ptr, IntPtrTy, "ptr2int", block_);
$ bin/rbx -Xjit.enabled -e ''
exception detected at toplevel: (StackError)
kernel/alpha.rb:20
kernel/delta/kernel.rb:47
kernel/bootstrap/kernel.rb:43
kernel/delta/kernel.rb:18
kernel/delta/kernel.rb:47
kernel/bootstrap/kernel.rb:43
kernel/delta/kernel.rb:18
kernel/delta/kernel.rb:47
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/daniel/Dev/rbx-llvm/bin/rbx
[Thread debugging using libthread_db enabled]
[New Thread 0x7f3468a41700 (LWP 28200)]
[Switching to Thread 0x7f3468a41700 (LWP 28200)]
Breakpoint 2, VMMethod (this=0x1e1e810, state=0x1de9580, meth=0x7f346720a518)
module Foo
BAZ = 100
module Bar
def self.baz
BAZ
end
end
end
puts Foo::Bar.baz
@classmethod
def get_page(cls, app_id, bookmark=None):
pagesize = 15
first_fetch = not bookmark
if first_fetch:
ascending = False
date = None
elif bookmark.startswith('-'): # we're moving backwards
ascending = False
date = str_to_date(bookmark[1:])
def coerce_to_array(v)
if v.IS_A?(Array) # internal test, not #is_a? method call
v
elsif v.respond_to?(:to_ary) # replace with to_a for 1.9
result = v.to_ary
if result.IS_A?(Array)
result
else
raise TypeError
end
@mernen
mernen / .bashrc
Created January 15, 2009 00:41 — forked from henrik/.bashrc
Slightly optimized version, and with niftier branch indicator
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
git diff --quiet HEAD &>/dev/null
[[ $? == 1 ]] && echo "*"
}
function parse_git_branch {