Skip to content

Instantly share code, notes, and snippets.

# This isn't meant to be ran as a script, but line-by-line
# Props to Binary (benary.org) for helping me with this
# Amended for ubuntu 18
# 0: Create a Scaleway instance and SSH into it
ssh root@...
# 0: Install sudo
apt install sudo
@MelleB
MelleB / dragbehavior.js
Last active September 8, 2016 08:46
Choo drag behavior
const initialState = () => ({
dragging: false,
moveAction: null,
moveData: null,
releaseAction: null,
releaseData: null,
offsetX: 0,
offsetY: 0,
parentOffsetX: 0,
@MelleB
MelleB / child-model.js
Created September 5, 2016 13:47
Hierarchical models with Choo
// Note: Child model is NOT registered with choo.model()
const model = {
state: {
name: '',
x: 0,
y: 0,
width: 0,
height: 0,
},
@MelleB
MelleB / app.ts
Last active September 3, 2016 05:41
import { run } from '@cycle/xstream-run';
import xs, { Stream } from 'xstream';
import { DOMSource } from "@cycle/dom/xstream-typings";
import { makeDOMDriver, div, input, p, VNode } from '@cycle/dom';
import Sidebar from './components/sidebar';
export class UIState {
public selectedTool: string;
@MelleB
MelleB / app.ts
Last active August 30, 2016 10:15
import xs from 'xstream';
import {run} from '@cycle/xstream-run';
import {makeDOMDriver, h1} from '@cycle/dom';
function main(sources: any) {
const sinks = {
DOM: xs.periodic(1000).map(i =>
h1('' + i + ' seconds elapsed'))
};
@MelleB
MelleB / test.rst
Last active May 21, 2016 20:00
Testing GitHub's reStructuredText features:

This is a title

Warning

This is a warning!

Note

This is a note!

WARNING

This is a warning

WARNING

This is a warning

@MelleB
MelleB / python-mode-ext.el
Last active May 19, 2016 09:15
Change background color of python class and function definitions in Emacs
(font-lock-add-keywords 'python-mode
'(("^\s*\\(def\s*\\)\\(.*\\)\\((.*):.*\xa\\)"
(1 '(:inherit 'font-lock-keyword-face :background "#F3F3F3"))
(2 '(:inherit 'font-lock-function-name-face :background "#F3F3F3" :weight bold))
(3 '(:background "#F3F3F3"))
)
("^\s*\\(class\s*\\)\\(.*\\)\\((.*):.*\xa\\)"
(1 '(:inherit 'font-lock-keyword-face :background "#EEEEEE" :height 1.4))
(2 '(:inherit 'font-lock-function-name-face :background "#EEEEEE" :height 1.4 :weight bold))
(3 '(:background "#EEEEEE" :height 1.4))
@MelleB
MelleB / event.py
Created April 30, 2016 20:22
A simple global event emitter in Python
_callbacks = {}
class Event():
@staticmethod
def on(event_name, f):
_callbacks[event_name] = _callbacks.get(event_name, []) + [f]
return f
@MelleB
MelleB / Kivy Aligned TextInput
Last active February 2, 2021 11:34
Kivy Aligned Text Input - halign + valign for TextInput
Note: This just aligns the position of the textblock, not the text itself.