Skip to content

Instantly share code, notes, and snippets.

@abbot
abbot / App.java
Created December 4, 2013 16:03
fake data for sesame bug
package fd;
import java.io.Console;
import java.util.ArrayList;
import java.util.Calendar;
import org.openrdf.model.impl.StatementImpl;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.query.QueryLanguage;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.http.HTTPRepository;
@abbot
abbot / gist:7121187
Created October 23, 2013 15:47
open new terminal tab
if is_running("Terminal") then
tell application "System Events"
tell process "Terminal"
tell menu bar 1
tell menu "Shell" of menu bar item "Shell"
tell menu item "Linux" of menu "New Tab" of menu item "New Tab" to click
end tell
end tell
end tell
tell window 1 of application "Terminal" to activate
@abbot
abbot / httpd-dashboard.conf
Created April 17, 2012 16:48
Config files for puppet installation
<VirtualHost xxx.xxx.xxx.xxx:80>
RedirectMatch ^/dashboard$ https://myhost/dashboard/
RedirectMatch ^/dashboard/$ https://myhost/dashboard/
RedirectMatch ^/dashboard/(.*)$ https://myhost/dashboard/$1
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName myhost
DocumentRoot /var/www/html
RailsBaseURI /dashboard
@abbot
abbot / conf.ini
Created February 13, 2012 20:32
datefmt=%s example for python logging
[loggers]
keys = root
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
@abbot
abbot / gist:1261449
Created October 4, 2011 11:52
complex key lookup using k-d tree
from scipy.spatial import kdtree
import itertools
import random
import time
random.seed(1)
data = list(itertools.permutations(range(30), 4))
random.shuffle(data)
print "Data contains", len(data), "elements."
import subprocess
p = subprocess.Popen("cat", stdin=subprocess.PIPE, stdout=subprocess.PIPE)
chunk = 1024
count = 0
while True:
p.stdin.write("0" * chunk)
count += chunk
print count
@abbot
abbot / gist:954809
Created May 4, 2011 05:50
function call timings
import time
def f(x):
return x + 1
def z(x):
pass
def g(x):
z(x)
# -*- encoding: utf-8 -*-
import sys
__all__ = ['proc_stat']
_pstat_parts = [
('pid', int),
('comm', str),
('state', str),
@abbot
abbot / x.js
Created October 28, 2009 21:56
CmdUtils.makeSearchCommand({
names: ["yandex"],
icon: "http://www.yandex.ru/favicon.ico",
description: "Поиск в Yandex",
author: {name: "Lev Shamardin", email: "shamardin@gmail.com"},
url: "http://yandex.ru/yandsearch?text={QUERY}&lr=1",
preview: function(pblock, {object}) {
var searchTerm = object.text;
var template = "Поиск в yandex: <b>${query}</b>";
var data = {query: searchTerm};
import os, re, sys
r = re.compile(r'abc xyz = "(.*)"')
def matches(f):
return ['%s:%s' % (f, m.group(1)) for m in (r.match(l) for l in open(f, "r")) if m]
for fn in (fn for fn in os.listdir(len(sys.argv) > 1 and sys.argv[1] or '.') if os.path.isfile(fn)):
rc = matches(fn)
if rc: print "\n".join(rc)