Skip to content

Instantly share code, notes, and snippets.

View atomize's full-sized avatar
🎹
♩♩

Berti atomize

🎹
♩♩
View GitHub Profile
@atomize
atomize / fillSelectMenu.js
Created October 1, 2018 18:53
Dynamically fill select options with a large list using document.createDocumentFragment() - much more efficient that document.createElement()
const fillMenu = (list, selector) => {
let subsSelect = document.getElementById(selector);
subsSelect.innerHTML = "";
let fragment = document.createDocumentFragment();
list.sort()
list.unshift("Select...")
list.forEach(function (element) {
let opt = document.createElement("option");
opt.value = element;
opt.innerHTML = element;
@atomize
atomize / index.html
Last active October 5, 2018 18:37
Old School lazy load
<img src="blank.gif" data-src="my_image.png" width="600" height="400" class="lazy">
<img src="blank.gif" data-src="my_image.png" width="600" height="400" class="lazy">
<img src="blank.gif" data-src="my_image.png" width="600" height="400" class="lazy">
<img src="blank.gif" data-src="my_image.png" width="600" height="400" class="lazy">
@atomize
atomize / isEmpty.js
Created October 8, 2018 17:00
ES6 null-undefined-''-[]-{} type check
const isEmpty = value => {
if (typeof value === 'number') return false
else if (typeof value === 'string') return value.trim().length === 0
else if (Array.isArray(value)) return value.length === 0
else if (typeof value === 'object') return value == null || Object.keys(value).length === 0
else if (typeof value === 'boolean') return false
else return !value
}
@atomize
atomize / cccagg_temp.js
Last active October 16, 2018 17:39
cccagg temp
let grouper;
const appInfo = {
aggSubs: [],
allSubs: [],
actualSubs: new Set(),
globalmenu: {},
imageUrls: new Map(),
pair: ["???", "???"]
};
@atomize
atomize / range.js
Created October 9, 2018 18:30
Generate range using Array.from() - with alphabet example.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Examples#Sequence_generator_(range)
const range = (start, stop, step) => Array.from({ length: (stop - start) / step }, (_, i) => start + (i * step));
// Generate numbers range 0..4
range(0, 5, 1);
// [0, 1, 2, 3, 4]
// Generate the alphabet using Array.from making use of it being ordered as a sequence
@atomize
atomize / s3.sh
Created October 18, 2018 19:58 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@atomize
atomize / onchange.sh
Created October 18, 2018 22:25 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@atomize
atomize / rsync.sh
Created October 18, 2018 22:28
Rsync with modern options for skipping compression.
export RSYNC_SKIP_COMPRESS=3fr/3g2/3gp/3gpp/7z/aac/ace/amr/apk/appx/appxbundle/arc/arj/arw/asf/avi/bz2/cab/cr2/crypt[5678]/dat/dcr/deb/dmg/drc/ear/erf/flac/flv/gif/gpg/gz/iiq/iso/jar/jp2/jpeg/jpg/k25/kdc/lz/lzma/lzo/m4[apv]/mef/mkv/mos/mov/mp[34]/mpeg/mp[gv]/msi/nef/oga/ogg/ogv/opus/orf/pef/png/qt/rar/rpm/rw2/rzip/s7z/sfx/sr2/srf/svgz/t[gb]z/tlz/txz/vob/wim/wma/wmv/xz/zip
rsync --skip-compress=$RSYNC_SKIP_COMPRESS .....
rsync -av --progress -e "ssh -T -c aes128-ctr -o Compression=no -x" source/ [email protected]:/destination
The key is leaving off the compression (-z) and using aes128-ctr on Ubuntu 18 (latest cipher support)
package main
import (
"bufio"
"flag"
"fmt"
"io"
"os"
"path/filepath"
"regexp"
@atomize
atomize / index.html
Last active October 19, 2018 20:57
one time listener
<!DOCTYPE html>
<html lang="en">
<head>
<title>Animate.css</title>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, minimal-ui" />
<link rel="dns-prefetch" href="//fonts.googleapis.com" />
<link rel="dns-prefetch" href="//code.jquery.com" />