Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike barbeque

  • Calgary AB Canada
View GitHub Profile
@barbeque
barbeque / withblock.py
Created Mar 21, 2020
how to implement behaviour of 'with' blocks in python
View withblock.py
class Exiter():
def __enter__(self):
print('i am in a block')
return self # critical
def __exit__(self, type, value, tb):
print('goodbye cruel world')
def add(self, a, b):
return a + b
with Exiter() as exiter:
@barbeque
barbeque / D88STRUC.txt
Created Nov 18, 2018
d88 file structure
View D88STRUC.txt
D88 (D68/D77/D98) File Structure
JPN Translations (http://jpntrans.nobody.jp)
--------------------------------------------------
People Involved
--------------------------------------------------
Translation, editing, etc.: Tokugawa Corporate Forum's Ashura
Hosting: noname345
--------------------------------------------------
@barbeque
barbeque / gist:38127addfc43d1eab028d4a4ac3fbcd4
Created Nov 6, 2018
m88 linker errors - not too many right?
View gist:38127addfc43d1eab028d4a4ac3fbcd4
SuperMactendo:M88p2 mike$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o src/pc88/base src/pc88/base.o src/pc88/beep.o src/pc88/calender.o src/pc88/crtc.o src/pc88/diskmgr.o src/pc88/fdc.o src/pc88/fdu.o src/pc88/floppy.o src/pc88/intc.o src/pc88/ioview.o src/pc88/joypad.o src/pc88/kanjirom.o src/pc88/memory.o src/pc88/memview.o src/pc88/mouse.o src/pc88/opnif.o src/pc88/pc88.o src/pc88/pd8257.o src/pc88/pio.o src/pc88/screen.o src/pc88/sio.o src/pc88/sound.o src/pc88/subsys.o src/pc88/tapemgr.o
Undefined symbols for architecture x86_64:
"DeviceList::Add(IDevice*)", referenced from:
PC88::ConnectDevices() in pc88.o
"DeviceList::Find(unsigned int)", referenced from:
PC88::IsCDSupported() in pc88.o
@barbeque
barbeque / p88sr.doc
Created Oct 20, 2018
partially translated p88sr readme
View p88sr.doc
-------------------------
P88SR.EXE マニュアル
-------------------------
【概要】
PC8801mk-2SR( V2 MODE ,8 MHz ) の機能をエミュレートします。
View toolbox-helloworld.c
int main(void) {
WindowPtr TheWindow;
InitGraf(&thePort);
InitFonts();
InitWindows();
TheWindow = GetNewWindow(128, 0L, (WindowPtr)-1L);
SetPort(TheWindow);
MoveTo(30, 50);
DrawString("\pHello, World");
@barbeque
barbeque / hashtable.rkt
Created Jul 6, 2017
Racket Hashtable cheat sheet
View hashtable.rkt
> (define myhash #hasheq((name . "bob")))
> (hash-has-key? myhash `name)
#t
> (hash-ref myhash `name)
"bob"
View Counterparty Credit Risk Metrics
/* Expected exposure is the expected (average) credit exposure conditional on positive market values */
def expectedExposure(marketValues: Seq[Double]): Double = {
val exposures = marketValues.filter(_ > 0f)
if (exposures.size == 0) 0.0
else exposures.sum / exposures.size
}
/* A high percentile (95%) of the distribution of exposures at any particular future date. Also called Peak Exposure (PE) */
def potentialFutureExposure(marketValues: Seq[Double], confidenceLevel: Double): Double = {
val exposures = marketValues.filter(_ > 0)
@barbeque
barbeque / gist:07dbaf74f3cd70a731d3
Created Jul 11, 2015
SetSysClock called twice?
View gist:07dbaf74f3cd70a731d3
Breakpoint 6, SystemInit ()
at /Users/mike/Code/cross-compilers/STM32F0xx_StdPeriph_Lib_V1.5.0/Libraries/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.c:162
162 RCC->CR |= (uint32_t)0x00000001;
(gdb) step
160 {
(gdb) step
162 RCC->CR |= (uint32_t)0x00000001;
(gdb) step
166 RCC->CFGR &= (uint32_t)0xF8FFB80C;
(gdb) step
@barbeque
barbeque / gist:44a00a1bbaa02509b961
Created Mar 12, 2015
Defining custom object and passing it into powershell functions
View gist:44a00a1bbaa02509b961
function NewSteak() {
$steak = New-Object PSObject
$steak | Add-Member -type NoteProperty -Name Doneness -Value "Rare"
$steak | Add-Member -type NoteProperty -Name Juiciness -Value "Low"
return $steak
}
function AuditSteak([PSObject]$steak) {
@barbeque
barbeque / gist:4040723
Created Nov 8, 2012
Turning C# generic Type back into "C# Type" declaration style.
View gist:4040723
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Reflection;
namespace GenericCodeGenerator
{
class Program