Skip to content

Instantly share code, notes, and snippets.


Stephen Ball sdball

View GitHub Profile
sdball / calculate_contentdm_scaling.php
Created September 9, 2010 15:30
A scaling function for CONTENTdm
View calculate_contentdm_scaling.php
* Return CONTENTdm scaling of $width and $height to $maxwidth and $maxheight.
* @param string $width starting width
* @param string $height starting height
* @param string $maxwidth width limit
* @param string $maxheight height limit
* @return array dmscale, dmwidth, dmheight
View bash_profile_snippets.bash
# add "[git]" to the prompt if in a git directory
# example (normal dir):
# user@host:/PATH
# $
# (in git directory)
# user@host:/PATH/GIT/PROJECT
# [git]$
export PROMPT_COMMAND='_GIT_LABEL= ;[ -d ".git" ] && _GIT_LABEL="[git]"'
export PS1="\u@\h:\w\n\${_GIT_LABEL}\$ "
sdball /
Created December 13, 2010 18:15
Calculates arbitrary points in the fibonacci sequence using recursion. This is actually salesforce Apex code, not java.
// this is, obviously, just an apex exploration
// i.e. horribly inefficient
Integer fib(Integer n) {
if (n <= 1) return 1; else return fib(n-1) + fib(n-2);
for (Integer i=0; i<=12; i++) {
sdball / googlemaps_loading_lots_of_points.js
Created January 1, 2011 23:29
A sampling of code for loading/unloading thousands of points as the user pans around the map.
View googlemaps_loading_lots_of_points.js
function requestMarkers() {
// no loading markers when zoomed way out
if (map.getZoom() < 11) { return };
// start dropping markers before the browser bogs down
if (markers.length > 50) {
// [snip typical ajax data request]
success: populateMarkers,
sdball / usa_state_hash.rb
Created January 18, 2011 22:25
United States State Abbreviation Hash
View usa_state_hash.rb
@states = {
AL: "Alabama",
AK: "Alaska",
AZ: "Arizona",
AR: "Arkansas",
CA: "California",
CO: "Colorado",
CT: "Connecticut",
DE: "Delaware",
FL: "Florida",
View central_office_kml_example.xml
<name>Central Office</name>
<description>1049 N 3RD ST</description>
View typical_dsl_coverage_polygon.xml
sdball / index.html
Created July 15, 2011 13:07
Use jQuery to modify URLs that contain a specific string
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Rewriting UR Links</title>
<h1>Rewriting UR Links</h1>
<a href="">Link to that opens in a new tab/window.</a>
sdball / text_to_link.html
Created August 10, 2011 18:01
Text into a link
View text_to_link.html
sdball / gist:1218338
Created September 15, 2011 02:02
gem redis
View gist:1218338
gem 'redis'
gem 'redis-store', '1.0.0.rc1'