Skip to content

Instantly share code, notes, and snippets.

View atomize's full-sized avatar
🎹
♩♩

Berti atomize

🎹
♩♩
View GitHub Profile
@atomize
atomize / data-markdown.user.js
Created March 28, 2019 20:36 — forked from paulirish/data-markdown.user.js
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@atomize
atomize / gulpfile.js
Created March 22, 2019 19:25 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@atomize
atomize / filehighlight.js
Created March 15, 2019 19:13
reminder for Prism
function loadFile(src, cb) {
var xhr = new XMLHttpRequest();
var s = [];
xhr.open("GET", src, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status < 400 && xhr.responseText) {
s = [src,xhr.responseText]
} else if (xhr.status >= 400) {
s = [src, "✖ Error " + xhr.status + " while fetching file: " + xhr.statusText]
@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
@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 / 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 / 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 / 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 / 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 / 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.