Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am carlosgaldino on github.
  • I am carlosgaldino (https://keybase.io/carlosgaldino) on keybase.
  • I have a public key whose fingerprint is 761C C1E1 ED5E 9CE0 611D ECA8 24D3 CE8E 2906 1EF5

To claim this, I am signing this object:

@carlosgaldino
carlosgaldino / gist:11023688
Created April 18, 2014 03:35
type inference in haskell
lengthOf x
| length x == 0 = "0"
| otherwise = length x
{--
lengthOf.hs:3:17:
Couldn't match expected type `[Char]' with actual type `Int'
In the return type of a call of `length'
In the expression: length x
In an equation for `lengthOf':
# Este é um exemplo encontrado na última edição do Programming Ruby do Dave Thomas, página 53.
# testa o método que converte uma string em um array de palavras
def test_empty_string
assert_equal([], words_from_string(""))
assert_equal([], words_from_string(" "))
end
def test_single_word
assert_equal(["cat"], words_from_string("cat"))
def flatten(arr)
out = []
arr.each do |a|
if a.is_a?(Array)
out += flatten(a)
else
out << a
end
end
set fuoptions=maxvert
function ToggleFullScreen()
if exists("s:old_columns")
set columns=s:old_columns
set nofu
unlet s:old_columns
else
let s:old_columns=&columns
set columns=84 fu
** Execute vm/test/runner
Running 1 tasks using 3 parallel threads
1: GN vm/test/runner.cpp
1: CC vm/test/runner.cpp
In file included from vm/test/runner.cpp:3322:
./vm/test/test_pointer.hpp: In member function ‘void TestPointer::test_read_long()’:
./vm/test/test_pointer.hpp:89: error: no matching function for call to ‘rubinius::Pointer::read_long(rubinius::VM*&)’
vm/builtin/ffi_pointer.hpp:62: note: candidates are: rubinius::Integer* rubinius::Pointer::read_long(rubinius::VM*, rubinius::Object*)
./vm/test/test_pointer.hpp: In member function ‘void TestPointer::test_write_long()’:
./vm/test/test_pointer.hpp:97: error: no matching function for call to ‘rubinius::Pointer::read_long(rubinius::VM*&)’
@carlosgaldino
carlosgaldino / gist:3291725
Last active October 8, 2015 06:28
Topics: Blue pill x Red pill talk
#include <stdio.h>
int bit_and(int x, int y)
{
return ~(~x | ~y);
}
int main(int argc, char **argv)
{
printf("%.8x\n", bit_and(6, 5));
#include <stdio.h>
/* Bitwise integer addition */
int plus(int x, int y)
{
int result = x ^ y;
int carry = (x & y) << 1;
if (carry != 0)
return plus(result, carry);
struct Person {
name: String,
age: u8
}
fn main() {
// only works if compiled with `--test` flag.
// let p = Person::create_with(String::from("Carlos"), 26);
let p = Person { name: String::from("Carlos"), age: 26 };
println!("{} {}", p.name, p.age);