Skip to content

Instantly share code, notes, and snippets.

View joshkoenig's full-sized avatar

Josh Koenig joshkoenig

View GitHub Profile
@joshkoenig
joshkoenig / smart_auth.php
Last active August 29, 2015 14:19
HOWTO: http-auth in PHP
<?php
# Here's how you can implement more nuanced logic for http auth.
# Note: this will not protect direct access to images, css, and js files.
# It will only block access to the site itself.
# It will also mean your site is not cached at the Pantheon edge at all.
#
# TODO: this will also block command-line access. To work around that
# we'd need to add an additional no-op check if the site is being accessed
# via Drush or WP-CLI.
@joshkoenig
joshkoenig / gist:1302244
Created October 20, 2011 20:22
tomcat log
[root@josh-twobox titan]# cat /usr/share/tomcat6/logs/localhost.2011-10-20.log
Oct 20, 2011 8:12:44 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class hudson.WebAppMain
java.lang.NoClassDefFoundError: javax/jmdns/impl/tasks/state/Canceler
at javax.jmdns.impl.DNSTaskStarter$DNSTaskStarterImpl.startCanceler(DNSTaskStarter.java:227)
at javax.jmdns.impl.JmDNSImpl.startCanceler(JmDNSImpl.java:1611)
at javax.jmdns.impl.JmDNSImpl.unregisterAllServices(JmDNSImpl.java:1044)
at javax.jmdns.impl.JmDNSImpl.close(JmDNSImpl.java:1810)
at hudson.DNSMultiCast.close(DNSMultiCast.java:54)
at hudson.model.Hudson.cleanUp(Hudson.java:2440)
@joshkoenig
joshkoenig / gist:1302261
Created October 20, 2011 20:27
Catalina log
Oct 20, 2011 8:12:44 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/jenkins] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@2ce07e6b]) and a value of type [org.acegisecurity.context.SecurityContextImpl] (value [org.acegisecurity.context.SecurityContextImpl@68e1ac21: Authentication: org.acegisecurity.providers.UsernamePasswordAuthenticationToken@68e1ac21: Username: developer; Password: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: authenticated]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
@joshkoenig
joshkoenig / pantheon.settings.php
Created December 22, 2011 20:18
Snippit to parse Pantheon environment config
<?php
// Place this in settings.php if you need to load Pantheon config earlier.
// For instance, when using the domain access module.
global $is_https;
$is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
// Load environmental config, if present.
if (isset($_SERVER['PRESSFLOW_SETTINGS'])) {
$pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
foreach ($pressflow_settings as $key => $value) {
"""
Will pull images from a tag.
I'm using this to make a photobook of my brother in law's wedding,
but you might find it helpful for any number of other things.
"""
from instagram.client import InstagramAPI
from pprint import pprint
import urlparse
import urllib
@joshkoenig
joshkoenig / gist:2588846
Created May 3, 2012 20:01
Instructions for testing Drupal 7.14 on Pantheon
From a working clone:
#> git pull http://git.drupal.org/project/drupal.git refs/tags/7.14
#> git push origin master
Now go run update.php in your dev environment and check everything out!
@joshkoenig
joshkoenig / gist:4121633
Created November 20, 2012 22:18
Mixpanel expressions
data = api.request(['engage'], {
'where': 'properties["$created"] > "2012-10-24T13:34:35" and properties["event_count"] > 0'
})
function file_create_url($path) {
<<<<<<< HEAD
// Clean up Windows paths.
$old_path = $path = str_replace('\\', '/', $path);
drupal_alter('file_url', $path);
// If any module has altered the path, then return the alteration.
if ($path != $old_path) {
return $path;
/**
* Implementation of hook_search().
*/
function user_search($op = 'search', $keys = NULL, $skip_access_check = FALSE) {
switch ($op) {
case 'name':
if ($skip_access_check || user_access('access user profiles')) {
return t('Users');
}
@joshkoenig
joshkoenig / wp-config.php
Created March 19, 2014 17:00
This is the wp-config.php supplied by Pantheon to allow automagic operation with WordPress
<?php
/**
* This config file is yours to hack on. It will work out of the box on Pantheon
* but you may find there are a lot of neat tricks to be used here.
*
* See our documentation for more details:
*
* http://helpdesk.getpantheon.com/
*/