Skip to content

Instantly share code, notes, and snippets.

Hraban Luyat hraban

Block or report user

Report or block hraban

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
hraban / coroutines.lisp
Created May 29, 2011 — forked from ryepup/coroutines in lisp
lisp coroutines using chanl (threads)
View coroutines.lisp
(defmacro make-coroutine ((&key (coroutine-done-value :done)) &body body)
(alexandria:with-gensyms ((thrfn "thread body")
(c "channel"))
`(let* ((,c (make-instance 'chanl:bounded-channel))
(,thrfn (lambda ()
(flet ((yield (&optional n)
(chanl:send ,c n)))
(yield ,coroutine-done-value)))))
(let ((alive-p T) val thr)
hraban / mylock.cs
Created Mar 20, 2012
Custom C# locking interface and implementation
View mylock.cs
using System;
using System.Threading;
namespace Locking
internal interface IWaitableLock
/// <summary>
/// Acquire the lock.
/// </summary>
hraban / static-int-functions-O0.s
Created Jun 28, 2012
Initialize variables using static functions instead of macros
View static-int-functions-O0.s
.file "test.c"
.type a, @function
pushq %rbp
.cfi_def_cfa_offset 16
movq %rsp, %rbp
.cfi_offset 6, -16
hraban / gist:3017681
Last active Aug 15, 2016
My .emacs (hraban)
View gist:3017681
(add-to-list 'load-path "~/.emacs.d/plugins")
;; cl-* functions and macros
(require 'cl)
(cl-defmacro if-exists ((var fname) &rest body)
`(let ((,var ,fname))
(when (file-exists-p ,var)
View test-O3.S
.file "test.c"
.p2align 4,,15
.globl my_test
.type my_test, @function
subq $8, %rsp
.cfi_def_cfa_offset 16
hraban / test-O3.s
Created Jul 4, 2012
Inlining through namespaces
View test-O3.s
.file "test.c"
.p2align 4,,15
.globl inline_value_proper
.type inline_value_proper, @function
movl $5000, %eax
hraban / prune-spaces.c
Created Jul 8, 2012
Example of a function that does not like overlapping buffers
View prune-spaces.c
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#define BUF_SIZE 256
/* source and destination buffers MUST NOT overlap */
char *
prune_spaces(char * dst, size_t dst_len, const char * src)
#!/usr/bin/env python
class Node(object):
def __init__(self, name, next=None): = next = name
self.l = 1 if next is None else next.l + 1
def __iter__(self,):
cur = self
hraban / weakrefmainloop.go
Created Nov 5, 2013
poc to clean up a mainloop goroutine when the "public pointer" runs out and is garbage collected
View weakrefmainloop.go
package main
import (
type foo struct {
hraban / pobox.php
Created Feb 12, 2014
Write-only file uploads for PHP server
View pobox.php
define("UPLOAD_DIR", "/tmp/pobox-uploads/");
define("CODE", "secretcodehere");
if ($_POST["code"] !== CODE) {
die("upload denied: illegal code");
if (!(is_dir(UPLOAD_DIR) || mkdir(UPLOAD_DIR, 0700))) {
You can’t perform that action at this time.