Skip to content

Instantly share code, notes, and snippets.

View Leonidas-from-XIV's full-sized avatar

Marek Kubica Leonidas-from-XIV

View GitHub Profile
@Leonidas-from-XIV
Leonidas-from-XIV / xchat-irc-encoding-send-utf8.patch
Created June 11, 2011 11:53
XChat sends in IRC/hybrid setting a mix of CP1252 and UTF-8. Make that UTF-8
--- src/common/server.c.old 2011-06-11 13:42:31.126537883 +0200
+++ src/common/server.c 2011-06-11 13:43:14.559870355 +0200
@@ -115,7 +115,7 @@
}
} else
{
- if (using_irc) /* using "IRC" encoding (CP1252/UTF-8 hybrid) */
+ if (0) /* using "IRC" encoding (CP1252/UTF-8 hybrid) */
/* if all chars fit inside CP1252, use that. Otherwise this
returns NULL and we send UTF-8. */
@Leonidas-from-XIV
Leonidas-from-XIV / gist:1407462
Created November 30, 2011 01:02
Python API equivalences in Clojure

Python API equivalences in Clojure

I tend to write rather functional code in Python so when I switch to Clojure I don't have to learn lots of things. Yet I often forget how to express some concepts in Clojure.

Infinite sequences

itertools.count(0) becomes (iterate inc 0)

@Leonidas-from-XIV
Leonidas-from-XIV / dummyimage.py
Created February 7, 2012 09:37
Generator for random JPEG images
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from itertools import izip
from datetime import datetime
from PIL import Image
from numpy.random import randint
x, y = 2560, 1920
@Leonidas-from-XIV
Leonidas-from-XIV / MainWindow.glade
Created March 7, 2012 11:52 — forked from sh4nks/MainWindow.glade
Text in einem TextBuffer einfügen
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="MainWindow">
<property name="can_focus">False</property>
<property name="has_resize_grip">False</property>
<signal name="destroy" handler="on_window_destroy" swapped="no"/>
<child>
<object class="GtkBox" id="vbox">
<property name="width_request">400</property>
@Leonidas-from-XIV
Leonidas-from-XIV / pixbuf-memory.py
Created March 11, 2012 07:27
Loading from memory does not work quite right.
#!/usr/bin/env python3
import base64
from gi.repository import Gtk as gtk
from gi.repository import GdkPixbuf as gdk_pixbuf
from gi.repository import Gio as gio
PYTHON_AT_WORK_48 = b"""
R0lGODlhMAAwAPcAADladTldfE9PT19fX0NjfFVsfmRkZG5ubXRwbWNtdnNz
c3t4dXR3eXx8fP+7G/+9I//DJP/EK//KLf/FMv/LNP/FPv/OOv/SNf/TPYWB
@Leonidas-from-XIV
Leonidas-from-XIV / gist:2029935
Created March 13, 2012 17:03
NPM, a maven-like maze
npm http GET https://registry.npmjs.org/jsdom
npm http GET https://registry.npmjs.org/zap
npm http GET https://registry.npmjs.org/docco
npm http GET https://registry.npmjs.org/coffee-script
npm http 200 https://registry.npmjs.org/zap
npm http GET https://registry.npmjs.org/zap/-/zap-0.2.4-1.tgz
npm http 200 https://registry.npmjs.org/docco
npm http GET https://registry.npmjs.org/docco/-/docco-0.3.0.tgz
npm http 200 https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script/-/coffee-script-1.2.0.tgz
@Leonidas-from-XIV
Leonidas-from-XIV / gist:2782333
Created May 24, 2012 15:48
Testing speed in 10k string records
import string, random
l = [''.join(random.choice(string.printable) for i in xrange(20)) for e in xrange(10000)]
print [e for e in l if "dbe" in e]
@Leonidas-from-XIV
Leonidas-from-XIV / hello.S
Created September 30, 2012 12:25
First steps in ARM assembler on Raspberry Pi
# switch to a nicer syntax
.syntax unified
# declare main as exportable (public)
.global main
# our main "function"
main:
# push return address (lr) and ip on the stack
push {ip, lr}
@Leonidas-from-XIV
Leonidas-from-XIV / gist:4226752
Created December 6, 2012 18:19
Io binary in Fedora 17
% rlwrap io
Io 20080120
Io> Range
==> Range_0x912e7d0:
first = Range_first()
foreach = Range_foreach()
index = Range_index()
last = Range_last()
next = Range_next()
previous = Range_previous()
OperatorTable addAssignOperator(":", "atPutNumber")
curlyBrackets := method(
r := Map clone
call message arguments foreach(arg,
r doMessage(arg))
r)
Map atPutNumber := method(
self atPut(
call evalArgAt(0) asMutable removePrefix("\"") removeSuffix("\""),