Skip to content

Instantly share code, notes, and snippets.

View zserge's full-sized avatar

Serge Zaitsev zserge

View GitHub Profile
--
-- 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)
@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;
// ==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>
gridLayout()
space()
foregroundLinearLayout()
navigationMenuItemView()
navigationMenuView()
scrimInsetsFrameLayout()
appBarLayout()
collapsingToolbarLayout()
coordinatorLayout()
//
// A simple SCTP echo client to demonstrate wrapping low-level socket file descriptor into a net.Conn.
// Should work fine on linux, darwin, freebsd, dragonfly and solaris (where syscalls are available for SCTP sockets).
//
package main
import (
"errors"
"fmt"