Skip to content

Instantly share code, notes, and snippets.

View jkp's full-sized avatar

Jamie Kirkpatrick jkp

View GitHub Profile
@jkp
jkp / cmake.rb
Created January 30, 2012 09:01
Homebrew formula for my branch of Cmake with Ninja build fixes
require 'formula'
class NoExpatFramework < Requirement
def message; <<-EOS.undent
Detected /Library/Frameworks/expat.framework
This will be picked up by CMake's build system and likely cause the
build to fail, trying to link to a 32-bit version of expat.
You may need to move this file out of the way to compile CMake.
@jkp
jkp / websocketserver.py
Created July 18, 2012 13:28
A simple WebSockets server with no dependencies
import struct
import SocketServer
from base64 import b64encode
from hashlib import sha1
from mimetools import Message
from StringIO import StringIO
class WebSocketsHandler(SocketServer.StreamRequestHandler):
magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
@jkp
jkp / bookmarklet.js
Last active June 25, 2023 14:46
Text-to-speech Bookmarklet
(function() {
var script = document.createElement('script');
script.setAttribute('src', 'https://bit.ly/426oCvn');
script.onload = function() {
textToSpeech('YOURKEYHERE', getRandomVoice());
};
document.body.appendChild(script);
})();
@jkp
jkp / readability-no-init.js
Created April 8, 2021 20:42
Readability Javascript without auto initialization
/*jslint undef: true, nomen: true, eqeqeq: true, plusplus: true, newcap: true, immed: true, browser: true, devel: true, passfail: false */
/*global window: false, readConvertLinksToFootnotes: false, readStyle: false, readSize: false, readMargin: false, Typekit: false, ActiveXObject: false */
var dbg = (typeof console !== 'undefined') ? function(s) {
console.log("Readability: " + s);
} : function() {};
/*
* Readability. An Arc90 Lab Experiment.
* Website: http://lab.arc90.com/experiments/readability
@jkp
jkp / qt5-base.rb
Created February 26, 2012 22:02
Formula to build a minimal qt5 base installation.
require 'formula'
require 'hardware'
class Qt5Base < Formula
homepage 'http://qt.nokia.com/'
head 'git://gitorious.org/qt/qtbase.git', :tag => 'e34ee3127043773a037bfd18a2d457d409032ee5'
keg_only 'For development purposes only'
def patches
@jkp
jkp / readme.md
Created February 18, 2013 12:30 — forked from jlewin/readme.md
Refork your own Gists!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Search</key>
<dict>
<key>Spotify-Albums</key>
<dict>
<key>Identifier</key>
<string>com.spotify.search.albums</string>
@jkp
jkp / gist:2284716
Created April 2, 2012 16:15 — forked from ahankinson/gist:1426301
Boost Python error "No to_python (by-value) converter found..."
I'm posting this here because I had a maddening search for information about why this error occurs when trying to do certain tasks in a Boost Python binding to a C++ object:
TypeError: No to_python (by-value) converter found for C++ type: Element*
This was when trying to iterate over a vector, defined as:
typedef std::vector<Element*> ElementList;
It turns out that in your `class_<>` definitions you have to be pretty specific. I already had:
from sniffer.api import *
import os, termstyle
import subprocess
# you can customize the pass/fail colors like this
pass_fg_color = termstyle.green
pass_bg_color = termstyle.bg_default
fail_fg_color = termstyle.red
fail_bg_color = termstyle.bg_default
@jkp
jkp / patch
Created February 25, 2012 11:20
Patch to fix QT compilation with clang - http://bit.ly/yyg5Ch
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
index d831e27..fac5054 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h
+++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
@@ -215,7 +215,7 @@ inline QString qt_mac_NSStringToQString(const NSString *nsstr)
{ return QCFString::toQString(reinterpret_cast<const CFStringRef>(nsstr)); }
inline NSString *qt_mac_QStringToNSString(const QString &qstr)
-{ return [reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr)) autorelease]; }
+{ return [const_cast<NSString*>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr))) autorelease]; }