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
// ==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. |
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
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)); |
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
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] |
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 |
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
!#/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
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
// 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
#!/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 |