Skip to content

Instantly share code, notes, and snippets.

View nathanielks's full-sized avatar

Nathaniel nathanielks

View GitHub Profile
@nathanielks
nathanielks / calc.js
Created November 27, 2015 02:50
Super simple way to calculate how long an egghead.io course is
var seconds = 0;
$('.table.table-condensed .info-line small.duration').each(function(){
var s = this.innerText.split(':');
seconds += s[0] * 60;
seconds += s[1] * 1;
});
console.log(seconds/60);
@nathanielks
nathanielks / Readme
Created September 7, 2012 04:46
jQuery Element Inline Distributor
Description:
I wrote this so that I could evenly distribute elements in a line. Here's an example that may explain better than words: http://cl.ly/JHnp, http://jsfiddle.net/nathanielks/pvGcz/4/. What it does it take the parent element and scans it for specific child elements. It then calculates the various widths and adds a left margin accordingly. The reason each element is given a display: block and float:left is because of a weird bug with display: inline. The script requires the elements to displayed inline initially, but because inline elements have a few extra pixels around them, the elements aren't all contained, even though the math is right. Really weird. Anyway, here's how you use it.
Usage:
$('#parent').distributeElements();
Here's the demo: http://jsfiddle.net/nathanielks/pvGcz/4/
@nathanielks
nathanielks / leaflet-init.js
Created July 27, 2012 00:38
Leaflet Focus Overlay
$(document).ready(function(){
var center = new L.LatLng(-18.9717, -3.53815); // geographical point (longitude and latitude)
var map = new L.Map('map', {
scrollWheelZoom: false,
}).setView(center, 3);
var watercolor = new L.StamenTileLayer("watercolor").addTo(map);
var overlayUrl = '/path/to/image.png',
@nathanielks
nathanielks / functions.php
Created March 14, 2012 21:25 — forked from johnmegahan/functions.php
Extended Walker class for use with the Twitter Bootstrap toolkit Dropdown menus in Wordpress.
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );
@nathanielks
nathanielks / wordpress.php
Created February 1, 2012 19:58 — forked from cogentParadigm/wordpress.php
Automated Wordpress Installer
#!/usr/bin/php
<?php
$usage = "Automated Wordpress installer\nby Ali Gangji\nUsage: wordpress install_dir -u dbuser -p dbpass -d dbname\nOptions:\n";
$usage .= " -u dbuser Database username\n";
$usage .= " -p dbpass Database password\n";
$usage .= " -d dbname Database name\n";
$usage .= " -h dbhost Database host\n";
$usage .= " --private Hide blog from search engines\n";
$usage .= " --prefix prefix Database prefix\n";
if ($argc < 2) {

Keybase proof

I hereby claim:

  • I am nathanielks on github.
  • I am nathanielks (https://keybase.io/nathanielks) on keybase.
  • I have a public key whose fingerprint is E5F6 FFB4 3651 D39A 25B9 1DAD FE02 07A3 8BD5 4DC4

To claim this, I am signing this object:

@nathanielks
nathanielks / Vagrantfile
Created September 26, 2014 21:22
Improved bedrock-ansible Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version '>= 1.5.1'
Vagrant.configure('2') do |config|
config.vm.box = 'roots/bedrock'
# Required for NFS to work, pick any local IP
config.vm.network :private_network, ip: '192.168.50.5'
<?php
/*
* Plugin Name: wpMandrill MS
* Plugin URI: trepmal.com
* Description: Network-wide settings for wpMandrill.
* Version: 2013.04.01
* Author: Kailey Lampert
* Author URI: kaileylampert.com
* License: GPLv2 or later
* TextDomain: wpmandrill-ms