Skip to content

Instantly share code, notes, and snippets.

@jeremykendall
jeremykendall / force-ntp-update
Created October 6, 2014 15:00
Forcing a clock update using NTP: bash script edition
#!/bin/bash
# Forces an ntp update
#
# Based on SO user Martin Schröder's answer to "How to force a clock update
# using ntp?": http://askubuntu.com/a/256004/41943
# Fail fast (set -e will bail at first error)
set -e
if [ "$EUID" -ne 0 ]; then

Keybase proof

I hereby claim:

  • I am jeremykendall on github.
  • I am jeremykendall (https://keybase.io/jeremykendall) on keybase.
  • I have a public key whose fingerprint is F208 596D C3AF 4E0F 5799 3253 AE91 19ED 6A12 CA18

To claim this, I am signing this object:

@jeremykendall
jeremykendall / composer.lock.diff
Created January 16, 2014 20:48
When I run `composer update vendor/package` or `compser update --lock` all of the reference hashes are changed to exact versions, and package versions with the tilde operator are changed to their equivalent version ranges. Here's a portion of the diff to help. I've uninstalled and reinstalled composer, cleared the `~/.composer` cache, rebooted m…
"dist": {
"type": "zip",
- "url": "https://<private-git-repo>/repos/mirrors/doctrine-doctrine-bundle/zipball/765b0d87fcc3e839c74817b7211258cbef3a4fb9?access_token=981ac7c34450e7a84f7252b43cdc508ed1748d3e",
- "reference": "765b0d87fcc3e839c74817b7211258cbef3a4fb9",
+ "url": "https://<private-git-repo>/repos/mirrors/doctrine-doctrine-bundle/zipball/v1.2.0?access_token=981ac7c34450e7a84f7252b43cdc508ed1748d3e",
+ "reference": "v1.2.0",
"shasum": null
},
"require": {
"doctrine/dbal": ">=2.2,<2.5-dev",
@jeremykendall
jeremykendall / password_hash_example.php
Last active January 19, 2022 07:50
Example of password hashing and verification with password_hash and password_verify. This script is intended to be run from the command line like so: 'php -f password_hash_example.php'
<?php
/**
* Example of password hashing and verification with password_hash and
* password_verify
*
* This script is intended to be run from the command line
* like so: 'php -f password_hash_example.php'
*
* @see http://stackoverflow.com/a/20809916/1134565
@jeremykendall
jeremykendall / csv-to-array
Created November 22, 2013 14:02
Script that creates a php array from a csv file and writes the php array to file.
#!/usr/bin/env php
<?php
if (!$argc == 3) {
die('Please provide input and output file names');
}
$file = $argv[1];
$output = $argv[2];
@jeremykendall
jeremykendall / frustrating.php
Last active December 26, 2015 18:08
To have to resort to a hack like this to get nav highlighting for a custom post type is ridiculous. Especially when it's a feature that's been requested for 3+ years (http://core.trac.wordpress.org/ticket/16382) and Google is chock full of "How the f*ck do I do this?" results: https://www.google.com/search?q=wp+current_page_parent+cpt&oq=wp+curr…
<?php
add_filter('nav_menu_css_class', 'namespace_menu_classes', 10, 2);
function namespace_menu_classes($classes , $item)
{
if (get_post_type() == 'company' || is_archive('company')) {
$classes = str_replace('current_page_parent', '', $classes);
if (strpos($item->url, 'portfolio') !== false) {
@jeremykendall
jeremykendall / example.pp
Created September 27, 2013 03:33
Changing apache user and group in /etc/apache2/envvars using sed in a puppet exec. Stolen from https://github.com/Intracto/Puppet/blob/master/apache2/manifests/init.pp#L12-L26
exec { "sed -i 's/www-data/vagrant/g' /etc/apache2/envvars":
onlyif => "/bin/grep -c 'www-data' /etc/apache2/envvars",
notify => Service['apache2'],
require => Package['apache2'],
}
@jeremykendall
jeremykendall / oops
Last active December 18, 2015 04:59
This was the reason I sent the "DIRECTORY_SEPARATOR" does not exist tweet (https://twitter.com/jeremykendall/status/342985273774321665). Boy am I embarrassed.
# php -v
PHP 5.3.14 (cli) (built: Aug 24 2012 12:56:43)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
# php -a
Interactive shell
php > var_dump(directory_separator)
php > var_dump(DIRECTORY_SEPARATOR);
@jeremykendall
jeremykendall / first.js
Created December 9, 2012 05:57
gist-vim
var http = require('http');
http.createServer(function(request, response) {
response.writeHead(200);
response.end("Hello, dogg!");
}).listen(9090);
console.log('Listening on port 9090');
var http = require('http');
http.createServer(function(request, response) {
response.writeHead(200);
response.end("Hello, dogg!");
}).listen(9090);
console.log('Listening on port 9090');