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 /
Last active Aug 29, 2015
Bash utils for deploy scripts
# Copyright (c) Hraban Luyat 2015 <>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
hraban / faviconchanger.html
Created Jul 7, 2015
animated favicon without gif
View faviconchanger.html
<!doctype html>
<link rel=icon id=favicon >
var i = 0;
setInterval(function () {
hraban / pre-commit
Last active Aug 11, 2019
NOCOMMIT git hook — prevent accidentally committing debug code
View pre-commit
# This pre-commit hook will prevent you from committing any line (or filename) containing
# the string NOCOMMIT. Use that tag in comments around source code you want to avoid
# accidentally committing, like temporary IP addresses or debug printfs.
# To add it to an existing repository, save it to .git/hooks/pre-commit (or append, if
# that file already exists). Remember to make executable (chmod +x ...)
# To automatically add this pre-commit hook to every repository you create or clone:
hraban / config.guess
Last active Aug 29, 2015
Building opus with emscripten
View config.guess
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
hraban / test.c
Last active Aug 29, 2015
Memcpy vs pointer dereference
View test.c
* Memcpy demonstration. Try compiling with:
* $ gcc -Wall -Werror -pedantic -std=c99 -S test.c -o test-deref.s
* $ gcc -Wall -Werror -pedantic -std=c99 -S test.c -DMEMCPY -o test-memcpy.s
* $ diff -u test-deref.s test-memcpy.s
* And play with -O0 to -O3 flags to see the effect of optimizations.
hraban / getrandomparagraph.scala
Created Feb 6, 2015
Get a random paragraph from a file
View getrandomparagraph.scala
import scala.util.Random
object RandomQuote {
private def splitParagraphs(r: io.BufferedSource) =
private def getRandomElement[T](ar: Array[T]): Option[T] = ar.length match {
case 0 => None
case _ => Some(ar(Random.nextInt(ar.length)))
hraban / poc.js
Last active Aug 29, 2015
encode array of strings literal in js by length
View poc.js
// Copyright © 2014 Hraban Luyat <>
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
View chatroomwidget.js
"use strict";
// appended odd string to avoid shadowing existing vars
function chatroomwidget_88ed71a($) {
if ($ === undefined) {
throw "chatroomwidget.js requires jQuery";
// TODO: get from query string
if (chatroomwidgetServerUrl === undefined) {
throw "chatroomwidgetServerUrl must be defined";
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))) {
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 {
You can’t perform that action at this time.