Tiny Cross-browser DOM ready function in 111 bytes of JavaScript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unique = arr => [...new Set(arr)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 ] ); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem | |
chmod 0600 id_rsa.pem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!#/bin/bash | |
for file in $(cat $1) | |
do | |
ffmpeg -i $file -vf scale=320:240 -strict -2 $(echo $file|sed ’s/\.[^.]*$//‘).mp4 | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |