Skip to content

Instantly share code, notes, and snippets.

View joonty's full-sized avatar

Jonathan Cairns joonty

View GitHub Profile
@joonty
joonty / client-7.1.0.patch
Last active July 4, 2020 13:45
Patch for client.py, part of the Komodo Python remote debugger. Fixes an exception being raised when "eval" is used, for versions 7.1.0 and 8.5.0.
3249,3250c3249
< _eval_optlist = [['i','transaction_id', int, 1, -1, None],
< ['l','length', int, 1, 0, None]]
---
> _eval_optlist = [['i','transaction_id', int, 1, -1, None]]
3252c3251
< (tid, data_length, data,) = self._getopts(cmdargs, self._eval_optlist, "eval")
---
> (tid, data,) = self._getopts(cmdargs, self._eval_optlist, "eval")
3268,3269c3267,3268
@joonty
joonty / vim-socket-server.py
Last active June 9, 2020 15:04
A vim-friendly, thread and queue based socket server written in python
import sys
import socket
import select
import Queue
import threading
import time
class EchoServer(threading.Thread):
def __init__(self, host, port, message_queue, output_queue):
self.__message_queue = message_queue
@joonty
joonty / .tmux.conf
Created May 15, 2014 09:57
My tmux config
set -g history-limit 5000
set-window-option -g utf8 on # utf8 support
# Open man page in new window
bind / command-prompt "split-window 'exec man %%'"
bind y run-shell "tmux show-buffer | xclip -sel clip -i" \; display-message "Copied tmux buffer to system clipboard"
set -g update-environment -r
# quick view of processes
bind '~' split-window "exec htop"
@joonty
joonty / context.patch
Created August 14, 2012 08:37
Patch for context get in RDBGP, part of the Komodo Ruby remote debugger tool. Fixes a problem getting non-local variables.
43a44
> processor.logger.debug("Adjusted stack depth: " + stackDepth.to_s)
88c89,93
< val = eval(name, the_binding)
---
> s_name = name.inspect
> if s_name[0] == ":"
> s_name = s_name[1..-1]
> end
> val = eval(s_name, the_binding)
describe "an example spec" do
context "greeting" do
def greeting
"hello"
end
it "should be 'hello'" do
expect(greeting).to eq "hello"
end
end
@joonty
joonty / sort.php
Created October 17, 2013 10:50
PHP sorting algorithm
<?php
$input = file("php://stdin");
sort($input);
file_put_contents(end($argv), join($input));
@joonty
joonty / threaded-vim-server.py
Created October 7, 2013 15:11
Background thread based socket server for vim
import sys
import socket
import select
import Queue
import threading
import time
import vim
import os
class LogError(Exception):
@joonty
joonty / each_with_object.rb
Last active December 22, 2015 08:58
Strange behaviour of array concatenation and each_with_object
def flatten_keys(hsh, keys)
keys.each_with_object([]) { |k, result|
result += hsh[k]
}
end
def flatten_keys_each(hsh, keys)
result = []
keys.each { |k|
result += hsh[k]
@joonty
joonty / php-xdebug
Created August 14, 2013 11:47
Xdebug php wrapper
#!/bin/bash
export XDEBUG_CONFIG="idekey=xdebug"
/usr/bin/php "$@"
@joonty
joonty / word_game.rb
Created July 30, 2013 13:28
Word game IRC bot, as a Cinch plugin
require 'cinch'
class Cinch::Plugins::WordGame
include Cinch::Plugin
match(/word start/, method: :start)
def start(m)
@word = DictionaryWord.new("/etc/dictionaries-common/words")
@guesses = 0
m.reply "Starting a new word game. Make a guess."