Skip to content

Instantly share code, notes, and snippets.

@cpdt
cpdt / minimal.rs
Last active May 9, 2023 10:42
A minimal Rust file with no_std for sizecoding (4k, 8k, 64k, etc)
#![no_std]
#![no_main]
#![feature(core_intrinsics, lang_items, link_args, alloc, alloc_error_handler)]
#[allow(unused_attributes)]
#[link_args = "/NODEFAULTLIB /SUBSYSTEM:WINDOWS /SAFESEH:NO /DYNAMICBASE:NO /ENTRY:WinMainCRTStartup /LTCG support/msvcrt.lib"]
extern "C" {}
#[macro_use]
extern crate alloc;
@hagemann
hagemann / database.js
Last active December 9, 2022 10:24
Promisified MySQL middleware for Node.js
const util = require('util')
const mysql = require('mysql')
const pool = mysql.createPool({
connectionLimit: 10,
host: 'localhost',
user: 'root',
password: 'password',
database: 'my_database'
})
@krzys-h
krzys-h / wrapper.c
Last active March 25, 2022 17:48
HTTrack remove param from query string plugin
// Remove sid= from query string plugin for HTTrack
// by krzys_h, 2018-05-15
// https://gist.github.com/krzys-h/4717608089c54f733083fd390e5c0f2b
// This makes HTTrack automatically remove the sid= parameter from URLs it visits, as there is no way this can be done with commandline parameters (see https://forum.httrack.com/readmsg/27508/index.html)
// Compilation and usage:
// gcc -shared -o wrapper.so -fPIC -I/usr/include/httrack wrapper.c
// httrack --wrapper ./wrapper.so ...
@anuragmathur1
anuragmathur1 / add-remove-public-read-s3.txt
Created August 2, 2017 00:00
s3cmd examples to add and remove public-read access for s3 buckets, folders and objects within.
## You may choose to remove --recursive if is required only for the bucket or folder and not for objects within.
s3cmd setacl --acl-private --recursive s3://mybucket-name
s3cmd setacl --acl-private --recursive s3://mybucket-name/folder-name
s3cmd setacl --acl-private --recursive s3://mybucket-name/folder-name/object-name
s3cmd setacl --acl-public --recursive s3://mybucket-name
s3cmd setacl --acl-public --recursive s3://mybucket-name/folder-name
s3cmd setacl --acl-public --recursive s3://mybucket-name/folder-name/object-name
@zcaceres
zcaceres / Nested-Routers-Express.md
Last active April 4, 2024 09:44
Child Routers in Express

Nested Routers in Express.js

Express makes it easy to nest routes in your routers. But I always had trouble accessing the request object's .params when you had a long URI with multiple parameters and nested routes.

Let's say you're building routes for a website www.music.com. Music is organized into albums with multiple tracks. Users can click to see a track list. Then they can select a single track and see a sub-page about that specific track.

At our application level, we could first have a Router to handle any requests to our albums.

const express = require('express');