Skip to content

Instantly share code, notes, and snippets.

View elhenro's full-sized avatar

Henry Schober elhenro

View GitHub Profile
@Jimbly
Jimbly / webroot.js
Last active March 13, 2019 17:38
Node.js app combining virtual hosts, proxies, mapped subdirectores, and static sites, with WebSockets support.
// Companion Blog Post about architecture:
// http://jimbesser.wordpress.com/2014/10/20/its-node-js-all-the-way-down/
// Companion Blog Post about dealing with legacy requests:
// http://jimbesser.wordpress.com/2014/11/29/the-horrible-things-peoples-routers-do-to-my-packets/
//
// Routing handled by this app:
// [www.]bigscreensmallgames.com -> static site: /var/data/smb_web/bigscreensmallgames.com/
// fanime.info -> node app running entire site on port 4001
// [default site]/app1: replace URL and redirect to single page app on 192.168.0.127:21022
// [default site] -> static site: /var/data/smb_web/dashingstrike.com/
" Strip the newline from the end of a string
function! Chomp(str)
return substitute(a:str, '\n$', '', '')
endfunction
" Find a file and pass it to cmd
function! DmenuOpen(cmd)
let fname = Chomp(system("git ls-files | rofi -dmenu -i -l 20 -p " . a:cmd))
if empty(fname)
return
@jdelibas
jdelibas / .git-commit-template.txt
Last active January 14, 2021 11:43
git commit message template
# <type>(<scope>): (If applied, this commit will) <subject>
# feat(login): add password enforcement rules
# |<---- Try To Limit Each Line to a Maximum Of 100 Characters ---->|
# <body>
# |<---- Try To Limit Each Line to a Maximum Of 100 Characters ---->|
# <footer>
@arnars
arnars / Gatsby v2 using Internet Explorer.md
Last active February 15, 2021 08:01
Tips for making Gatsby v2 working with IE / Internet Explorer

Making Gatsby work with Internet Explorer 10 and 11

I created this gist in order to help myself and others keep track of tips and tricks in order to make Gatsby v2 play nicely with Internet Explorer 10 and 11.

This is experience based. Please share your experiences when you have a solution to a problem.

External compilation of modules

If you suspect that an es6-based module is breaking your app, then try to add gatsby-plugin-compile-es6-packages and include the package as one of the modules.

@IcanDivideBy0
IcanDivideBy0 / useCanvas.js
Last active September 28, 2021 03:14
Simple hook for canvas rendering in react
import React from "react";
// Usage
function App() {
const draw = React.useCallback(gl => {
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clearDepth(1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
}, []);
const canvasRef = useCanvas(draw, "webgl2");
@random-robbie
random-robbie / install_go_pi.sh
Created April 26, 2018 14:16
Install Go Lang 1.10.1 on Raspberry Pi 3
wget https://storage.googleapis.com/golang/go1.10.1.linux-armv6l.tar.gz
sudo tar -C /usr/local -xvf go1.10.1.linux-armv6l.tar.gz
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
source ~/.bashrc
@danallison
danallison / downloadString.js
Created September 29, 2014 16:44
download string as text file
function downloadString(text, fileType, fileName) {
var blob = new Blob([text], { type: fileType });
var a = document.createElement('a');
a.download = fileName;
a.href = URL.createObjectURL(blob);
a.dataset.downloadurl = [fileType, a.download, a.href].join(':');
a.style.display = "none";
document.body.appendChild(a);
a.click();
@ivermac
ivermac / fetch-basic-auth.md
Created August 1, 2018 14:45
Using fetch with basic auth
let username = 'john';
let password = 'doe';
let url = `https://httpbin.org/basic-auth/${username}/${password}`
let authString = `${username}:${password}`
let headers = new Headers();
headers.set('Authorization', 'Basic ' + btoa(authString))
fetch(url,{method: 'GET', headers: headers})
    .then(function (response) {
 console.log (response)
@johnnyopao
johnnyopao / encrypt-all.sh
Created May 2, 2018 23:42
GPG Encrypt all files in directory
#!/bin/bash
# This uses gpg to encrypt every file in a directory as separate
# encrypted files
# Usage
# ./encrypt-all.sh ./dir-of-files-to-encrypt "PASSPHRASE"
FILES="$1"
PASSPHRASE="$2"
@danmikita
danmikita / init.vim
Created November 16, 2018 19:16
File preview with FZF, RG, Bat, and Devicons
nnoremap <silent> <leader>e :call Fzf_dev()<CR>
" ripgrep
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
" Files + devicons