Skip to content

Instantly share code, notes, and snippets.

View zserge's full-sized avatar

Serge Zaitsev zserge

View GitHub Profile
#!/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
@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;
@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);
}
}
@zserge
zserge / favicon.ico
Last active January 27, 2018 12:17
GIF recorder
/*
* 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 / 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 / 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({
//
// 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"
//
// 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"
gridLayout()
space()
foregroundLinearLayout()
navigationMenuItemView()
navigationMenuView()
scrimInsetsFrameLayout()
appBarLayout()
collapsingToolbarLayout()
coordinatorLayout()