Skip to content

Instantly share code, notes, and snippets.

@mapsam
mapsam / gallery.css
Last active May 14, 2021 12:57
Wordpress ACF Lightbox
@mapsam
mapsam / README.md
Created November 24, 2014 21:50
Leaflet layer toggling

Showing the functionality of toggling layers in Leaflet while preserving their reference for later usage (i.e. turning the layer back on). This is useful when working with many layers in leaflet and turning opacity to 0 won't cut it because it can have negative effects when hover and click events require properly layered DOM elements.

Important takeaways:

  • It's important to scope your data to access it globally, or at least within your appropriate scope.
  • Turn off a layer by referencing its variable using the removeLayer() method.
  • Turn on a layer by referencing its variable using the addLayer() method.
@mapsam
mapsam / typeahead.css
Created January 15, 2015 23:35
typeahead styles
.typeahead,
.tt-query,
.tt-hint {
width: 396px;
height: 30px;
padding: 8px 12px;
font-size: 24px;
line-height: 30px;
border: 2px solid #ccc;
-webkit-border-radius: 8px;
@mapsam
mapsam / index.html
Last active August 29, 2015 14:13
loop through array to place as text
<h1>Code for America <br><span id="thing">FTW</span></h1></div>
@mapsam
mapsam / question.markdown
Created January 20, 2015 00:04
scope question for @thebigspoon

So for this random project (another one) I'm working on geocodeing a spreadsheet of addresses and adding them to a map. I'm building with the constructor.prototype stuff that you showed me with Guss and am wondering how far I can extend the prototype for more organization. Say for instance I'd like to split my functions into categories such as "spreadsheet" and "map" where I could essentially do all spreadsheet functions by calling:

this.spreadsheet.get OR this.spreadsheet.query OR this.spreadsheet.print_to_dom

and similarly could use my mapping functions like:

this.map.init_tiles OR this.map.add_points

basically keeping everything scoped within the same set of parent functions instead of all at the same parent constructor level.

@mapsam
mapsam / geocode_on_load.html
Last active August 29, 2015 14:16
Script that makes a call to the Census geocoding API when the page loads
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--
here we are including the jQuery library specifically to use
the `$.ajax()` function for making a call to the Census API
-->
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
@mapsam
mapsam / input_geocode.html
Created February 27, 2015 21:17
This example allows the user to enter an address and pass the value to a function that calls the Census geocoding API
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<style>
body {
background: salmon;
}
@mapsam
mapsam / get_latlng.html
Created February 27, 2015 21:27
Retrieve the Latitude and Longitude values from the Census geocoding API
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<style>
body {
background: MediumAquaMarine;
}
@mapsam
mapsam / this.md
Last active August 29, 2015 14:17
_this = this vs. .bind(this)

Some recent work has pushed me into scoping my javascript more consciously. There is a lot of usage of this on a local level that can make things all sorts of confusing. There are multiple avenues to properly scope your javascript through your functions, but keeping this scoped properly to use in other scopes gets complicated. I use two different methods and am unsure which is best:

assigning to a new variable

Can now be used inside other functions as _this when you also need the specific function's this scope.

var _this = this;

using .bind(this)

@mapsam
mapsam / drive.md
Created March 17, 2015 17:13
Drive Reorganization for Team RVA

Here's a first crack at re-organizing the Drive. Thinking we have three buckets:

  1. Admin
  2. Projects/Research
  3. Notes/Meetings

What do you think? Probably requires a few currently existing folders to be renamed. The goal is to start putting some of our research into project-specific folders so we can have it all in one place. That's what makes sense to me, but if it doesn't to you this is definitely open for critique!

Team Admin *