Skip to content

Instantly share code, notes, and snippets.

View werelax's full-sized avatar

Elías Alonso werelax

View GitHub Profile
@werelax
werelax / lexer.js
Last active December 18, 2015 11:39
The laziest Lisp lexer in history.
function lexer(code) {
var strings = [],
normalize = function(code) {
return code.replace(/\(/g, " ( ")
.replace(/\)/g, " ) ")
.replace(/\s\s*/g, " ")
.replace(/^\s*/g, "")
.replace(/\s*$/g, "");
};
code = code.replace(/(".*?")/g, function(str) { return "ç" + (strings.push(str) - 1) + "ç"; });
@willurd
willurd / web-servers.md
Last active May 25, 2025 11:13
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@doitian
doitian / init.el
Created April 20, 2013 09:05
Minimal emacs config
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
@datagrok
datagrok / git-serve.md
Last active April 21, 2023 07:33
How to easily launch a temporary one-off git server from any local repository, to enable a peer-to-peer git workflow.
@HarryR
HarryR / racket-libevent-webserver-example.rkt
Created November 8, 2012 21:26
Example of basic libevent http server in Racket using FFI
#lang racket
(require ffi/unsafe
ffi/unsafe/define)
(define-ffi-definer define-libevent (ffi-lib "libevent"))
; Event Base
(define evbase-ptr (_cpointer 'evbase))
(define-libevent event_base_new (_fun -> evbase-ptr))
(define-libevent event_base_dispatch (_fun evbase-ptr -> _void))
@rantav
rantav / README.md
Created June 27, 2012 05:18
MongoDB increment or insert

In mongodb it's easy to make at upsert, meaning update-or-insert by calling

db.collection.update({criteria}, {updated fields}, true)

The third parameter means - insert a new document if the document doesn't exist yet. So, for example, the following will insert a new document for the user if there's no document for that user yet, and will update it if it already exists:

 db.users.update({user_id: '1234'}, {user_id: '1234', name: 'Ran'}, true)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@gre
gre / easing.js
Last active May 22, 2025 13:16
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@scottjehl
scottjehl / jqm-simple-dynamic-page.js
Created June 21, 2011 14:08
jQuery Mobile: Simple dynamic page creation
/* Dynamically create a page and navigate to it.
(and include the page in browser history ) */
//create markup
var newPage = $("<div data-role=page data-url=yay><div data-role=header><h1>YAY!!!!</h1></div><div data-role=content><img src=http://bukk.it/yay.gif /></div></div");
//append it to the page container
newPage.appendTo( $.mobile.pageContainer );
//go to it
@ncweinhold
ncweinhold / main.c
Created May 25, 2011 20:44
Calling Gambit-C scheme functions from C
#include <stdio.h>
#define ___VERSION 406001
#include "gambit.h"
#include "somescheme.h"
#define SCHEME_LIBRARY_LINKER ____20_somescheme__
___BEGIN_C_LINKAGE