Skip to content

Instantly share code, notes, and snippets.

@mfdj
mfdj / console_methods.html
Last active August 25, 2015 21:59
browser console methods
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>console methods</title>
</head>
<body>
<script>
console.assert(1 === true, "assert 1 is strictly equal to true");
console.log({a: "eh", b: "bee"}, [1,2,4,8,16]);
@mfdj
mfdj / cdp.sh
Last active August 26, 2015 03:08
cdp function - dead simple approach to creating and visiting directory aliases
# directory where aliases are stored
export CDP_PATH=~/dotfiles/cdp_symlinks
# cdp --add <-- creates an alias of the current direcotry path, named for the current folder name
# cdp --add custom-name <-- same as above with custom-name
# cdp another-name <-- change into alias
# cdp --list <-- see all aliases available to cdp
# cdp --remove some-name <-- remove an alias
# cd `cdp --path` <-- change into the directory where aliases are stored
function cdp {
@mfdj
mfdj / rand_int.sh
Last active August 26, 2015 21:06
BASH random integer function using /dev/urandom
function rand_int {
local min=$1
local max=$2
# dd if=/dev/urandom bs=1 count=1 <-- grab a single 1-byte frame from /dev/urandom
# | od -An -vtu1 <-- convert raw-binary to a decimal
# | tr -d ' ' | tr -d "\n"` <-- trim spaces and line-breaks from output of od (gotta be better way)
local randByte=`dd if=/dev/urandom bs=1 count=1 2> /dev/null | od -An -vtu1 | tr -d ' ' | tr -d "\n"`
@mfdj
mfdj / openssl_ca_recipe.sh
Last active August 29, 2015 13:57
Generate multiple clean, workable local "mini Certificate Authorities" preconfigured to be good enough. Based on OpenSSL. Developed for Bash on OSX (should be pretty portable).
#!/usr/bin/env bash
function defaultinput()
{
local LABEL=$1
local DEFAULT=$2
local __return=$3
echo -n "$LABEL [$DEFAULT] "
read input_a
if [[ -z "$input_a" ]]; then
@mfdj
mfdj / colon_to_multiline.sh
Last active August 29, 2015 13:57
view $PATH (or any colon separated string) as a readable multiline output — tested on OSX bash
##### first attempt
# one-liner
echo $PATH | sed -e "s~:~\\`echo -e '\n\r'`~g"
# bash function
sep2ln()
{
local INPUT=$1
local SEPARATOR=$2
@mfdj
mfdj / .htaccess
Last active August 29, 2015 14:00
Adding HSTS headers to all responses when using php-fpm + mod_fastcgi using basic php or Symfony2
# add HTTP Strict Transport Security (HSTS) header to all *non-php* responses
# - mod_fastcgi apparently ignores mod_headers?
# - see: https://www.owasp.org/index.php/HTTP_Strict_Transport_Security
Header set Strict-Transport-Security "max-age=7776000"
@mfdj
mfdj / config.yml
Last active August 29, 2015 14:03
Extract database-related and other parameters from PagodaBox's environment — override parameters.yml and keep your secrets out of your repo
# file: app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: parameters_pagoda.php } # import after parameters.yml to override it's values
- { resource: security.yml }

Keybase proof

I hereby claim:

  • I am mfdj on github.
  • I am mfdj (https://keybase.io/mfdj) on keybase.
  • I have a public key whose fingerprint is A056 0C76 83D0 CD21 912A 34AB 45ED 067E 0D3B 9AC3

To claim this, I am signing this object:

@mfdj
mfdj / php_ini_path.sh
Created January 19, 2015 08:00
grab the php.ini path in *nix shell (tested on osx bash)
# print it
$ echo `php -i | grep 'Load.*Config.*File.*=>' | sed s/'.* => '/''/`
# open it
$ $EDITOR `php -i | grep 'Load.*Config.*File.*=>' | sed s/'.* => '/''/`
# open it in sublimetext
$ subl `php -i | grep 'Load.*Config.*File.*=>' | sed s/'.* => '/''/`
@mfdj
mfdj / angular_module_fights.html
Last active August 29, 2015 14:14
angular.js naming conflicts
<!DOCTYPE html>
<html lang="en" ng-app="fightApp">
<head>
<meta charset="UTF-8">
<title>angular module fights</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h3>Module Eh vs. Module Bee</h3>