Skip to content

Instantly share code, notes, and snippets.

View fcofdez's full-sized avatar

Francisco Fernández Castaño fcofdez

View GitHub Profile
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 / 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
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
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
@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)
}
#include <stdlib.h>
#include <stdio.h>
int main(){
int *a;
a = (int *) malloc(sizeof(int) * 12);
for (int i = 0; i < 12 ; i++)
a[i] = i;
for (int i = 0; i < 12 ; i++)
printf("%i\n", a[i]);
@fcofdez
fcofdez / gist:04f0f9b01398a9910417
Last active May 28, 2018 20:35
Distributed systems questions

Questions about Distributed systems by @tsantero.

  1. explain the life of an http request.
  2. what does the FLP result teach us?
  3. what is a byzantine failure?
  4. explain CRDTs
  5. explain linearizability.
  6. how does DNS work?
  7. crash-stop vs crash-recovery?
  8. difference between soft and hard real time
In [14]: dis(x)
2 0 BUILD_LIST 0
3 LOAD_GLOBAL 0 (range)
6 LOAD_CONST 1 (10)
9 CALL_FUNCTION 1
12 GET_ITER
>> 13 FOR_ITER 16 (to 32)
16 STORE_FAST 0 (x)
19 LOAD_FAST 0 (x)
22 LOAD_CONST 2 (1)
Client:
Version: 1.8.1
API version: 1.20
Go version: go1.4.2
Git commit: d12ea79
Built: Thu Aug 13 02:33:17 UTC 2015
OS/Arch: linux/amd64
Server:
Version: 1.8.1