Skip to content

Instantly share code, notes, and snippets.

View seisvelas's full-sized avatar
🦊
const sh = network.pop(shell); sh.write({recipient:'admin'}, 'nice system!');

Xandre V seisvelas

🦊
const sh = network.pop(shell); sh.write({recipient:'admin'}, 'nice system!');
View GitHub Profile
@seisvelas
seisvelas / fib.s
Created December 5, 2018 01:52
Attempted recursive fibonacci finder
.section .data
.section .text
.globl _start
_start:
# adjust stack frame and push fib args to stack
pushl $5
pushl $1
pushl $0
import timeit
from numpy import mean
nqueens_gen_setup = """def threatened(pos, past, n):
for i in range(len(past)):
if past[i] == pos or abs(pos - past[i]) == len(past) - i:
return True
return False
def nqueens(n, past=None):
@seisvelas
seisvelas / nqueens_gen.py
Created December 6, 2018 23:55
Generates a...generator? To lazily generate nqueens solutions
def threatened(pos, past, n):
for i in range(len(past)):
if past[i] == pos or abs(pos - past[i]) == len(past) - i:
return True
return False
def nqueens(n, past=None):
if past == None:
for i in range(n):
yield from nqueens(n, [i+1])
@seisvelas
seisvelas / sleep.rkt
Created December 12, 2018 18:14
Computer Science is a subset of poetry
; prayer for λ long night's sleep
(let ((yourself rest)
(sometimes
(λ (person) cannot-connect 'anymore
(and ;has-to
sleep
(for ([days '(at . λ . 'time)])
(not even?) 2
raise (λ (single) 'finger))))))
shutdown (and #'just sleep
@seisvelas
seisvelas / recursive_power.asm
Last active September 12, 2019 16:09
My first recursion in x86
section .data
section .text
global _start
global power
power:
; ro ro fite
push rbp
mov rbp, rsp
@seisvelas
seisvelas / r_pow_macos.asm
Created December 19, 2018 01:07
Recursive power function for MacOS nasm
section .data
section .text
global start
global power
power:
; ro ro fite
push rbp
mov rbp, rsp
@seisvelas
seisvelas / queue_kata.py
Last active January 6, 2019 02:48
Solution for Supermarket Queue Kata (https://www.codewars.com/kata/57b06f90e298a7b53d000a86) [edit: added comments for Pete education]
def queue_time(customers, n):
# keep track of time
wait = 0
# pool of people currently checking out at a register
checkers_out = []
# how many customers to load into queue.
@seisvelas
seisvelas / modified.py
Last active January 6, 2019 19:52
Reddit contribution (ca. 2013)
def upload(config_file):
bucket = s3.get_bucket(bucket_name)
# build a list of files already in the bucket
remote_files = {key.name : key.etag.strip('"') for key in bucket.list()}
# upload local files not already in the bucket
for root, dirs, files in os.walk(static_root):
@seisvelas
seisvelas / debian_getdents64.c
Created January 16, 2019 22:19
Apparently I'm too lazy to learn how to paste into VirtualBox
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#define handle_error(msg) \
@seisvelas
seisvelas / SYS_getdents64.c
Last active January 16, 2019 22:34
Test for possible bug in Torsocks getdent_fix branch
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#define handle_error(msg) \
do { perror(msg); exit(EXIT_FAILURE); } while (0)