Skip to content

Instantly share code, notes, and snippets.

View mlin's full-sized avatar

Mike Lin mlin

View GitHub Profile
@arthurafarias
arthurafarias / README.md
Last active July 8, 2023 11:43
Encoding URI and URI Component in C++

Encode and Decode HTTP URIs and URI components in C++

What is a URI?

A Uniform Resource Identifier (URI) is a string of characters that unambiguously identifies a particular resource. To guarantee uniformity, all URIs follow a predefined set of syntax rules,[1] but also maintain extensibility through a separately defined hierarchical naming scheme (e.g. "http://").

Such identification enables interaction with representations of the resource over a network, typically the World Wide Web, using specific protocols. Schemes specifying a concrete syntax and associated protocols define each URI. The most common form of URI is the Uniform Resource Locator (URL), frequently referred to informally as a web address. More rarely seen in usage is the Uniform Resource Name (URN), which was designed to complement URLs by providing a mechanism for the identification of resources in particular namespaces.

The common parts of a URI are described below.

@lovubuntu
lovubuntu / Sha256.kt
Created November 24, 2017 15:58
function to generate Sha-256 in Kotlin
Class Hasher {
fun hash(): String {
val bytes = this.toString().toByteArray()
val md = MessageDigest.getInstance("SHA-256")
val digest = md.digest(bytes)
return digest.fold("", { str, it -> str + "%02x".format(it) })
}
}
@mlin
mlin / dx-ci-init.py
Last active October 14, 2020 06:25
Suggested best practices for DNAnexus workflow development & continuous integration
#!/usr/bin/env python
#
# Initializes a git repository with some suggested best practices for DNAnexus
# workflow development & continuous integration. Run dx-ci-init.py in the root
# of your git repository; it creates the following, which you should then
# customize as you like:
#
# applets/hello-world
# Trivial applet template which you can build on or copy.
#
@allanmac
allanmac / tk1_gpu_max_clock.sh
Last active August 14, 2017 13:25
Some login tweaks for L4T 19.3 to disable USB autosuspend and lock the GPU to max MHz. I have lines 3-11 of tk1_tweaks.sh appended to my .profile.
#!/bin/bash
#
# Lock GPU and MEM clocks to max MHz
#
# - benchmarking shows there is no need to override the MEM clock
#
echo
echo Locking GPU clock to max MHz for debugging porpoises...
# set to max
@mina86
mina86 / version.py
Last active December 10, 2022 04:07 — forked from dcreager/version.py
Extract a setuptools version from the git repository's tags.
# -*- coding: utf-8 -*-
"""Calculates the current version number.
If possible, uses output of “git describe” modified to conform to the
visioning scheme that setuptools uses (see PEP 386). Releases must be
labelled with annotated tags (signed tags are annotated) of the following
format:
v<num>(.<num>)+ [ {a|b|c|rc} <num> (.<num>)* ]
@larrybolt
larrybolt / cf-ddns.sh
Last active April 29, 2024 13:34
Automatically update your CloudFlare DNS record to the IP, Dynamic DNS for Cloudflare
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
# Automatically update your CloudFlare DNS record to the IP, Dynamic DNS
# Can retrieve cloudflare Domain id and list zone's, because, lazy
# Place at:
# /usr/local/bin/cf-ddns.sh
@razorsedge
razorsedge / bdmapping
Created April 17, 2012 16:55 — forked from smoser/bdmapping
bdmapping: utility for providing the correct block-device-mapping args for ebs instances on EC2
#!/bin/sh
Usage() {
cat <<EOF
${0##*/} [-c] instance-type
print ephemeral store block-device-mapping arguments for 'instance-type'
If '-c' given, also print "--instance-type <instance-type>"
examples:
@zbroyar
zbroyar / gist:1432555
Created December 5, 2011 06:28
OCaml CURL GET, POST, PUT, DELETE examples
(* ocamlfind ocamlopt -o exmpl -package curl -linkpkg exmpl.ml *)
open Printf
let _ = Curl.global_init Curl.CURLINIT_GLOBALALL
(*
*************************************************************************
** Aux. functions
*************************************************************************
*)