Skip to content

Instantly share code, notes, and snippets.

View reqshark's full-sized avatar
🎚️
back at it

Bent Cardan reqshark

🎚️
back at it
View GitHub Profile
@reqshark
reqshark / style_guide.md
Created August 8, 2017 07:55 — forked from dominictarr/style_guide.md
style guide

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@reqshark
reqshark / ip.js
Last active May 6, 2017 10:37
get your ips
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(){
@reqshark
reqshark / cal.js
Last active March 8, 2017 10:20
the calendar
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() )
@reqshark
reqshark / git.sh
Created February 17, 2017 10:05
damn it! committed to the wrong branch again...
# 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
@reqshark
reqshark / dsock_http.c
Created February 16, 2017 13:14
first try dsock http
//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>
@reqshark
reqshark / parseURL.js
Created January 27, 2017 19:46
parse url
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
}
@reqshark
reqshark / from.args.js
Created January 21, 2017 06:01
`$ ls -la` to list files on unix. for success, call process.exit with zero
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 )
@reqshark
reqshark / bld.js
Created January 21, 2017 04:49
my javascript build system: more front-end shenanigans
// $ 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
@reqshark
reqshark / killthatthing.js
Created October 13, 2016 19:42
stream talk
/**
* 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 ) {