Skip to content

Instantly share code, notes, and snippets.

View brianteachman's full-sized avatar

Brian Teachman brianteachman

View GitHub Profile
@brianteachman
brianteachman / stop_words.php
Created January 13, 2013 08:21
A PHP array of common English stop words that can loaded by an include statement.
<?php
//http://www.ranks.nl/resources/stopwords.html
return $stop_words = array(
'a',
'about',
'above',
'after',
'again',
'against',
'all',
##
# My solution is not the shortest, but it makes sense to me.
##
def print_abacus(value):
abacus, rod, slices = '', '00000*****', []
for char in str(value):
# is there any reason not to use a list of dictionaries?
slices.append({'left': (10 - int(char)), 'right': (10 - (10 - int(char)))})
rows = len(slices) # does it make sense to cache here?
if rows < 10:
@brianteachman
brianteachman / password_scorer.js
Created December 4, 2012 00:40
Password Scorer
// http://net.tutsplus.com/tutorials/javascript-ajax/meet-crockford%E2%80%99s-jscheck/
(function () {
var PasswordScorer = {};
PasswordScorer.score = function (password) {
var len = password.length,
lengthScore = 0,
letterScore = 0,
chars = {}
if (len >= 21) { lengthScore = 7; }
@brianteachman
brianteachman / php_time_profiler.php
Created October 1, 2012 22:41
PHP timimg script using microtime() and BC Math
#!/usr/bin/php
<?php
$profile = function() {
static $start = '0';
list($timestamp, $microseconds) = split(' ', microtime());
$current = bcadd($timestamp, $microseconds, 4);
if ($start === '0') {
$start = $current;
return;
}
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@brianteachman
brianteachman / Rot13.js
Created September 29, 2012 17:06
ROT-13 letter substitution cipher Constructor. Provides ROT-13 encoding and decoding.
function Rot13() {
var result = "";
var decode = false;
var lookup = function(char, i) {
var lt1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
var lt2 = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm ";
var orig = (decode) ? lt2: lt1;
var enc = (decode) ? lt1: lt2;
@brianteachman
brianteachman / rot13.js
Created September 29, 2012 15:51
ROT-13 letter substitution cipher. For obfuscation because of virtually absent, level of security.
//http://en.wikipedia.org/wiki/Rot13
//var name = "Brian Teachman";
//var token = "Oevna Grnpuzna";
function rot13(name) {
var lt1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
var lt2 = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm ";
var result = "";