Skip to content

Instantly share code, notes, and snippets.

View steinbring's full-sized avatar

Joe Steinbring steinbring

View GitHub Profile
@steinbring
steinbring / index
Created August 10, 2014 16:42
Loop over an array, inside of another array using ng-repeat; limit output using ng-show
<ul>
<li ng-repeat="marketCity in marketCities">
<h2>{{marketCity.label}}</h2>
<ul>
<li ng-repeat="station in marketCity.stations">
<div class="StationInfo">
<div class="label">
{{station.orgDisplayName}}
</div>
@steinbring
steinbring / SortStations.js
Created August 10, 2014 16:27
Take an array of stations (with marketCity as an attribute) and create an array of marketCities (with stations as an attribute)
// Define the unique market cities
$scope.marketCities = [];
for (var i = 0; i < data.query.results.station.length; i++){
// if it isn't already there, add it
if(i !== 0 && data.query.results.station[i].marketCity !== data.query.results.station[i-1].marketCity){
$scope.marketCities.push({ label: data.query.results.station[i].marketCity, stations: [data.query.results.station[i]]});
}else if(i == 0){
$scope.marketCities.push({ label: data.query.results.station[i].marketCity, stations: [data.query.results.station[i]]});
}else if(data.query.results.station[i].id !== data.query.results.station[i-1].id){
// is the market already there? well, just add the station then.
@steinbring
steinbring / geolocate.html
Created May 11, 2014 21:03
How to use JavaScript to sort a list of locations by how far they are from your current location
<!--
Joe Steinbring
http://steinbring.net
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
@steinbring
steinbring / gist:d5ce33ad41691a762966
Created May 3, 2014 17:32
How to use navigator.geolocation.getCurrentPosition(), Google Reverse Geocoding API, the Google Static Maps API, and the Google Street View API to find yourself
<!--
Joe Steinbring
http://steinbring.net
///////////////////////
This is part 2. To see the original version, check out https://gist.github.com/steinbring/368a9e693c8c765125df.
-->
<!DOCTYPE html>
<html>
<head>
<title>Find Me!</title>
@steinbring
steinbring / Geolocation.html
Created April 30, 2014 03:34
How to use navigator.geolocation.getCurrentPosition() and the Google Reverse Geocoding API to prepopulate an address form
<!DOCTYPE html>
<html>
<head>
<title>Find Me!</title>
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
@steinbring
steinbring / PocketJoe.html
Created February 6, 2014 05:21
Pocket Joe 0.02 - This is a sample Android app that I created, to help teach myself PhoneGap. More info is available at: http://steinbring.net/2014/pocket-joe-revisited-joe-evolves-his-phonegap-skills/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Pocket Joe</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jquery.mobile-1.4.0.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.4.0.min.js"></script>
@steinbring
steinbring / PocketJoe.html
Last active January 4, 2016 15:29
This is meant to be a very basic jQuery/HTML/CSS RSS reader. It uses YQL to turn the XML feed into a JSON feed that the browser's origin limits are alright with.
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Pocket Joe</title>
<!-- jQuery CDN -->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<!-- jQuery UI CDN -->
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<!-- A jQuery UI CSS -->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
@steinbring
steinbring / WithAccept.cfm
Last active January 3, 2016 15:19
I've been having trouble with cffile on a particular website. I created this as a test of a hypothesis. I think cffile's accept attribute is borked on CF10. I tested it on CentOS/Apache/CF10 Standard and localhosted on Win7. Go to http://steinbring.net for the explanation.
<form method="post" enctype="multipart/form-data">
<input name="theFile" type="file">
<input name="submitButton" name="submit" type="submit" value="Upload">
</form>
<cfif isDefined("form.theFile")>
<!--- Is there a file? Upload it to the files folder. --->
<cffile action="upload"
filefield="theFile"
accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
@steinbring
steinbring / DecimalToBinary.htm
Last active December 27, 2015 23:09
This very simple HTML + JavaScript app converts decimal numbers to unsigned binary and back again. It can handle values from 0 to 2^64/2. I mostly just did this because I was curious. I doubt it would have much value beyond a CS class or something.
<!--
Joe Steinbring
http://steinbring.net
11/10/2013
-->
<html>
<head>
<title>Decimal to Binary Converter</title>
</head>
<body>
@steinbring
steinbring / UseVocabulary.cfm
Created September 2, 2013 20:03
This is an experiment in the dynamic population of a variable scope, based upon the content within a table. It could be really useful for the localization of content.
<cfsilent>
<cfif isDefined("url.language")>
<cfquery name="VocabQuery" datasource="erp">
select vcName as name,
vcValue as value,
vcLanguage as language
from tblVocab
where vcLanguage = <cfqueryparam cfsqltype="cf_sql_varchar" value="#url.language#">
</cfquery>
<cfset variables.vocabulary = StructNew()>