Skip to content

Instantly share code, notes, and snippets.

View zserge's full-sized avatar

Serge Zaitsev zserge

View GitHub Profile
// ==UserScript==
// @match http://developer.android.com/*
// ==/UserScript==
var elem = document.getElementById('search-container');
document.addEventListener("keypress", function(e) {
if (e.which == 47) { // '/', like in vim
if (document.createEvent) {
var ev = document.createEvent('MouseEvents');
diff --git a/lposix.c b/lposix.c
index 03dcbe8..e0bd25c 100644
--- a/lposix.c
+++ b/lposix.c
@@ -34,6 +34,8 @@
#include <time.h>
#include <unistd.h>
#include <utime.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
@zserge
zserge / chain.js
Created October 17, 2013 09:04
Extemely minimalistic implementation of promises/futures
function chain(callback) {
var queue = [];
function _next() {
var cb = queue.shift();
if (cb) {
cb(_next);
}
}
--
-- Let you write code like
-- chain(func1):next(func2):next(func3):go()
--
function chain(cb)
local queue = {}
local n, go;
go = function()
local cb = table.remove(queue, 1)
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@zserge
zserge / B.java
Created October 5, 2014 15:04
Tiny benchmark class
/** A tiny benchmark class */
public static class B {
private int count = 0;
private long start;
private long end;
private long min = Long.MAX_VALUE;
private long max;
private String label;
package trikita.anvil.demo;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Spinner;
package trikita.anvil.demo;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Spinner;
@zserge
zserge / encoding_test.go
Created May 2, 2015 14:12
Benchmarks for various encodings (Gob is the fastest, obviously, JSON is ~4 times slower, CSV is ~10 times slower)
package main
import (
"bytes"
"encoding/csv"
"encoding/gob"
"encoding/json"
"math/rand"
"testing"
)
@zserge
zserge / MainActivity.java
Created July 28, 2015 13:01
Simple camera example
package com.example.anvil.empty;
import android.app.Activity;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.FrameLayout;