Skip to content

Instantly share code, notes, and snippets.

@MrTrick
MrTrick / test_dompdf_1.2.0.php
Created February 15, 2022 09:58
#Reproducing an error in dompdf 1.2.0
<?php declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
$dompdf = new Dompdf\Dompdf();
$dompdf->loadHtml(<<<HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
@MrTrick
MrTrick / AppServiceProvider.php
Created February 4, 2021 16:04
Simple direct-injection of custom requests with validation rules.
<?php declare(strict_types=1);
namespace App\Providers;
use Illuminate\Contracts\Validation\ValidatesWhenResolved;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;
/**
* Class AppServiceProvider.
@MrTrick
MrTrick / M503
Created May 30, 2019 01:18
Melzi settings
M503
ok 0
EPR:2 75 115200 Baudrate
EPR:3 129 0.000 Filament printed [m]
EPR:2 125 0 Printer active [s]
EPR:2 79 0 Max. inactive time [ms,0=off]
EPR:2 83 360000 Stop stepper after inactivity [ms,0=off]
EPR:3 3 80.0000 X-axis steps per mm
EPR:3 7 80.0000 Y-axis steps per mm
EPR:3 11 405.4591 Z-axis steps per mm
@MrTrick
MrTrick / combined.hex
Last active February 5, 2019 23:28
Combining hex files
:200000005FCC7EC05FCC7CC077C47AC079C078C077C076C075C074C073C072C071C0076354
:200020004236B79BD8A71A39685618AEBAAB558C1D3CB7CC5763BD6DEDFD753EF61772314D
:20004000BF000000803F08000000BE922449123EABAAAA2ABECDCCCC4C3E00000080BEAB4E
:20006000AAAAAA3E00000000BF000000803F0000000000084178D3BB4387D1133D190E3C29
:20008000C3BD4282AD2B3E68EC8276BED98FE1A93E4C80EFFFBE01C4FF7F3F0000000000D2
:2000A0000102040810200101010101010036003800377C02830211241FBECFE5D2E0DEBF3E
:2000C000CDBF20E0A6E6B0E001C01D92AF38B207E1F710E0A0E6B0E0EEEFF4E102C0059081
:2000E0000D92A636B107D9F710E0C4EBD0E003C02297FE01C6D8C23BD107D1F71ED5F3C949
:200100007FCF8EE690E014D28EE690E07FD262E080E082D461E081E07FC4CF92DF92EF9262
:20012000FF92CF93DF936B017C01C0E0D0E08EE690E0CFD3C817D90740F4A7019601BE01AA
@MrTrick
MrTrick / opc_array.cs
Created February 29, 2012 22:52
Simple OPC DA Client to read/write arrays
//-----------------------------------------------------------------------------
// |
// Mindbleach Engineering, Australia |
// |
// Copyright (c) 2012 Mindbleach Engineering |
// All Rights Reserved |
// |
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// OPC DA Array Client |
Design a puzzle, consisting of:
• a small number (<10) of polyomino pieces of varied configurations, but the same unit size.
• a rectangular container of arbitrary height and width, ideally but not necessarily integral multiples of the polyomino unit size.
Having a single unique solution:
• where all pieces fit flat within the container.
• where all pieces are placed non-orthogonally wrt the container.
Ideally / Bonus Points
• Pieces are unique
@MrTrick
MrTrick / example_output.txt
Last active December 11, 2017 00:39
Secret santa permutor
EAS=>PRB, MP=>AS, R=>E, B=>M
EAS=>PRB, MP=>ES, R=>A, B=>M
EAS=>PRB, MP=>EA, R=>S, B=>M
EAS=>MPR, MP=>EA, R=>B, B=>S
EAS=>MPB, MP=>AR, R=>E, B=>S
EAS=>MPR, MP=>AB, R=>E, B=>S
EAS=>MRB, MP=>EA, R=>P, B=>S
EAS=>MPR, MP=>EB, R=>A, B=>S
EAS=>MPB, MP=>ER, R=>A, B=>S
EAS=>PRB, MP=>EA, R=>M, B=>S
var _=require('lodash');
/** Run the given from/to replace patterns on every reference in the given node **/
function translateRefs(node, from, to) {
if (node.$ref) node.$ref = node.$ref.replace(from, to);
else if (typeof node === 'object') for(var i in node) if (node.hasOwnProperty(i)) translateRefs(node[i], from, to);
}
function importSchema(file, name, root) {
var schema = _.cloneDeep(require(built_schemas+"/"+file)); //Import and copy the schema
translateRefs(schema, /^#\/definitions\//, "#/definitions/"+name+"-"); // Convert every internal reference to the new path
translateRefs(root, new RegExp("^"+file+"#/definitions/"), "#/definitions/"+name+"-"); // Convert every base reference to the new path
@MrTrick
MrTrick / gist:4110724
Created November 19, 2012 13:46
ATMEGA328P Timer2 notes - for setting up RTC tick source
PRTIM2 bit in ”Minimizing Power Consumption” on page 41 must be written to zero to enable Timer/Counter2
module.
Timer has storage registers;
- TCNT2 counting register
- OCR2A output compare register A
- OCR2B output compare register B
(OCR2A/B compared to TCNT2, can drive waveform generator)
Control registers;
/**
* Send a single G-code line, and resolve with the response.
* @param {string} line A single line of G-Code
* @return {Promise} A promise that resolves with the response line, or rejects with the serial error.
*/
send: function(line) {
var self = this, port = this.port;
//Clear any incoming data
return port.flush()
//Write the G-code line into the serial port, and set up a waiter with the response.