Skip to content

Instantly share code, notes, and snippets.

View jarrodhroberson's full-sized avatar

Jarrod Roberson jarrodhroberson

View GitHub Profile
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@maximebf
maximebf / webtail.py
Created October 21, 2011 13:25
Web tail / tail -f as a webpage using websocket
#!/usr/bin/python
# Equivalent of "tail -f" as a webpage using websocket
# Usage: webtail.py PORT FILENAME
# Tested with tornado 2.1
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
import tornado.httpserver
@gclaramunt
gclaramunt / Event.java
Created March 28, 2012 18:13
Fluent state machine in Java
package statemachine;
public class Event {
final private String label;
public Event(String newLabel) {
label = newLabel;
}
/**
@yincrash
yincrash / Google2APi.java
Created April 22, 2012 17:22
Google OAuth2.0 for scribe-java
package org.scribe.builder.api;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.scribe.exceptions.OAuthException;
import org.scribe.extractors.AccessTokenExtractor;
import org.scribe.model.OAuthConfig;
import org.scribe.model.OAuthConstants;
import org.scribe.model.OAuthRequest;
@bhavanki
bhavanki / colorize-maven.sh
Created June 21, 2012 21:10 — forked from mike-ensor/colorize-maven.sh
Colorize Maven output
#!/bin/sh
# Written by Mike Ensor ([email protected])
# Copywrite 2012
# Use as needed, modify, have fun!
# Modified by Bill Havanki
# This was intended to be used for Maven3 + Mac OSX, but it's been modified for Cygwin and Linux.
# Maybe it still works on OSX?
# Changes from original:
# - Cygwin support
@jarrodhroberson
jarrodhroberson / size of array.cpp
Created November 12, 2012 15:33
How to get the length of an array with a template as well as pass in an array to a function to get its length in the function.
#include <cstdint>
#include <stdio.h>
template<typename T, size_t SIZE>
size_t getSize(T (&)[SIZE]) {
return SIZE;
}
typedef std::uint_fast8_t byte;
@jarrodhroberson
jarrodhroberson / delve-jar.sh
Created March 12, 2013 16:52
A short Bash script to delve through a directory of .jar files and find the ones that contain a given package or class.
#!/bin/sh
find . -name '*.[jwes]ar' | while read LINE; do grep -q $1 "$LINE"; if [ $? -eq 0 ];then echo "$LINE"; jar tvf "$LINE" | grep $1;echo;fi;done
@ophentis
ophentis / gist:5473449
Created April 27, 2013 15:16
setting multiple private key for ssh
1.
ssh-keygen -t rsa -f ~/.ssh/id_rsa.work -C "Key for Word stuff"
2.
touch ~/.ssh/config
chmod 600 ~/.ssh/config
echo "IdentityFile ~/.ssh/id_rsa.work" >> ~/.ssh/config
echo "IdentityFile ~/.ssh/id_rsa.misc" >> ~/.ssh/config
@valerysntx
valerysntx / underscore.uuid.js
Last active December 17, 2015 13:49
client javascript uuid v4 and v5 generator. do not require additional libs. adopted from 'superscore' extensions by David Souther. http://davidsouther.github.com/superscore/ usage: var randomUUID = underscore.UUID.v4(); var uuidv5 = underscore.UUID.v5(msg,namespace);
var underscore = (function(underscore){
// Build several namespaces, globally...
var UUID = {};
var Sha1 = function(str){return Sha1.hash(str, true);};
var Utf8 = {};
var extend = function() {
var options, name, src, copy, copyIsArray, clone,
@jhoff
jhoff / md5.js
Created November 27, 2013 18:27
Closure of Joseph's Myers md5 javascript implementation
/*
* http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
(function() {
var md5cycle = function(x, k) {
var a = x[0], b = x[1], c = x[2], d = x[3];
a = ff(a, b, c, d, k[0], 7, -680876936);