Skip to content

Instantly share code, notes, and snippets.

View ungoldman's full-sized avatar
🤔
💭

Nate Goldman ungoldman

🤔
💭
View GitHub Profile
@ungoldman
ungoldman / config.rb
Last active December 25, 2015 05:29
middleman instance variables that are collections of pages
# ...
def get_pages
# get an array of pages whose source filename contains .html
@pages = sitemap.resources.find_all { |page| page.source_file.match(/\.html/) }
# sort them by an arbitrary YAML frontmatter property called 'order'
@pages.sort! { |a,b| a.data['order'].to_i <=> b.data['order'].to_i }
end
@ungoldman
ungoldman / sum.js
Last active December 23, 2015 10:09
sums in node
var usage = 'Usage: node sum.js val1 val2 [other_vals]';
var nums = process.argv.slice(2);
var sum = 0;
// as a simple program
console.log(nums);
if (nums.length < 2) {
console.log(usage);
@ungoldman
ungoldman / rim-fire.json
Last active December 21, 2015 15:48
active fire data from EOSDIS in GeoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ungoldman
ungoldman / github.rb
Created August 20, 2013 21:34
learn you an octokit!
# make sure octokit and highline are actually installed first
require 'octokit'
require 'highline/import'
login = ask("Enter your login: ") { |q| q.echo = false }
pass = ask("Enter your pass: ") { |q| q.echo = false }
@client = Octokit::Client.new(:login => login, :password => pass)
@ungoldman
ungoldman / view.js
Created July 26, 2013 17:58
bind marionette view to model changes
Views.ListItem = Marionette.ItemView.extend({
template: 'item',
tagName: 'li',
className: 'gt-result',
initialize: function() {
// THIS
this.listenTo(this.model, 'change', this.render);
this.listenTo(this.model, 'change', this.renderShape);
},
@ungoldman
ungoldman / leaflet.tooltip.override.js
Created July 24, 2013 22:14
how to override a leaflet method
L.Tooltip.prototype.updatePosition = function(latlng) {
var pos = this._map.latLngToLayerPoint(latlng);
L.DomUtil.setPosition(this._container, pos);
this._container.style.display = 'inline-block';
console.log('doing something');
return this;
}
/**
Usage: Just include this script after Marionette and Handlebars loading
IF you use require.js add script to shim and describe it in the requirements
*/
(function(Handlebars, Marionette) {
Marionette.Handlebars = {
path: 'templates/',
extension: '.handlebars'
};
@ungoldman
ungoldman / spatialReference.js
Created June 1, 2013 21:35
ArcGIS JS spatial reference helpers
define([], function(){
return {
// check if an object is a geometry
isGeometry: function(object){
return object.isInstanceOf(esri.geometry.Geometry);
},
// check if an object is a graphic
@ungoldman
ungoldman / person.css
Created March 21, 2013 18:34
gist with a twist
/* - - - - - - - - - person Bubbles - - - - - - - */
.person {
height: 50px;
position: absolute;
width: 50px;
}
.portrait {
border: 4px solid #fff;
border-radius: 50%;
@ungoldman
ungoldman / application_controller.rb
Created February 21, 2013 21:24
force_ssl replacement method
class ApplicationController < ActionController::Base
[...]
private
def switch_to_https
return if Rails.env.development? ||
request.ssl? ||
request.protocol.include?('https') ||