Skip to content

Instantly share code, notes, and snippets.

@chjj
chjj / good_randomness.js
Created August 27, 2011 16:57
good randomness
// small script i wrote to get strong randomness in node
// putting it here so i dont lose it
// copyright (c) 2011, christopher jeffrey, mit license, etc.
// example output:
// urandom: 0.17843490773309834
// Math.random: 0.7067500613629818
// random: 0.3154916005012327
@chjj
chjj / .vimrc
Last active January 29, 2023 07:47
vimrc, so i don't lose it
"
" ~/.vimrc
" https://gist.github.com/chjj/1257074
"
" === options ==================================================================
set nocompatible " vim settings
set nomodeline " security measure
@chjj
chjj / archive
Created October 8, 2011 17:41
script for people who dont like file managers
#!/bin/sh
# easy manipulation of archives for people
# who don't like archivers or file managers
# copyright (c) 2011, christopher jeffrey
LIST=
EXTRACT=
CREATE=
ENCRYPT=
@chjj
chjj / frame_extents.c
Created November 1, 2011 08:05
x frame extents
static void
get_frame_extents(Display *dpy, Window w, int *top) {
long *extents;
Atom actual_type;
int actual_format;
unsigned long nitems, bytes_after;
unsigned char *data = NULL;
int result;
*top = 0;
@chjj
chjj / node_functions.sh
Created November 2, 2011 00:52
node functions for .bashrc
# $ echo "console.log('hello world')" | runjs
runjs() {
cat | xargs -0 node -e
}
# usage:
# $ echo "hello world" | jsrx "/h\w+/g" "hi"
jsrx() {
local str=$(cat | sed "s/\\\/\\\\\\\/g" \
| sed "s/'/\\\'/g" | sed ':a;N;$!ba;s/\r\n\|\n/\\n/g')
@chjj
chjj / trans.sh
Created November 6, 2011 04:44
setting transparency from bash
#!/bin/bash
# transset in a bash script
# copyright (c) 2011, christopher jeffrey
# usage:
# by window id
#trans -w "$WINDOWID" -o 75
# by name
#trans -n "urxvt" -o 75
@chjj
chjj / pocketfm.js
Created December 17, 2011 14:38
pocket-sized file manager/sharing so i dont have to start up samba
/**
* pocketfm
* Pocket-sized File Manager
* Uses plain html to be as simple as possible
* Code is messy, needs revision and needs
* native mv, rm, cp implementations
* Copyright (c) 2011, Christopher Jeffrey (MIT License)
*/
process.title = 'pocketfm';
@chjj
chjj / regex_fail.js
Created January 24, 2012 20:08
regex failure
var regex = /^ *<\w+(?!:\/|@)\b(?:"[^"]*"|'[^']*'|[^>])*?> *(?:\n{2,}|\s*$)/;
var str = ''
+ '<div class="hero-unit">\n'
+ ' <img src="img/hello_world.png" style="misc: properties;">\n'
+ ' <div>\n'
+ ' <h1>hello world</h1>\n'
+ ' <p>hello world.</p>\n'
+ ' <p><a class="hello world" href="#!hello">hello world</a></p>\n'
+ ' </div>\n'
terminal #2:
open("/dev/pts/8", O_RDWR|O_NOCTTY) = 8
ioctl(8, TIOCSWINSZ, {ws_row=30, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb735f738) = 851
close(8) = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
mmap2(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xb6a3a000
mprotect(0xb6a3a000, 4096, PROT_NONE) = 0
clone(child_stack=0xb6a7a484, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0xb6a7abd8, {entry_number:6, base_addr:0xb6a7ab70, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}, child_tidptr=0xb6a7abd8) = 852
@chjj
chjj / gist:2695383
Created May 14, 2012 18:03
winston changelog

Winston Changelog

From v0.5.11 to query_stream.

  • Some transports have been altered in the way the log objects themselves are transported. Any code that relies on a log object's property names for a particular transport may need to be changed.
    commits:
    • 7bfd5b8483ad2f71ac8d3f350608b506dc0dc208
  • 979193c2ef2857d99dd2852c3d5432438a268b4d