Skip to content

Instantly share code, notes, and snippets.

Hello world

What about 249 huh?

Virtual tables

Virtual tables let you provide data on demand as a SQLite table so

#!/usr/bin/env python3
import apsw
class Example:
def connect(self):
while True:
dbname = "example.db"
connection = apsw.Connection(str(dbname))
connection.cursor().execute("PRAGMA journal_mode = WAL")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
#define CHECK \
do \
{ \
if (res != SQLITE_OK) \
File "src/thirdparty/whoosh/searching.py", line 786, in search
self.search_with_collector(q, c)
File "src/thirdparty/whoosh/searching.py", line 819, in search_with_collector
collector.run()
File "src/thirdparty/whoosh/collectors.py", line 143, in run
self.set_subsearcher(subsearcher, offset)
File "src/thirdparty/whoosh/collectors.py", line 919, in set_subsearcher
WrappingCollector.set_subsearcher(self, subsearcher, offset)
File "src/thirdparty/whoosh/collectors.py", line 621, in set_subsearcher
self.child.set_subsearcher(subsearcher, offset)
@rogerbinns
rogerbinns / gist:6237680
Created August 15, 2013 02:23
Fixing fixed navbar and anchors problem
(function() {
var waitTillJQuery=function() {
if(window.jQuery) {
var $=window.jQuery;
// make sure navbar is taken into account
var scrollToRightPlace=function() {
if($(".navbar-fixed-top").length) {
var navheight=$(".navbar-fixed-top").outerHeight(true);
var selector=window.location.hash;
if(!selector) return;
def add_concurrent_options(parser, prefer_threads=False):
# Adds relevant options to parser
parser.add_argument("--workers", choices=("threads", "processes"), default="threads" if prefer_threads else "processes",
help="Select if concurrency is done using threads or processes [%(default)s]")
parser.add_argument("--single", action="store_true", help="Uses a single thread for concurrency. This makes debugging a lot easier")
import multiprocessing
def get_concurrent_executor(options):
# Gets a suitable executor
if options.workers=="threads" or options.single:
@rogerbinns
rogerbinns / mongo_hacker.js
Created March 8, 2013 22:41
mongo hacker with display hook example
/*
*
* Mongo Hacker
* MongoDB Shell Enhancements for Hackers
*
* Tyler J. Brock - 2013
*
* http://tylerbrock.github.com/mongo-hacker
*
*/
@rogerbinns
rogerbinns / apsw shell.sql
Last active December 14, 2015 09:28
Dumps from SQLite
SQLite version 3.7.15.2 (APSW 3.7.15.2-r1)
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .dump
-- SQLite dump (by APSW 3.7.15.2-r1)
-- SQLite version 3.7.15.2
-- Date: Fri Mar 1 05:34:14 2013
-- Tables like: (All)
-- Database: /tmp/foo.db
-- User: rogerb @ workstation
@rogerbinns
rogerbinns / gist:3204034
Created July 30, 2012 03:30
Chaining install broadcast receivers
@Override
public void onReceive(Context context, Intent intent) {
// ensure all declared receivers can handle this intent
intent.setComponent(null);
// do what Market/Store/Finsky should have done in the
// first place
List l = context.getPackageManager()
.queryBroadcastReceivers(intent, 0);
for (ResolveInfo ri : l) {
ActivityInfo ai = ri.activityInfo;