Skip to content

Instantly share code, notes, and snippets.

View joshuapowell's full-sized avatar
☄️
https://info.cern.ch/hypertext/

J.I. Powell joshuapowell

☄️
https://info.cern.ch/hypertext/
View GitHub Profile
@joshuapowell
joshuapowell / preprocess.inc
Created January 26, 2012 02:13
Drupal: Remove as much pre-generated core CSS as possible
<?php
/**
* Implementation of hook_css_alter().
*/
function MYTHEME_css_alter(&$css) {
// Remove core block stylesheet(s)
unset($css[drupal_get_path('module', 'block') . '/block.css']);
@joshuapowell
joshuapowell / preprocess.inc
Created January 26, 2012 02:14
Drupal: Allow for Node Type specific html.tpl.php files (e.g., html--story.tpl.php, html--page.tpl.php, html--webform.tpl.php)
<?php
/**
* Implementation of hook_preprocess_html().
*/
function MYTHEME_preprocess_html(&$variables, $hook) {
if ($node = menu_get_object()) {
if (isset($node->type)) {
$variables['theme_hook_suggestions'][] = 'html__' . str_replace('_', '--', $node->type);
@joshuapowell
joshuapowell / preprocess.inc
Created January 26, 2012 02:16
Drupal: Allow for Node Type specific page.tpl.php files (e.g., page--node--story.tpl.php, page--node--page.tpl.php, page--node--webform.tpl.php)
<?php
/**
* Implementation of hook_preprocess_page().
*/
function MYTHEME_preprocess_page(&$variables, $hook) {
// Allow for page templates, based on node type
if (isset($variables['node'])) {
$variables['theme_hook_suggestions'][] = 'page__node__' . str_replace('_', '--', $variables['node']->type);
@joshuapowell
joshuapowell / template.php
Created January 26, 2012 02:17
Drupal: Automatically clear all site caches and reset all Views (i.e., views that are coded and saved as individual files)
<?php
/**
* Automated Cache Clearing
*
* For development purpose only, this cannot be enabled on a live
* website or else it will make everyone that uses the site sad.
*/
/* Clear all Drupal core caches */
@joshuapowell
joshuapowell / reset.less
Last active September 25, 2024 18:58
LESS: Global LESS CSS reset that gives elements default formatting.
/**
* Global Reset of all HTML Elements
*
* Resetting all of our HTML Elements ensures a smoother
* visual transition between browsers. If you don't believe me,
* try temporarily commenting out this block of code, then go
* and look at Mozilla versus Safari, both good browsers with
* a good implementation of CSS. The thing is, all browser CSS
* defaults are different and at the end of the day if visual
* consistency is what we're shooting for, then we need to
@joshuapowell
joshuapowell / messages.less
Created January 26, 2012 02:22
LESS: LESS CSS basic console and messages (e.g., error, warning, status) to work with Drupal's HTML class attributes
/**
* Messages
*
*
*/
#console {
border: 0;
font-size: 12px;
margin: 14px 0 0;
.messages {

Virtualenv's bin/activate is Doing It Wrong

I'm a Python programmer and frequently work with the excellent [virtualenv][] tool by Ian Bicking.

Virtualenv is a great tool on the whole but there is one glaring problem: the activate script that virtualenv provides as a convenience to enable its functionality requires you to source it with your shell to invoke it. The activate script sets some environment variables in your current environment and defines for you a deactivate shell function which will (attempt to) help you to undo those changes later.

This pattern is abhorrently wrong and un-unix-y. activate should instead do what ssh-agent does, and launch a sub-shell or sub-command with a modified environment.

Problems

@joshuapowell
joshuapowell / gist:e209a4dac5c8187ea8ce
Last active March 11, 2023 18:37
Setup Postgres.app to use PostGIS on OS X

Download and Install Postgres.app

Before we can setup PostGIS we need to have a local version of Postgresql installed and running. The most effecient way to do this is to download and install Postgres.app.

Spatially Enable your Postgres Database

Once Postgres.app is installed in your computers /Applications directory. Open the Terminal and enter the following two commands

psql -d DATABASE_NAME -f /Applications/Postgres.app/Contents/Versions/9.3/share/postgresql/contrib/postgis-2.1/postgis.sql
@joshuapowell
joshuapowell / gist:c637a21caf46371ac42b
Created December 4, 2014 16:06
Selecting Appropriate Colors for a Choropleth

Effectively selecting colors for your choropleth map can be intimidating. Thankfully there are a couple of resources that can help us out.

The first is the ColorBrewer website which allows you to tinker with a preset or custom color pallette over a live map.

The second is a preconstructed D3 Map from the mbostock library that contains pre-defined colors, constructed using ColorBrewer.

http://mbostock.github.io/d3/talk/20111018/choropleth.html

@joshuapowell
joshuapowell / Tutorial
Last active August 29, 2015 14:11
Creating high density (1M+ Map Markers) map using a SHP file and Mapbox.com
## Convert your SHP File to a GeoJSON File
1. Download and Unzip your SHP file
2. Change to the SHP file directory
3. Convert the SHP file to a GeoJSON file
````
ogr2ogr -f "GeoJSON" my_file.geojson my_file.shp
````
## Convert your GeoJSON File to Mapbox Vector Tiles