Skip to content

Instantly share code, notes, and snippets.

View fcofdez's full-sized avatar

Francisco Fernández Castaño fcofdez

View GitHub Profile
@fcofdez
fcofdez / fib.rs
Last active August 29, 2015 14:14
Calling Rust code from python
#![crate_type = "dylib"]
#[no_mangle]
pub extern fn fib(n: i32) -> i32 {
if n < 2 {
n
} else {
fib (n-1) + fib(n -2)
}
The system is: Linux - 3.17.8-200.fc20.x86_64 - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /usr/bin/cc
Build flags:
Id flags:
The output was:
0
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
@fcofdez
fcofdez / gist:be64699f4df5db7739f6
Created August 13, 2014 15:56
pre-commit hook
if git status --porcelain | awk '{ print $2 }' | xargs grep -r "set_trace" &>/dev/null
then
echo "Error, trying to commit with traces"
exit 1
fi
location /webhook/17cbb307-94ec-446b-a17b-ab82594c974c {
if ($request_method != 'POST') {
return 405;
}
content_by_lua 'ngx.print(io.popen("/path/to/script.sh"):read("*a"))';
}
@fcofdez
fcofdez / nintendotetrisai.md
Created May 13, 2014 14:50
Applying Artificial Intelligence to Nintendo Tetris