Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -eu
_UID=$(id -u)
GID=$(id -g)
# give lxd permission to map your user/group id through
grep root:$_UID:1 /etc/subuid -qs || sudo usermod --add-subuids ${_UID}-${_UID} --add-subgids ${GID}-${GID} root
# set up a separate key to make sure we can log in automatically via ssh
# with $HOME mounted
@metainfa
metainfa / postgres-notify-trigger.sql
Created July 22, 2017 23:29 — forked from bithavoc/postgres-notify-trigger.sql
I used this trigger to notify table changes via NOTIFY (migrating off RethinkDB)
CREATE OR REPLACE FUNCTION notify_trigger() RETURNS trigger AS $$
DECLARE
channel_name varchar DEFAULT (TG_TABLE_NAME || '_changes');
BEGIN
IF TG_OP = 'INSERT' THEN
PERFORM pg_notify(channel_name, '{"id": "' || NEW.id || '"}');
RETURN NEW;
END IF;
IF TG_OP = 'DELETE' THEN
PERFORM pg_notify(channel_name, '{"id": "' || OLD.id || '"}');
@metainfa
metainfa / index.js
Created February 23, 2017 08:18 — forked from TylerK/index.js
React Router 4, React -> Preact for production, Async route-based code-splitting.
import React from 'react'
import { render } from 'react-dom';
import { Router, Route } from 'react-router-dom';
import LazyRoute from 'lazy-route';
const App = () => {
render() {
return (
<Router>
<Route
@metainfa
metainfa / high-dpi-canvas.html
Created January 14, 2017 15:47 — forked from Costava/high-dpi-canvas.html
HTML5 Canvas - Rendering of Text on High-DPI Screens
<html>
<head>
<script src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
</head>
<body>
<h2>Naive canvas</h2>
<canvas id="naive" width="400" height="50"></canvas>
<h2>High-def Canvas</h2>
@metainfa
metainfa / index.js
Created October 16, 2016 16:46 — forked from whiteinge/index.js
POC Node HTTP server for server-sent-events using RxJS
/**
Proof-of-concept server-sent events HTTP server using Node.js and RxJS
Open http://localhost:8000 in a browser and view the console.
**/
var http = require('http'),
https = require('https');
var Rx = require('rx');
import {Stream} from 'most'
const fromNodeCallBack = fn => (...args) => new Stream(new CallBackSource(fn, args))
class CallBackSource {
constructor (fn, args) {
this.fn = fn
this.args = args
}
❯ rollup --version
rollup version 0.25.3
❯ time rollup -c ./rollup.js
rollup -c ./rollup.js 4.65s user 0.22s system 118% cpu 4.131 total
❯ time webpack
Hash: ebb00bbccd954c114d3c
Version: webpack 2.0.7-beta
Time: 3623ms
@metainfa
metainfa / logout-indicator.py
Created June 7, 2016 19:32 — forked from bellbind/logout-indicator.py
[python][pygi][ubuntu]Logout indicator for ubuntu Unity
#!/usr/bin/python3
# Logout indicator for ubuntu Unity
# module of python3-gi (PyGI)
from gi.repository import GLib
from gi.repository import Gio
from gi.repository import Gtk
from gi.repository import AppIndicator3
def dbus_logout(w, arg):
@metainfa
metainfa / node_rfp.js
Created May 25, 2016 23:18 — forked from Istar-Eldritch/node_rfp.js
Reactive Functional Programming in NodeJS with Most.js
'use static';
const http = require('http');
const most = require('most');
const port = 3000;
const server = http.createServer();
most.fromEvent('listening', server).forEach(() => {
@metainfa
metainfa / TrueColour.md
Created May 22, 2016 18:29 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Colours in terminal

It's a common confusion about terminal colours... Actually we have this:

  • plain ascii
  • ansi escape codes (16 colour codes with bold/italic and background)
  • 256 colour palette (216 colours + 16 ansi + 24 gray) (colors are 24bit)
  • 24bit true colour ("888" colours (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"