Skip to content

Instantly share code, notes, and snippets.

Fatal error 11: Segmentation fault
Backtrace:
emacs[0x4f719b]
emacs[0x4dcc4e]
emacs[0x4f5dee]
emacs[0x4f5f53]
/usr/lib/libpthread.so.0(+0xf870)[0x7f1fff832870]
emacs[0x49ee2b]
emacs[0x4a3004]
emacs[0x4314a5]
@hackaugusto
hackaugusto / gist:7860387
Created December 8, 2013 17:13
Borrowed function
fn inner(f: &fn(&mut int)) {
let mut a = ~1;
f(a);
}
fn borrow(b: &mut int, f: &fn(&mut int)) {
f(b);
f(b); // can reuse borrowed variable
inner(f); // shouldn't f be borrowed?
fn double(f: &|int| -> int, a: int) -> int {
(*f)(a) * 2
}
fn borrow(f: &|int| -> int) -> int {
let r = double(f,1);
(*f)((*f)(r))
}
fn main() {
print!("{}", borrow(&|a:int| a+1));
Debugger entered--Lisp error: (file-error "make client process failed" "connection refused" :name "epc con 3" :buffer #<buffer *epc con 3*> :host "localhost" :service 42324 :nowait nil)
make-network-process(:name "epc con 3" :buffer #<buffer *epc con 3*> :host "localhost" :service 42324 :nowait nil)
open-network-stream("epc con 3" #<buffer *epc con 3*> "localhost" 42324)
epc:connect("localhost" 42324)
epc:start-server("/home/hack/.emacs.d/el-get/jedi/env/bin/python" ("/home/hack/.emacs.d/el-get/jedi/jediepcserver.py" "--address" "127.0.0.1"))
epc:start-epc("/home/hack/.emacs.d/el-get/jedi/env/bin/python" ("/home/hack/.emacs.d/el-get/jedi/jediepcserver.py" "--address" "127.0.0.1"))
(let ((mngr (epc:start-epc server-prog server-args))) (set-process-query-on-exit-flag (progn (or (and (memq (aref (progn ... ...) 0) cl-struct-epc:connection-tags)) (error "%s accessing a non-%s" (quote epc:connection-process) (quote $
jedi:epc--start-epc("/home/hack/.emacs.d/el-get/jedi/env/bin/python" ("/home
#!/usr/bin/zsh
setopt ERR_EXIT
# cannot use PIPE_FAIL because we want to ignore mount efivarfs failure
# setopt PIPE_FAIL
msg() {
printf "==> $1\n" "${@:2}"
}
@hackaugusto
hackaugusto / allowed_users
Last active January 26, 2016 06:57
vsftpd virtual users
user1
user2
...
@hackaugusto
hackaugusto / serialization
Last active February 26, 2016 15:58
profiling results from GreenletProfiler, filtered for the serialization code (rlp, encoding, msgpack)
Completed 1000 transfers at 72.9175900588 tps
ncalls tottime percall % cumtime percall function
16000 0.018 0.000 0.17 0.151 0.000 <genexpr>
19999 0.055 0.000 0.51 0.159 0.000 BigEndianInt.deserialize
71000 0.088 0.000 0.82 0.129 0.000 is_integer
43994 0.172 0.000 1.61 0.302 0.000 packl
2000 0.005 0.000 0.05 0.018 0.000 encode_hex
19999 0.024 0.000 0.22 0.245 0.000 deserialize
4999 0.012 0.000 0.12 0.422 0.000 decode
2000 0.013 0.000 0.12 0.067 0.000 deserialize
3598395 function calls (3793231 primitive calls) in 10.645 seconds
Ordered by: internal time
List reduced from 325 to 15 due to restriction <15>
ncalls tottime percall cumtime percall filename:lineno(function)
7000 0.718 0.000 1.049 0.000 __init__.py:224(ecdsa_recover_compact)
17000/122000 0.622 0.000 1.817 0.000 umsgpack.py:338(_pack2)
53020 0.451 0.000 1.455 0.000 keccak.py:79(Keccak_Hash.__init__)
5000 0.369 0.000 0.398 0.000 __init__.py:136(_ecdsa_sign_recoverable)
@hackaugusto
hackaugusto / postmortem_hack.py
Last active April 29, 2017 16:20
A quick hack to land inside the stack of a greenlet that trowed a exception
# ---- HACK ----
# this will replace greenlet's Gevent class, for it to work it must
# be pasted before any code uses gevent is imported
import functools
import gevent
def wrap_pm(run):
@functools.wraps(run)
def wrapper(*args, **kwargs):
@hackaugusto
hackaugusto / rec.py
Created October 4, 2016 20:58
recursion vs. loop
# -*- coding: utf-8 -*-
from __future__ import print_function
import timeit
setup_rec = '''
def rec(a):
a[0] *= 2
a[1] *= 3
if a[0] + a[1] < 178: