Skip to content

Instantly share code, notes, and snippets.

View geon's full-sized avatar

Victor Widell geon

View GitHub Profile
@geon
geon / Main.asm
Created August 1, 2021 20:47
Modified version of the interrupt handling in https://www.youtube.com/watch?v=LpG9gqPtNLo
; 10 SYS (4096)
*=$0801
BYTE $0E, $08, $0A, $00, $9E, $20, $28, $34, $30, $39, $36, $29, $00, $00, $00
*=$1000
start
@geon
geon / async-iterator-server.ts
Created November 30, 2018 08:47
How to build a socket server with async and for-await.
import { createServer, Socket } from "net";
// Promisified socket.write().
const write = (socket: Socket, data: Buffer | string) =>
new Promise((resolve, reject) =>
socket.write(data as Buffer, (error: Error | undefined) => {
if (error) {
reject();
} else {
resolve();
@geon
geon / tsbug.ts
Last active November 20, 2017 14:50
console.log(myFunction());
const myConstant = "";
function myFunction(myArgument: string = myConstant): string {
return myArgument;
}
@geon
geon / demo.sql
Created June 1, 2017 12:37
pipelinedb event clustering
-- DROP SCHEMA public CASCADE;
-- CREATE SCHEMA public;
-- The bad measurements that should be clustered into errors.
CREATE STREAM bad_measurements ("measurement" REAL, "timestamp" TIMESTAMPTZ);
-- This is only useful because it create an output stream of deltas, important for clustering events.
@geon
geon / keyof.ts
Created December 8, 2016 12:13
Typed Backbone-style models with `keyof` in Typescript 2.1
class Model<T> {
props: T;
constructor(initial: T | void){
if (initial) {
this.props = initial;
}
}
set<K extends keyof T>(propName: K, value: T[K]) {
this.props[propName] = value;
@geon
geon / index.jade
Created February 5, 2016 21:46
Flexbox full-page web app layout with scrollable panels.
.full-screen.column
.header Header
.main.stretchy
.left Menu-stuff here
ul
li Menu Entry
li Menu Entry
li Menu Entry
li Menu Entry
li Menu Entry
@geon
geon / gist:e8b9e1125325e39c58b9
Created October 5, 2015 09:28
PipelineDB example
Data:
{"type":"add","uuid":"4b24edb2-5074-4a3a-95cb-927d5535da7c","topic":"clients","data":{"time":"2015-03-23T15:45:34.995Z"}}
{"type":"add","uuid":"26ff7bdb-9913-47ab-a6df-8c985320c1bb","topic":"clients","data":{"time":"2015-03-23T15:45:36.082Z"}}
{"type":"add","uuid":"914096b8-dc66-4239-bb1c-88baba0c1831","topic":"lines","data":{"time":"2015-03-23T15:45:40.323Z","clientId":"26ff7bdb-9913-47ab-a6df-8c985320c1bb","line":"Hello?"}}
{"type":"add","uuid":"bdb60b1e-b34b-490e-a737-0ceb81208f4e","topic":"lines","data":{"time":"2015-03-23T15:45:44.935Z","clientId":"4b24edb2-5074-4a3a-95cb-927d5535da7c","line":"What?"}}
{"type":"del","uuid":"4b24edb2-5074-4a3a-95cb-927d5535da7c","topic":"clients"}
{"type":"add","uuid":"f9aacc7e-1745-4a54-8e54-b9bea3cbc3bb","topic":"clients","data":{"time":"2015-03-23T15:45:59.800Z"}}
{"type":"add","uuid":"2c45cca3-cfa5-4ac2-bfec-12ca985d869b","topic":"lines","data":{"time":"2015-03-23T15:46:15.624Z","clientId":"f9aacc7e-1745-4a54-8e54-b9bea3cbc3bb","line":"Works finw"}}
{"type":"ad
@geon
geon / demo.sh
Created October 1, 2015 06:09
Command line tool to extract values from a JSON file.
echo '{"foo1":123, "foo":{"bar":[1,2,3]}}' | ./json.js foo.bar.2
@geon
geon / backbone.local-buffered.js
Created December 10, 2013 13:05
Experimenting with a LocalStorage buffer for backbone in case of dropped connection.
"use strict";
var LocalBuffered = {};
LocalBuffered.Model = Backbone.Model.extend({
constructor: function () {
Backbone.Model.apply(this, arguments);
<?php
$content = '
Text with newlines, possible XSS attacks and URLs.
<script type="text/javascript">alert("this could be an XSS attack.");</script>
The URL to my github page is https://github.com/geon.
';