Skip to content

Instantly share code, notes, and snippets.

@mark-d-holmberg
mark-d-holmberg / purge.sh
Created September 29, 2011 19:32
How to purge passwords from files
#to find the offenders
find -name "*\.php" -print0 | xargs -0 grep -Rin "password" > results.txt
# to replace it with garbage
find . -name "*.php" -print0 | xargs -0 sed -i -e 's/FINDME/REPLACEWITHME/g'
# you can change '*.php' to the extension you want.
# remove the command from .bash_history
> ~/.bash_history
@mark-d-holmberg
mark-d-holmberg / grep_makefile.sh
Created October 4, 2011 19:52
Grepping Makefiles for Executable Names
#TODO: Match the optional ".x86" extension
grep -Rin --after-context 1 "all:" $(find -type f -iname "Makefile") | grep -Rin "\-o\ \b\w\+-\?\w\+-\?\w\+\?\?\b"
@mark-d-holmberg
mark-d-holmberg / RUN_SIMPLETON.sh
Created November 30, 2011 20:21
The BASH run script for Simpleton Wumpus World Agent
#!/bin/bash
agent=SIMPLETON
port=31656
trace=1
SLEEP=10
steps=150
seed=1257360045
./RunProg ./WW_Test -p ${port} -d 0 -D 1 -R 1 -s ${steps} -t 0 -S ${SLEEP} -z {seed} &
@mark-d-holmberg
mark-d-holmberg / redcarpet.rb
Created February 15, 2012 04:56 — forked from stephencelis/redcarpet.rb
Redcarpet (Markdown) template handler for Rails 3.1.
class ActionView::Template
class Markdown
def call(template)
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(template.source).inspect
end
end
ActionView::Template.register_template_handler :md, Markdown.new
end
@mark-d-holmberg
mark-d-holmberg / login.php
Created March 22, 2012 19:54
PHP Login Script
<?php
session_start();
/*see if we can echo stuff*/
//if( (!isset( $_SESSION['logged_in'] )) || (!isset( $_SESSION['username' )) )
$logged_in = $_SESSION['logged_in'];
$username = $_SESSION['username'];
// $timestamp = $_SESSION['timestamp'];
$session_id = $_SESSION['session_id'];
//-------------------------
@mark-d-holmberg
mark-d-holmberg / git_diff_wrapper.sh
Created September 5, 2012 21:59
the wrapper for git diff on my iMac at work
#!/bin/sh -
mvim -d -f "$2" "$5"
@mark-d-holmberg
mark-d-holmberg / distribute_article_published_at.rb
Created January 1, 2013 19:48
Given a list of published articles, randomly distribute their published_at date to be between 5 months ago and today.
Article.published.each do |k|
new_published = rand(5.months.ago..Time.now)
k.update_attribute(:published_at, new_published)
end
countries = [
["AF", "Afghanistan"],
["AL", "Albania"],
["DZ", "Algeria"],
["AS", "American Samoa"],
["AD", "Andorra"],
["AO", "Angola"],
["AI", "Anguilla"],
["AQ", "Antarctica"],
["AG", "Antigua and Barbuda"],
@mark-d-holmberg
mark-d-holmberg / bootstrap_and_overrides.css.less
Created January 12, 2013 03:48
How to fix Twitter Bootstrap Missing Icons
@import "twitter/bootstrap/bootstrap";
body {
padding-top: 60px;
}
@import "twitter/bootstrap/responsive";
// Set the correct sprite paths
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
@mark-d-holmberg
mark-d-holmberg / delay.js
Created January 16, 2013 03:05
Delay AJAX Remove
fadeOut().delay(2000).queue(function() { $(this).remove(); });