This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "dgc-decode" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
base45 = "3.0.0" | |
ciborium = "0.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn neighbour_at<const D: usize>(i: u32) -> [i32; D] { | |
let mut el = [0_i32; D]; | |
let mut n = i; | |
for v in el.iter_mut().rev() { | |
*v = (n as i32 % 3) - 1; // -1 is needed because we offset the digits so that we are in range -1..1 | |
n /= 3; | |
} | |
el |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const fp = require('fastify-plugin') | |
const mysql = require('mysql2/promise') | |
const CONNECTION_STRING = process.env.DB_CONN_STRING | |
module.exports = fp(async function (fastify, opts) { | |
const db = await mysql.createConnection(CONNECTION_STRING) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getMyPublicIp } from './utils.ts' | |
getMyPublicIp | |
.then(console.log) | |
.catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const x = require('./index.js') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createServer } = require('http'); | |
createServer((req, res) => { | |
console.log('--------'); | |
console.log(JSON.stringify(req.headers, null, 2)); | |
req.pipe(process.stdout); | |
res.writeHead(200, {'Content-Type': 'application/json'}); | |
res.end(JSON.stringify({ok:true})); | |
}) | |
.listen(8000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import gzip | |
cw_client = boto3.client('cloudwatch') | |
event_system = cw_client.meta.events | |
def gzip_request_body(request, **kwargs): | |
gzipped_body = gzip.compress(request.body) | |
request.headers['Content-Encoding'] = 'gzip' | |
request.data = gzipped_body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt; | |
use std::str::FromStr; | |
// [x - 1, y - 1] [ x , y - 1] [x + 1, y - 1] | |
// [x - 1, y ] (current) [x + 1, y ] | |
// [x - 1, y + 1] [ x , y + 1] [x + 1, y + 1] | |
const DIRECTIONS: [(i8, i8); 8] = [ | |
(-1, -1), | |
(0, -1), | |
(1, -1), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readdir, stat } from 'fs' | |
import { join } from 'path' | |
function listNestedFilesRec (path, state, cb) { | |
state.ops++ | |
readdir(path, (err, files) => { | |
state.ops-- | |
if (err) { | |
return cb(err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createUploadStream (filename) { | |
const connector = new PassThrough() | |
upload(filename, connector) | |
return connector | |
} |