Skip to content

Instantly share code, notes, and snippets.

View Techworker's full-sized avatar

Benjamin Ansbach Techworker

View GitHub Profile
<?php
class P1
{
const DIRECTIONS = ['N', 'E', 'S', 'W'];
protected string $file;
protected int $x;
protected int $y;
protected int $degrees;
<?php
class P2
{
protected string $file;
protected int $x = 0;
protected int $y = 0;
protected int $wpx = 10;
protected int $wpy = 1;
@Techworker
Techworker / day11.php
Last active December 12, 2020 01:58
AOC Day11
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$input = <<<AOC
...
AOC;
const OCCUPIED = '#';
const FREE = 'L';
<?php
$input = <<<AOC
// ...
AOC;
function p1Data() {
global $input;
// read joltages
$adapters = array_map('intval', explode("\n", $input));
<?php
$ops = [];
$lines = array_map('trim', file(__DIR__ . '/day8.txt'));
foreach($lines as $line) {
$ops[] = explode(' ', $line);
}
function emulate($ops, $infiniteReturn = false) {
$pos = 0;
<?php
// child => [...parents]
$part1Rules = [];
// parent => [...child => count]
$part2Rules = [];
$lines = array_filter(file(__DIR__ . '/data.txt'));
$regex = '/(?<parent>\w+\s\w+) bags contain|(?<count>\d+)\s(?<child>\w+\s+\w+) bag/';
const pascal = require('./src/Indyo').factory('http://127.0.0.1:4103');
const keyPair = pascal.Keys.decryptPrivateKey(
'53616C7465645F5FBCBB3CE7D3604D59B60B1F98065E743DAC933FFB5FDC384D0D18ED193F0C3BC03666634AB93CE1040C4B9B7FBAAA78120DF21D8AE241E8E0',
'test123'
);
(async () => {
await pascal.Wallet.send(keyPair, 91461, 91462, 0.1234, 'test123');
const indyo = require('./src/Indyo').factory('http://127.0.0.1:4103');
const keyPair = indyo.Keys.decryptPrivateKey(
'53616C7465645F5FBCBB3CE7D3604D59B60B1F98065E743DAC933FFB5FDC384D0D18ED193F0C3BC03666634AB93CE1040C4B9B7FBAAA78120DF21D8AE241E8E0',
'test123'
);
(async () => {
let account = await indyo.Accounts.findByAccountNumber(91461);
await account.send(keyPair, 91462, 0.1234, 'test123');
const Coding = require('@pascalcoin-sbx/common').Coding;
const BC = require('@pascalcoin-sbx/common').BC;
const GUID = require('@pascalcoin-sbx/common').Types.GUID;
const CompositeType = Coding.CompositeType;
// perpare format
class Groupon extends CompositeType
{
constructor() {
super('groupon');
@Techworker
Techworker / send_data.js
Created July 5, 2019 10:29
Send DATA operation to Pascal without disclosing the private key
// import libraries
const SbxSigning = require('@pascalcoin-sbx/signing');
const SbxRpc = require('@pascalcoin-sbx/json-rpc');
const SbxCrypto = require('@pascalcoin-sbx/crypto');
// import private key
const keyPair = SbxCrypto.importEncryptedPrivateKey(
'XXX', // encrypted private key
'XXX' // password
);