Skip to content

Instantly share code, notes, and snippets.

View zserge's full-sized avatar

Serge Zaitsev zserge

View GitHub Profile
@zserge
zserge / usbhid.js
Created July 31, 2015 10:03
Espruino example
var on = false;
setInterval(function() {
on = !on;
LED1.write(on);
LED2.write(!on);
}, 500);
console.log('Hello, world!');
E.setUSBHID({
#!/bin/sh
BGCOLOR='#550000'
TEXTCOLOR='#eeeeee'
TEXTFONT='Ubuntu-Light'
TEXTSIZE=72
TEXT="\nHello this is a very long text\nwrapped in many lines"
# Put screenshot into a frame, change +86+242 if you change a frame PNG
composite -geometry +86+242 $1 frame.png $2
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"
//
// A simple echo server for SCTP sockets, it creates a socket with a syscall then wraps it into a net.Listener interface
// to make goroutine-safe (otherwise reading or writing would block the whole host thread).
// All it does is echoing back all the received data from the client.
//
package main
import (
"fmt"
//
// This is just a collection of syscalls that are used by libsctp linux implementation.
// Although it supports message-oriented workflow, it can't be wrapped into a net.PacketConn.
//
package main
import (
"log"
"syscall"
@zserge
zserge / MainActivity.java
Created February 21, 2017 11:32
Reproducing Anvil issue #83
package trikita.foo;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import trikita.anvil.RenderableView;
import static trikita.anvil.DSL.*;
@zserge
zserge / favicon.ico
Last active January 27, 2018 12:17
GIF recorder
autoload -U compinit colors vcs_info
colors
compinit
REPORTTIME=3
HISTFILE=~/.zhistory
HISTSIZE=5000
SAVEHIST=5000
setopt INC_APPEND_HISTORY
setopt EXTENDED_HISTORY
@zserge
zserge / act.js
Last active October 31, 2019 21:18
const h = (e, p = {}, ...c) => ({e, p, c: [].concat(...c)});
const render = (vlist, dom) => {
vlist = [].concat(vlist);
vlist.forEach((v, i) => {
let n = dom.childNodes[i];
let s = (v.s = (n ? n.s : v.s) || {});
while (typeof v.e === 'function') {
v = v.e(v.p, s, u => Object.assign(s, u) && render(vlist, dom));
}
v.s = s;