Skip to content

Instantly share code, notes, and snippets.

View dmundt's full-sized avatar

Daniel Mundt dmundt

  • STRABAG Infrastructure & Safety Solutions GmbH
  • Germany, Berlin
View GitHub Profile
@dmundt
dmundt / upgrade-debian-wsl.md
Created June 16, 2023 11:29 — forked from bramtechs/upgrade-debian-wsl.md
Upgrade Debian 9, (current WSL) to Debian 12 (bookworm testing)

Upgrade Debian 9 (current WSL) to Debian 12 (bookworm testing)

As of writing, the Debian distro for WSL (Windows Subsystem for Linux) is quite old.

You can get more up-to-date package managers, text-editors and compilers by upgrading WSL to Debian 12 (current testing).

  • Root required
  • Use at your own risk, preferably on a fresh installation.
  • Choose 'yes' when Debian requests to restart services.
@dmundt
dmundt / template-fragments.go
Created May 3, 2023 17:27 — forked from benpate/template-fragments.go
Demonstration of Template Fragments using the standard Go template library
package main
import (
"html/template"
"net/http"
"strconv"
)
/***********************
This is a simple demonstration of how to use the built-in template package in Go to implement
@dmundt
dmundt / end
Last active September 8, 2021 00:14
Cura G-Code
M104 S0 ;Extruder heater off
M140 S0 ;Heated bed heater off (if you have it)
G91 ;Relative positioning
G1 E-1 F300 ;Retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;Move Z up a bit and retract filament even more
G28 X0 Y0 ;Move X/Y to min endstops, so the head is out of the way
M84 ;Steppers off
G90 ;Absolute positioning
;Put printing message on LCD screen
M117 Stopped printing...
@dmundt
dmundt / go.mod
Last active January 23, 2020 10:46
Go: diffpatchmerge example usage
module example.com/m
go 1.13
require github.com/sergi/go-diff v1.1.0
@dmundt
dmundt / SVGSamples.dart
Created February 1, 2013 09:43 — forked from ltackmann/SVGSamples.dart
Dart: SVG Sample
#import('dart:html');
class SVGSamples {
void run() {
drawlines();
}
void drawlines() {
final int maxY = 250;
@dmundt
dmundt / gist:4563185
Created January 18, 2013 08:37
C: Create semi-open interval [min, max).
// Create semi-open interval [min, max).
int random_in_range(unsigned int min, unsigned int max) {
int base_random = ::rand(); // in [0, RAND_MAX]
if (RAND_MAX == base_random) {
return random_in_range(min, max);
}
// Now guaranteed to be in [0, RAND_MAX).
int range = max - min;
int remainder = RAND_MAX % range;
@dmundt
dmundt / file_test.dart
Created November 14, 2012 13:11
Dart: Sequential file write/delete operations
import 'dart:io';
Future<int> saveDelete(int i) {
var completer = new Completer();
var path = new Path.fromNative(r'D:\test.txt');
var file = new File.fromPath(path);
var outputStream = file.openOutputStream();
if (outputStream.writeString('Hello World!')) {
outputStream.close();
} else {
@dmundt
dmundt / isolate_wrapper.dart
Created November 5, 2012 15:57
Dart: Isolate Wrapper
import 'dart:isolate';
import 'dart:mirrors';
class IsolateWrapper {
SendPort _sender;
IsolateWrapper(this._sender);
// noSuchMethod(name, args){
// return _sender.call([name, args]);
// }
@dmundt
dmundt / IsolateWrapper.dart
Created November 1, 2012 13:16
Dart: From Ports to Objects
// Taken from [Dart Today and Beyond (Gilad Bracha/Google)](http://www.dartlang.org/slides/2012/10/html5devconf/dart-today-and-beyond.pdf) (slide 34)
class IsolateWrapper {
SendPort _sendPort;
IsolateWrapper(this._sendPort);
noSuchMethod(name, args){
return _sendPort.call([name, args]);
}
}
@dmundt
dmundt / dart_strategy_01.dart
Created October 31, 2012 21:03
Dart: Strategy pattern in Dart
// Strategy pattern in Dart with abstract base class.
abstract class Renderer {
static const TEXT = const TextRenderer('text');
static const HTML = const HtmlRenderer('html');
static const JSON = const JsonRenderer('json');
final String name;
const Renderer._internal(this.name);
void render();
}