Skip to content

Instantly share code, notes, and snippets.

View kragen's full-sized avatar

Kragen Javier Sitaker kragen

View GitHub Profile

Here's an excerpt from xev output from me typing "¤xo", which is to say, Compose x o x o. What you can see from this:

  1. The keystrokes eaten by the Compose key still appear as KeyPress and KeyRelease events. They just have XFilterEvent=True on the KeyPress events. The other keystrokes (and the KeyRelease events) have XFilterEvent=False.
  2. The ¤ character is injected as a fake KeyPress, with keycode 0 and a keysym corresponding to the actual Unicode code point. I tried ☺ later; the corresponding keysym is keysym 0x100263a, U263A.
  3. I believe that all of this compose-key hackery is being done by Xlib, not by the X server, because you have to start a new X client in order to get it to notice changes to .XCompose.
PropertyNotify event, serial 30, synthetic NO, window 0x6800001,
    atom 0x19d (_NET_WM_ICON_GEOMETRY), time 1774437600, state PropertyNewValue
# Simplified CoffeeScript version of voting code from
# <http://www.cap-lore.com/CapTheory/Language/lambdaSecurity.html>:
# simplified from <https://gist.github.com/3429195>.
counter = ->
x = 0
voterMaker: ->
yet = true
-> if yet
yet = false
@kragen
kragen / lunchvoting.coffee
Created August 22, 2012 20:43
A CoffeeScript and corrected version of https://gist.github.com/3428922.
# CoffeeScript version of voting code from
# <http://www.cap-lore.com/CapTheory/Language/lambdaSecurity.html>:
mocntr = ->
x = 0
voterMaker: ->
yet = true
-> if yet
yet = false
++x
// Original code in Scheme, from
// <http://www.cap-lore.com/CapTheory/Language/lambdaSecurity.html>:
//
// (define (mocntr) (let ((x 0)) (cons (lambda () (let ((yet #t))
// (lambda () (if yet (begin (set! yet #f) (set! x (+ 1 x)) x)))))
// (lambda () x))))
// (define restaurants (list "Mandarin" "Casa Lupe" "Coffee Shop"))
// (define (noontime) (let ((bb
// (map (lambda(r) (cons r (mocntr))) restaurants)))
// (for-each (lambda (e) ((cdr e) (cons "Lunchtime!" (map
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""A DSL for making paths of interesting shapes.
Nick Johnson and Kragen Javier Sitaker
<https://gist.github.com/2555227>
"""
import math
info g++
kragen@inexorable:~$
kragen@inexorable:~$
kragen@inexorable:~$ g++ -std=c++0x test.cc
kragen@inexorable:~$ php
<?
print 3 || 4;
?>
1kragen@inexorable:~$
kragen@inexorable:~$ php
(* Backtracking templates. See
<http://lists.canonical.org/pipermail/kragen-tol/2012-April/000951.html>
for more details.
This version doesn’t yet implement template parsing or a reasonable
way to feed in template parameters (e.g. JSON).
I decided to do this entirely with polymorphic variants to familiarize
myself with them, and without any type declarations, but I did cheat a
little bit: in one place I use an ordinary list instead of faking one
#!/usr/bin/python
"Very simple rotating cube in ASCII art."
import sys, time
w, h, out = 80, 24, sys.stdout
cube = [(x, y, z) for x in -1, 1 for y in -1, 1 for z in -1, 1]
s = 0.1 # sine
c = (1 - s**2)**0.5 # cosine
ym = h/3 # Y magnification
xm = 2*ym # X magnification
En http://pad.telecomix.org/kipfajub
También en https://gist.github.com/2210789
# Para compilar node.js (voy a anotar el porque de cada comando despues)
tar xzvf node-v0.6.14.tar.gz # extraer archivo: z para gzip, v para verbose, f para file
cd node-v0.6.14/
./configure # se quejó que no había compilador de c++
sudo apt-get install g++ # g++ es el compilador c++ de GNU
./configure # ahora tiene más éxito pero se cuelga en falta de openssl
apt-cache show nodejs # pero no se sabe de un "nodejs"
apt-cache show node # ni tampoco, porque tengo que agregar universe y multiverse
@kragen
kragen / clases.md
Created February 22, 2012 03:36 — forked from Diex/clases.md
Unix - La Navaja del Ejercito Suizo

Primer curso de Escuela Newton. Serán 8 clases sobre los conocimientos mínimos necesarios para poder trabajar cómodamente en cualquier sistema operativo de la familia Unix (en particular Linux - Ubuntu) Dictado por Javier Sitaker. 8 Clases. Comienza el 5 de Marzo de 2012. Mas info: [email protected]

Resumen Del Curso

Lamentablemente, un montón de nuestros sistemas actuales Unix están en otro mundo, diferente del de las interfaces de Web y GUI que usamos cotidianamente --- un mundo subterráneo debajo del iPhone, Android, Kindle, Mac, casi todos los servidores, y los desktops de software libre. Éste curso te abre las puertas a todo ésto.