Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephen Ball sdball

View GitHub Profile
@sdball
sdball / self_instance_demo.rb
Created May 1, 2014
self vs instance vs local variables in initialize
View self_instance_demo.rb
class UsingSelf
attr_accessor :a, :b, :c
def initialize(a, b, c)
self.a = a
self.b = b
self.c = c
end
end
class UsingInstance
@sdball
sdball / keybase.md
Created May 12, 2014
keybase proof
View keybase.md

Keybase proof

I hereby claim:

  • I am sdball on github.
  • I am sdball (https://keybase.io/sdball) on keybase.
  • I have a public key whose fingerprint is D718 9FCA 7760 1079 3990 C5AE 9337 38E4 021E 0115

To claim this, I am signing this object:

View loltie.txt
lol lol
<o>
|
|
|
>o< "I've lost R2!"
@sdball
sdball / calculate_contentdm_scaling.php
Created Sep 9, 2010
A scaling function for CONTENTdm
View calculate_contentdm_scaling.php
<?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
sdball / apex_fib.apex.java
Created Dec 13, 2010
Calculates arbitrary points in the fibonacci sequence using recursion. This is actually salesforce Apex code, not java.
View apex_fib.apex.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++) {
System.debug(fib(i));
}
@sdball
sdball / googlemaps_loading_lots_of_points.js
Created Jan 1, 2011
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) {
dropSuperfluousMarkers();
}
$.ajax({
// [snip typical ajax data request]
success: populateMarkers,
@sdball
sdball / usa_state_hash.rb
Created Jan 18, 2011
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 typical_dsl_coverage_polygon.xml
<Placemark>
<styleUrl>#dsl</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-83.98093654387421,34.36732
-83.98223988881587,34.377583641421
-83.98610089352155,34.38739925343817
View central_office_kml_example.xml
<Placemark>
<name>Central Office</name>
<description>1049 N 3RD ST</description>
<styleUrl>#co</styleUrl>
<Point>
<coordinates>-99.73335,32.45157</coordinates>
</Point>
</Placemark>