Skip to content

Instantly share code, notes, and snippets.

@uhop
uhop / nginx-webp-sample.conf
Last active November 3, 2023 12:09
Serving WEBP with nginx conditionally.
View nginx-webp-sample.conf
user www-data;
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
@uhop
uhop / ANSI.md
Created July 3, 2023 19:01 — forked from fnky/ANSI.md
ANSI Escape Codes
View ANSI.md

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@uhop
uhop / .bash_aliases
Created July 3, 2016 20:19
My bash setup
View .bash_aliases
# commands from http://www.askapache.com/linux/bash_profile-functions-advanced-shell.html
#alias chmod='command chmod -c'
alias cpr='command cp -rpv'
alias df='command df -kh'
alias df1='command df -ia'
alias diff='diff -up'
alias dsiz='du -sk * | sort -n --'
alias du='command du -kh'
alias du1='echo *|tr " " "n" |xargs -iFF command du -hs FF|sort'
@uhop
uhop / README
Created May 29, 2023 06:35 — forked from radfish/README
Route only Transmission through a VPN connection using your own VPN server
View README
# The approach is to mark packets from a specific user,
# create a dedicated routing table with a default route
# through the VPN, and force all marked packets to be
# routed using that table.
#
# Sources:
# https://www.niftiestsoftware.com/2011/08/28/making-all-network-traffic-for-a-linux-user-use-a-specific-network-interface/
# http://freeaqingme.tweakblogs.net/blog/9340/netflix-using-a-vpn-for-just-one-application.html
# In this guide
View h.mjs
// Copied from https://github.com/heya/dom under BSD-3 and slightly modified.
// create.js
// Dojo-inspired set of DOM utilities
export const namespaces = {
svg: 'http://www.w3.org/2000/svg',
xlink: 'http://www.w3.org/1999/xlink',
ev: 'http://www.w3.org/2001/xml-events',
xml: 'http://www.w3.org/XML/1998/namespace'
@uhop
uhop / on.mjs
Created May 19, 2023 21:15
The ES6 facelift for the venerable on() from https://github.com/clubajax/on
View on.mjs
// a facelift of the venerable on.js: slightly modified for ES6, removed dead browsers
// copied from https://github.com/clubajax/on, used under the MIT license
// internal utilities
const getNodeById = id => {
const node = document.getElementById(id);
if (!node) {
console.error('`on` Could not find:', id);
}
@uhop
uhop / str-pad.js
Last active May 16, 2023 14:47
Padding a string: left pad, right pad, repeating a string
View str-pad.js
const rep = (str, n) => {
if (n < 1 || !str) return '';
let result = '';
for (;;) {
if (n & 1) {
result += str;
}
n >>= 1;
if (n < 1) break;
str += str;
View brew-bundle-brewfile-tips.md

Brew Bundle Brewfile Tips

Copyright & License

Unless otherwise noted (either in this file or in a file's copyright section) the contents of this gist are Copyright ©️2020 by Christopher Allen, and are shared under spdx:Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.) open-source license.

Sponsor

If you more tips and advice like these, you can become a monthly patron on my GitHub Sponsor Page for as little as $5 a month; and your contributions will be multipled, as GitHub is matching the first $5,000! This gist is all about Homebrew, so if you like it you can support it by donating to them or becoming one of their Github Sponsors.

@uhop
uhop / static-server.mjs
Last active May 12, 2023 17:22
No-dependency ES6 drop-in modular static development HTTP server.
View static-server.mjs
// https://gist.github.com/uhop/fbb7fc3606cbb2fa54e0ce4f9a200037
// License: BSD-3
// (c) 2023 Eugene Lazutkin
import http from 'http';
import fs from 'fs';
import path from 'path';
const fsp = fs.promises;
@uhop
uhop / print.html
Created April 24, 2023 16:10
Multi-page print test
View print.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Multi-page print test</title>
<!--
Print to PDF, landscape, letter size, no margins, enable background graphics.
Tested on Chrome.
-->
<style>