Skip to content

Instantly share code, notes, and snippets.

View atomize's full-sized avatar
🎹
♩♩

Berti atomize

🎹
♩♩
View GitHub Profile
// move all text into <span>
// they occupy exactly the place necessary for the text,
for (let li of tree.querySelectorAll('li')) {
let span = document.createElement('span');
li.prepend(span);
span.append(span.nextSibling); // move the text node into span
}
// catch clicks on whole tree
@atomize
atomize / ccc.js
Created October 24, 2018 21:59
testGist
const unique = arr => [...new Set(arr)];
@atomize
atomize / Append CSV to Sheet.py
Last active September 27, 2024 12:55 — forked from david-pettifor-nd/Append CSV to Sheet.py
Google Drive/Sheets API
# open the CSV file
csv_file = open(CSV_LOCATION, 'r')
csv_reader = csv.reader(csv_file)
values = []
for row in csv_reader:
values.append(row)
body = {
'values': values
@atomize
atomize / README.md
Created November 10, 2018 22:54 — forked from dciccale/README.md
Tiny Cross-browser DOM ready function in 111 bytes of JavaScript

DOM Ready

Tiny Cross-browser DOM ready function in 111 bytes of JavaScript.

@atomize
atomize / WATCH_COMMANDS.sh
Created November 11, 2018 22:13
Set the PS4 variable, which is evaluated for every command being executed just before the execution if trace is on.
#!/bin/bash
#You can set the PS4 variable, which is evaluated for every command being executed just before the execution if trace is on:
PS4='$(echo $(date) $(history 1) >> /tmp/trace.txt) TRACE: '
#Then, enable trace:
set -x
#To stop tracing, just:
#set +x
@atomize
atomize / exampleExecuteByName.js
Last active November 24, 2018 21:00
Execute function by name string and context (window/namespace)
// Example of how to use executeFunctionByName()
// question: https://stackoverflow.com/q/359788
// answer: https://stackoverflow.com/a/42171078
// via user: https://stackoverflow.com/users/2158270/mac
a = function( args ) {
console.log( 'global func passed:' );
for( var i = 0; i < arguments.length; i++ ) {
console.log( '-> ' + arguments[ i ] );
}
};
@atomize
atomize / convert id_rsa to pem
Last active November 30, 2018 14:55 — forked from mingfang/convert id_rsa to pem
Convert id_rsa to pem file
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
chmod 0600 id_rsa.pem
@atomize
atomize / ffmpeg_batch_resize.sh
Created January 6, 2019 21:02
use ffmpeg and bash to scale multiple video files to matching scale/size.
!#/bin/bash
for file in $(cat $1)
do
ffmpeg -i $file -vf scale=320:240 -strict -2 $(echo $file|sed ’s/\.[^.]*$//‘).mp4
done
@atomize
atomize / color-conversion-algorithms.js
Created February 17, 2019 14:33 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@atomize
atomize / _get.sh
Created February 26, 2019 22:03
bash function to download file from web without cURL/wget
# Add this to your .bashrc
# Use it like: you@console_>$ _get https://website.org/file.txt
_get ()
{
IFS=/ read proto z host query <<< "$1"
exec 3< /dev/tcp/$host/80
{
echo GET /$query HTTP/1.1
echo connection: close
echo host: $host