Skip to content

Instantly share code, notes, and snippets.

@novocaine
novocaine / install_q3.sh
Last active May 29, 2020 14:50
Shell script to build and install Quake 3 Arena Demo using ioquake on OS X x86_64
#!/bin/bash
set -ex
mkdir q3a
cd q3a
# checkout and build for x86_64
git clone https://github.com/ioquake/ioq3
cd ioq3
### Keybase proof
I hereby claim:
* I am novocaine on github.
* I am jwsalter (https://keybase.io/jwsalter) on keybase.
* I have a public key ASDbvIbtNix_X1trzmyBl2loflAqd9dEKSuUOyG5_uxSgQo
To claim this, I am signing this object:
@novocaine
novocaine / gist:381835576664894019a8
Created June 29, 2015 10:33
lib2to3 fixer for changing division operator into div()
"""Fixer that replaces / with div() function"""
from ..fixer_base import BaseFix
from ..fixer_util import Call, Name, Node, Comma
class FixDivision(BaseFix):
PATTERN = "term< any+ '/' any+ >"
def transform(self, node, results):
@novocaine
novocaine / find_text_opens
Last active August 29, 2015 14:22
Using redbaron to find all open()s in text mode so we can review them for python 3
from redbaron import RedBaron
import os
import sys
import io
def is_bad_open(node):
# must be function invocation (not method invocation)
if node.parent.type != 'atomtrailers':
return False
@novocaine
novocaine / find_cmp_sorts
Created June 2, 2015 12:30
Using redbaron to find sort and sorted using cmp so we can convert them to key for python 3
from redbaron import RedBaron
import os
import sys
import io
def is_bad_sort(node):
# must be .method invocation
if node.parent.type != 'atomtrailers':
return False
test_BitSTring (tests.test_asn1.ASN1TestCase) ... ok
test_Integer (tests.test_asn1.ASN1TestCase) ... ok
test_Object (tests.test_asn1.ASN1TestCase) ... ok
test_String (tests.test_asn1.ASN1TestCase) ... DEBUG:__init__:data = None
DEBUG:__init__:data = None
@novocaine
novocaine / gist:09d5c00e67fd0aa13cfc
Last active August 29, 2015 14:14
fix libxml2 2.9.2 python 3 on windows
diff -ur libxml2-2.9.2.old/python/setup.py libxml2-2.9.2/python/setup.py
--- libxml2-2.9.2.old/python/setup.py 2014-10-16 09:35:22.000000000 +0100
+++ libxml2-2.9.2/python/setup.py 2015-01-22 12:23:18.804795900 +0000
@@ -123,7 +123,7 @@
with_xslt=0
if missing("libxslt-py.c") or missing("libxslt.py"):
- if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
+ if missing("xsltgenerator.py") or missing("libxslt-python-api.xml"):
print("libxslt stub generator not found, libxslt not built")
@novocaine
novocaine / gist:ae657bdbf0f25b81e52b
Last active August 29, 2015 14:14
patch libxslt 1.1.28 bindings to python 3 and fix on windows
diff -ur libxslt-1.1.28.old/libxslt/xsltlocale.h libxslt-1.1.28/libxslt/xsltlocale.h
--- libxslt-1.1.28.old/libxslt/xsltlocale.h 2012-09-04 16:26:24.000000000 +0100
+++ libxslt-1.1.28/libxslt/xsltlocale.h 2015-01-22 15:57:16.524757800 +0000
@@ -12,6 +12,7 @@
#define __XML_XSLTLOCALE_H__
#include <libxml/xmlstring.h>
+#include "xsltexports.h"
#ifdef XSLT_LOCALE_XLOCALE
@novocaine
novocaine / gist:5191558
Created March 18, 2013 22:44
decode content disposition header using utf8 for ios, which by default interprets the header as ASCII
- (NSString*)getFilenameFromContentDisposition:(NSString*)contentDisposition {
// filename is optionally quoted.
//
// note that if the disposition indicates the asterisk
// notation - filename*= - this indicates an explicit encoding;
// in that case we will drop through to just using the responses
// suggestedFilename (don't want to deal with the complexity,
// hopefully the system has reasonably behaviour when the
// encoding is actually unambiguous)
NSString* suggestedFilename = nil;
@novocaine
novocaine / TouchTimerWorkaround.js
Created December 6, 2012 05:00 — forked from jpattishall/TouchTimerWorkaround.js
setTimeout workaround for iPad and iOS6
/**
Workaround for iOS 6 setTimeout bug using requestAnimationFrame to simulate timers during Touch/Gesture-based events
Author: Jack Pattishall (jpattishall@gmail.com)
This code is free to use anywhere (MIT, etc.)
Usage: Pass TRUE as the final argument for setTimeout or setInterval.
Ex:
setTimeout(func, 1000) // uses native code
setTimeout(func, 1000, true) // uses workaround