Skip to content

Instantly share code, notes, and snippets.

@vmx
vmx / initial_index.escript
Last active August 29, 2015 14:04
Performing the same actions as the Couchbase view engine updater does
#!/usr/bin/env escript
% This script can be run from any directory with write permission.
% You need to set the ERL_LIBS environment variable to the location of the
% installed erlang apps. For example:
% ERL_LIBS=/opt/couchbase/lib/couchdb/erlang/lib PATH=$PATH:/opt/couchbase/bin escript initial_index.escript
-define(UPR_PORT, "11209").
%-define(UPR_PORT, "12000").
@vmx
vmx / beerdb2json.py
Created August 21, 2014 00:03
Convert the openbeerdb from CSV into the JSON format Couchbase uses
#!/usr/bin/env python3
from collections import OrderedDict
import csv
import json
import re
import sys
import unicodedata
#!/bin/sh
scanimage --resolution 300 --mode Gray --format=tiff --custom-gamma=yes --custom-gamma=yes --gamma-table [0]0-[165]65535,[165]65535-[255]65535 --buffer-size=128 > output.tiff
@vmx
vmx / disable-trackstick.md
Created June 24, 2015 09:17
How to disable a trackpoint/trackstick/pointing stick in xorg
$ xinput list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS DualPoint TouchPad        	id=11	[slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS DualPoint Stick             id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
@vmx
vmx / fbsonmapfun.cc
Created September 24, 2015 14:04
Extracting a single field out of some data using FBSON and Subdoc
#include <sys/time.h>
#include <fstream>
#include <vector>
#include "fbson/FbsonJsonParser.h"
// From http://stackoverflow.com/a/1861493/935109
typedef unsigned long long timestamp_t;
static timestamp_t get_timestamp ()
@vmx
vmx / traverseviews.erl
Last active October 6, 2015 10:08
Traversing Couchbase view files in some hacky way
% Traversing view btrees
% Compile with:
%
% ERL_LIBS=<path-to-your-couchbase-source>/install/lib/couchdb/erlang/lib erlc
%
% Run with:
%
% ERL_LIBS=<path-to-your-couchbase-source>/install/lib/couchdb/erlang/lib erl -s traverseviews -noshell -s init stop
%
-module(traverseviews).
@vmx
vmx / gen_server_msg.erl
Created January 19, 2016 09:19
Receiving messages in gen_server
-behaviour(gen_server).
-export([start/0, msg/1, msg_recv/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
start() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
msg(Msg) ->
@vmx
vmx / couchbase_dump_vbucket.py
Last active March 23, 2016 04:54
Dump the contents of a Couchbase vBucket into a directory where the keys are the filenames
#!/usr/bin/env python2
# Dump the contents of a vbucket file into a directory of the same name. The
# keys are the filenames, the value the file contents
import os
import sys
import couchstore
@vmx
vmx / README.md
Last active April 26, 2016 07:59
Saner file paths on multi-configuration jobs in Jenkins

Configuration

Under "Advanced Project Options" set "Use custom workspace" to:

workspace/${JOB_NAME_SIMPLE}-${GERRIT_BRANCH}${EXECUTOR_NUMBER}

Add the Groovie script under "Prepare an environment for the run" to "Evaluated Groovy script".

@vmx
vmx / update_systemui.sh
Last active October 14, 2016 09:02 — forked from romanbb/gist:8011102
compile, push, and start SystemUI.apk
#!/bin/bash
# Works for me on Android 7.0 (Nougat)
# You might need to edit `frameworks/base/packages/SystemUI/Android.mk` and add
# `LOCAL_JACK_FLAGS := --multi-dex native` to the `SYSTEM_UI_INCREMENTAL_BUILDS`
# case
. build/envsetup.sh
SYSTEM_UI_INCREMENTAL_BUILDS=true make -j 4
adb start-server
adb shell pkill -TERM -f com.android.systemui
adb remount