Skip to content

Instantly share code, notes, and snippets.

View th-yoo's full-sized avatar

th-yoo

View GitHub Profile
@th-yoo
th-yoo / test.py
Created July 9, 2023 10:49
Bokeh with FastAPI
from __future__ import annotations
from pprint import pprint
from var_dump import var_dump
from fastapi import FastAPI, WebSocket, Request, HTTPException, WebSocketDisconnect
from fastapi.responses import HTMLResponse, PlainTextResponse
from fastapi.staticfiles import StaticFiles
app = FastAPI()
@th-yoo
th-yoo / test_undefined_offset_exception.php
Last active September 1, 2019 11:48 — forked from mmacia/test_undefined_offset_exception.php
How to catch an invalid array index offset as a native exception in PHP (RAII supported)
<?php
/**
* this class shows how to override default PHP handler to catch undefined index errors
* and throw it as native exceptions, much more convenient way to work with object
* oriented programs.
*
* @author Moisés Maciá <mmacia@gmail.com>
* @see http://codeup.net
*/
@th-yoo
th-yoo / stream_promise.js
Last active March 22, 2017 12:10
Promisify node stream
'use strict'
// (node -v) => 5.2.0
const stream = require('stream');
class StreamPromise {
constructor(stream) {
this._promises = [];
this._add(stream);
this._cur = stream;
@th-yoo
th-yoo / dumpbin.md
Created January 24, 2017 06:18
binary dumper functions

C

static void dumpbin( const void* beg, const void* end
		   , size_t stride)
{
	static const char n2a[]
	= { '0', '1', '2', '3', '4', '5', '6', '7'
	  , '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
	
	const unsigned char* cur = (const unsigned char*)beg;