Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am bytespider on github.
  • I am bytespider (https://keybase.io/bytespider) on keybase.
  • I have a public key whose fingerprint is AB4E 0D5B C744 98E8 14EE E8D7 1642 B2DF 12CE 8036

To claim this, I am signing this object:

package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
func main() {
r := mux.NewRouter()
public function autoLinkText($text)
{
// a more readably-formatted version of the pattern is on http://daringfireball.net/2010/07/improved_regex_for_matching_urls
$pattern = '/((https?):\/\/)?([\da-z\.-]+\.[a-z\.]+)([\/\w \.-]+)*\/?/i';
$callback = function($matches) {
$url = array_shift($matches);
if (is_null(parse_url($url, PHP_URL_SCHEME))) {
$url = 'http://' . $url;
#!/bin/bash
PORT=2222
if [ ${VAGPORT} ]; then
PORT=${VAGPORT}
fi
IFS=$'\n'
SSH_CONFIG=($(vagrant ssh-config $1 | sed -e 's/^ *//' -e 's/ *$//'))
#!/bin/bash
PORT=2222
if [ ${VAGPORT} ]; then
PORT=${VAGPORT}
fi
IFS=$'\n'
SSH_CONFIG=($(vagrant ssh-config $1 | sed -e 's/^ *//' -e 's/ *$//'))
@bytespider
bytespider / copy javascript array.js
Created January 25, 2010 14:12
Copy javascript array to new array
var array_a = [1,2,3];
var copy_of_array_a = array_a.slice(0);
function ANSI_X923_pad(hex_str, blocksize) {
blocksize = blocksize || 512; // in bits
var bit_str_len = hex_str.length * 4; // in bits
var bit_str_len_hex = bit_str_len.toString(16);
// how many nibbles are left over?
var pad_nibbles = (((bit_str_len / blocksize) < 1) ? (blocksize - (bit_str_len_hex.length * 4)) - bit_str_len : (blocksize - (bit_str_len_hex.length * 4)) - (bit_str_len - blocksize)) / 4;
return hex_str + new Array(1 + pad_nibbles).join(0) + bit_str_len_hex;
}
// bookmarklet to introspect the source of current page
javascript:(function(d,h){h=d.documentElement.innerHTML;d.open();d.write('<pre>'+('<!DOCTYPE html><html>'+h+'</html>').replace(/[<>]/g,function(m){return{'<':'&lt;','>':'&gt;'}[m]})+'</pre>')})(document);
window.addEventListener('load', function (event) {
var stylesheets = window.document.styleSheets;
for(var i = 0; i < stylesheets.length; i++) {
parseStylesheet(stylesheets[i]);
}
function parseStylesheet(stylesheet) {
if(stylesheet.imports) {
for (var i = 0; i < stylesheet.imports.length; i++) {
function openURL(url) {
var a = d.createElement('a'), d = document;
a.href = url;
a.dispatchEvent(d.createEvent('MouseEvents').initMouseEvent('click'));
}