Skip to content

Instantly share code, notes, and snippets.

@narthur
narthur / Factory.php
Last active May 5, 2019 08:31
[Object Factory with Boundary Dependency Injection] #tdd
<?php
namespace Avorg;
if (!\defined('ABSPATH')) exit;
class Factory
{
private $namespace = __NAMESPACE__;
@narthur
narthur / index.html
Created December 20, 2017 15:11
Section Background Strategies
<div class="section"></div>
@narthur
narthur / index.html
Last active December 19, 2017 19:41
Triangle Algorithm Simple JS
<div class="container">
<div class="content">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Libero vero animi suscipit debitis unde mollitia veritatis sapiente maxime velit obcaecati repudiandae incidunt, corrupti, voluptates ad. Recusandae itaque doloribus quibusdam fugit ut quis cumque sit, fugiat, culpa perspiciatis mollitia inventore hic tempore aspernatur aliquam quo. Consequatur saepe a cumque! Dicta dignissimos facilis laborum impedit ad sunt quam tenetur? Repellat, officiis sed veritatis possimus ipsum, labore quam eligendi est minus quae incidunt saepe. Consequatur laudantium atque qui soluta, voluptate dolores dolore blanditiis.</div>
<div class="triangle"></div>
</div>
@narthur
narthur / q-num-mem.py
Created May 13, 2016 22:38
Have a list of problems? Want to memorize it Cram.com-style? This is the script for you.
#!/usr/bin/python
import sys
from random import randint
quantity = int(sys.argv[1])
cards = [False] * quantity
def memorize(cards):
while False in cards:
@narthur
narthur / .gitconfig
Created April 4, 2016 21:10 — forked from samsalisbury/.gitconfig
Git diff and merge with p4merge (OSX)
[merge]
keepBackup = false
tool = p4merge
[mergetool "p4merge"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\""
keepTemporaries = false
trustExitCode = false
keepBackup = false
[diff]
tool = p4merge
@narthur
narthur / enable_wp_debugging.php
Created March 13, 2016 17:16
Enable WordPress debugging
// Source: https://www.smashingmagazine.com/2011/03/ten-things-every-wordpress-plugin-developer-should-know/
// Replace `define('WP_DEBUG', false);` in `wp-config.php` with the following lines:
// Turns WordPress debugging on
define('WP_DEBUG', true);
// Tells WordPress to log everything to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Doesn't force the PHP 'display_errors' variable to be on
@narthur
narthur / getDirSize.sh
Created January 26, 2016 15:38
Get size of a directory in Unix terminal
# Source: http://unix.stackexchange.com/a/3021/138212
du -sh directory_name
@narthur
narthur / compareDirectories.sh
Last active January 26, 2016 15:32
Compare two directories recursively
# Source: http://www.unixtutorial.org/2008/06/how-to-compare-directories-in-unix/
diff --recursive --brief /tmp/dir1 /tmp/dir2
@narthur
narthur / listBySizeRecursively.sh
Created January 12, 2016 19:11
Sort contents by file size recursively
ls -RlhS
# -R: recursive
# -l: long listing
# -h: human readable file sizes
# -S: sort by file size
@narthur
narthur / findLargestFile.sh
Created January 12, 2016 19:10
Find largest file recursively
sudo find /path/to/search/ -size +15M -printf "%s - %p\n" | sort -n | tail