Skip to content

Instantly share code, notes, and snippets.

@lgoldstien
lgoldstien / getFileList.php
Created December 4, 2013 09:07
A function to get a list of files from the current directory and all subdirectories, returned in an array.
function getFilesList ($scanDirectory) {
/** Create empty arrays for the files to scan and directories to evaluate */
$_filesToBeScanned = array();
$_directoriesLeftToEvaluate = array();
/** Add the first directoy on to the evaluation queue */
array_push($_directoriesLeftToEvaluate, $scanDirectory);
while (count($_directoriesLeftToEvaluate) !== 0) {
/** Grab the last directory */
@lgoldstien
lgoldstien / golang-gameoflife.go
Last active December 31, 2015 03:59
Golang game of life
// An implementation of Conway's Game of Life.
package main
import (
"bytes"
"fmt"
"math/rand"
"time"
"os"
"strconv"
@lgoldstien
lgoldstien / stringPad.js
Created December 13, 2013 13:28
Pad out "y" string with "x" character until it is "z" characters long
/**
* Pad a string to a particular length
* @param {string} string - The string to be padded
* @param {string} paddingChar - The character used to pad out the string
* @param {int} count - The desired total length of the string
* @return {string} - The padded string
*/
var stringPad = function (string, paddingChar, paddedLength) {
var outputString = String(string);
@lgoldstien
lgoldstien / workspace-loader.sh
Last active August 19, 2020 16:10
A simple script to load workspace specific environment variables and the like.
#!/bin/bash
function workspace_cd() {
cd $@ && [ -f ".workspace" ] && source .workspace
}
alias cd="workspace_cd"
@lgoldstien
lgoldstien / ScanDirectories.php
Created January 17, 2014 08:20
A simple set of functions to scan a directory tree and produce a flat array of all the file paths under that tree.
<?
/** Set the root of the directy tree you wish to scan */
$scanDirectory = "/var/www";
/** Create empty arrays for the files to scan and directories to evaluate */
$_fileList = array();
$_directoriesLeftToEvaluate = array();
/** Add the first directoy on to the evaluation queue */
array_push($_directoriesLeftToEvaluate, $scanDirectory);
/**
* HTMLSpecialChars
*/
function htmlSpecialChars (source) {
/** Mapping from HTML encoded character to actual character */
var character_mapping = {
/** These are just example characters, you can fill this up with any character conversion you want to do */
"&amp;": "&",
"&copy;": "©"
};
@lgoldstien
lgoldstien / phpscan.php
Last active August 29, 2015 13:56
Scan a directory structure for files and produce hashes for later checking.
<?php
/**
* PHP-Scandir
* This application will scan all directories under the current directory and report any comprimised files
*
* @author Lawrence Goldstien <@lgoldstien>
* @contributers ["Ricky Birtles <@relaxedricky>"]
* @package PHP-Scandir
* @version 0.0.0
@lgoldstien
lgoldstien / en_GB_wordlist.txt
Created May 1, 2014 19:21
British English Wordlist
aardvark
aardvarks
aardwolf
ab
abaca
aback
abacus
abacuses
abaft
abalone
@lgoldstien
lgoldstien / SlickGrid.Column.Definition.js
Last active August 29, 2015 14:02
A demonstration of a slickgrid column configuration with most options filled out.
{
id : "1",
field : "SortCode",
name : "Bank Sort Code *",
validator : "^[0-9]{6}$"
editable : true,
editor : SlickGrid.Editors.TextEditor,
formatter : SlickGrid.Formatters.TextFormatter
}
function TextEditor(args) {
var $input;
var defaultValue;
var scope = this;
this.init = function() {
$input = $("<input />")
.appendTo(args.container)
.bind("keydown.nav", function(e) {
if (e.keyCode === $.ui.keyCode.LEFT || e.keyCode === $.ui.keyCode.RIGHT) {