Skip to content

Instantly share code, notes, and snippets.

@tluyben
tluyben / Forth1.cs
Last active December 23, 2024 01:07
A minimal Forth implementation in C#
/*
* Minimal .NET Forth implementation. Just an experiment. Do not use for anything serious.
* by Tycho Luyben (https://github.com/tluyben)
*
* The only 'primitive' (built-in) is an foreign function interface word which allows you to define
* whatever is needed, for example:
*
* hello System.String System.Console.WriteLine ffi
*
* will print hello.
@tluyben
tluyben / cli.go
Created May 5, 2018 16:18
Calculate WIF from a private key
package main
import (
"fmt"
"os"
"encoding/hex"
"github.com/mr-tron/base58/base58"
)
func main() {
@tluyben
tluyben / background.cs
Last active November 30, 2017 18:56
Hangfire actions without all the serialization issues (won't survive server restart or multiple servers, but easier to make that work as well)
Random r = new Random();
static ConcurrentDictionary<int, Action> actions = new ConcurrentDictionary<int, Action>();
public static void ExecuteAction(int i)
{
Action a;
actions.Remove(i, out a);
a();
}
@tluyben
tluyben / Placeholder.cs
Created June 5, 2017 11:01
Placeholder Winforms
class InternalTextBox : MaskedTextBox
{
bool _PlaceholderHandled = false;
void DoPlaceholder()
{
if (Placeholder.Length > 0 && this.Text == string.Empty && this.Text != this.Placeholder)
{
@tluyben
tluyben / frmFlowChart.cs
Created April 28, 2017 04:16
Short how to use OpenDiagram Flowchart
Model model = diagram1.Model;
diagram1.Model.SetSize(new Size(1000, 1000));
Shape shape = new Shape();
shape.Location = new PointF(10, 20);
//model.Shapes.Add("a1", shape);
Flowchart f = (Flowchart)diagram1;
shape = f.AddFlowShape(shape.Location, FlowchartStencilType.Terminator);
shape.Label = new Label("kaas");
@tluyben
tluyben / XMLExtensions.cs
Created April 7, 2017 06:58
Handy XML extensions
using System;
using System.Xml;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace test1
{
public static class XMLExtensions
{
@tluyben
tluyben / mltocsv.pl
Created December 21, 2016 10:27
Getting out the emails from a email client list
#!/usr/bin/perl
@d = split(/\;/,`cat mailinglist.txt`);
print "Email\tFirst\tLast\n";
foreach(@d) {
chomp;
$s = $_;
$s =~ s/^\s+|\s+$//g;
if ($s=~/(.*?)\s*\((.*?)\)/igsm) {
$e = $2;
@tluyben
tluyben / gist:176281a23039f4b26b95ec63ddc1ac08
Created October 15, 2016 14:07
webmsx - stepping + slowing
var si = setInterval(function() {WMSX.room.machine.systemPause(false);WMSX.room.machine.videoClockPulse(); console.log(WMSX.room.machine.cpu.toString());WMSX.room.machine.systemPause(true);}, 200);
@tluyben
tluyben / FeatureContext.php
Last active October 17, 2015 09:41
FeatureContext.php for Behat + Laravel 5 testing, fixed/improved from https://github.com/philsturgeon/build-apis-you-wont-hate
<?php
use Behat\Behat\Context\ClosuredContextInterface;
use Behat\Behat\Context\TranslatedContextInterface;
use Behat\Behat\Context\Context;
use Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Illuminate\Routing\UrlGenerator;
use Behat\MinkExtension\Context\MinkContext;
@tluyben
tluyben / py2php.py
Last active September 10, 2015 07:16 — forked from reusee/py2php.py
Python to php translator, compile python script to php
import ast
from cStringIO import StringIO
import sys
INFSTR = '1e308'
def interleave(inter, f, seq):
seq = iter(seq)
try:
f(next(seq))