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 ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/ | |
const digits = /^\d\d\.|^\d\d\d\./g | |
const local = /^127\.|^10\.|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-1]\.|^192\.168\./g | |
const RTCPeerConnection = window.RTCPeerConnection | |
|| window.mozRTCPeerConnection || window.webkitRTCPeerConnection | |
ipaddr(function(addr1){ | |
console.log(addr1) | |
setTimeout(function(){ |
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 days = [ 's', 'm', 't', 'w', 't', 'f', 's' ] | |
const today = new Date(Date.now()) | |
// calsz, for conducting hypertext markup language measurements | |
const calsz = [ 0 ] | |
// generate a calendar year | |
const calendar = yr ( today.getFullYear() ) | |
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
# FIX TRIGGER HAPPY COMMIT TO WRONG BRANCH: | |
# ---------- | |
git reset --soft HEAD^ | |
git checkout branch | |
git commit | |
# DELETE TAG | |
# ---------- | |
git tag -d 12345 | |
git push origin :refs/tags/12345 |
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
//cc main.c $CFLAGS $LDFLAGS -ldill $opt/lib/libdsock.a -o server && ./server | |
#include <libdill.h> | |
#include <dsock.h> | |
#include <assert.h> | |
#include <errno.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> |
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 parseURL (url) { | |
var div = document.createElement('div'); | |
div.innerHTML = '<a></a>'; | |
div.firstChild.href = url; // Ensure href is properly escaped | |
div.innerHTML = div.innerHTML; // Run current innerHTML back through parser | |
return div.firstChild.origin || '//' + div.firstChild.hostname; // or case is for IE | |
} |
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 n = [ 'error', 'stdout', 'stderr' ] | |
require('child_process').exec('ls -la', function output () { | |
return [] | |
.slice | |
.call ( arguments ) // or do [].from(arguments) | |
.reduce ( ( p, c, i ) => { | |
if ( c ) | |
console.log(`\n\n${n[i]}:\n\n${c}`) | |
return p | |
}, process.exit ) ( 0 ) |
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
// $ npm i nanomsg browserify es6ify stylus | |
// $ node bld | |
const createWriteStream = require('fs').createWriteStream | |
const readFileSync = require('fs').readFileSync | |
const writeFile = require('fs').writeFile | |
const resolve = require('path').resolve | |
const browserify = require('browserify') | |
const join = require('path').join | |
const watch = require('fs').watch |
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
/** | |
* Readable Stream | |
*/ | |
require('util').inherits( _rs, require('stream').Readable ); | |
function _rs ( fn ) { | |
this._read = function(){}; | |
require('stream').Readable.call( this, { objectMode: true } ); | |
} | |
function rs ( fn ) { |
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
/** | |
* `_ (27).daysago` | |
* returns date notation n days ago | |
*/ | |
exports._ = n => { // 86400000 == 24 hrs | |
return { daysago : new Date( Date.now() - (n * 86400000) )}; | |
} |
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
console.log( suuid() ); // somethiing like 'e1bdadd6' | |
function suuid() { | |
var sm = [], i = 256; | |
while (i--) | |
sm[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 ); | |
var uu = Math.random() * 0xffffffff | 0; | |
return sm[ uu & 0xff ] + | |
sm[ uu >> 8 & 0xff ] + | |
sm[ uu >> 16 & 0xff ] + |