Skip to content

Instantly share code, notes, and snippets.

View dmgarland's full-sized avatar

Dan Garland dmgarland

View GitHub Profile
@dmgarland
dmgarland / maps.js
Created May 9, 2013 23:32
My bucketlist maps.js
var map;
var timer;
function initMap() {
var mapOptions = {
center: new google.maps.LatLng(51.51121389999999, -0.1198244),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map($("#map-canvas")[0], mapOptions);
@dmgarland
dmgarland / search.js
Created May 2, 2013 15:38
My front-end search feature
$(document).ready(function() {
//$('body').on('change', '#search', function () {
$('#search').change(function() {
var _this = this;
var searchTerm = $(this).val();
var results = _.filter(items, function(item) {
var matchTerm = new RegExp(searchTerm);
return item.name.match(matchTerm);
@dmgarland
dmgarland / instagram.html
Last active December 16, 2015 17:19
Timer
<html>
<head>
<title>Instagram Underscore Practice</title>
<script src="underscore-min.js"></script>
<script src="instafeed.min.js"></script>
<script src="jquery-1.9.1.min.js"></script>
</head>
<body>
<h1>My Amazing Timer Page</h1>
@dmgarland
dmgarland / test.html
Created April 25, 2013 13:17
OnMouseOver
<html>
<head>
</head>
<body>
<div style="width:300px;height:300px;background:red" onmouseover="doStuff('green')" onmouseout="doStuff('red')" id="box">
</div>
<script>
function doStuff(colour) {
@dmgarland
dmgarland / animals.js
Created April 24, 2013 15:24
Inheritance in JS
Animal.prototype = {
constructor: Animal,
name : "",
numberOfLegs: undefined,
speak : function() {
console.log("Hello I am " + this.name);
}
};
function Animal(name, numberOfLegs) {
<% @authors = Author.all %>
<ul>
<% @authors.each do |a| %>
<li><%= link_to a.name, url_for(:controller, :action, :author_name => 'M')%></li>
<% end %>
</ul>
@dmgarland
dmgarland / gist:5375042
Created April 12, 2013 20:52
hello world
Hello world
require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
require 'pry'
class ProductsControllerTest < Test::Unit::TestCase
context "ProductsController" do
setup do
@product = Product.new(:title => "Chocolate Teapot").save
end
should "return all Products when we visit /products" do
get '/products'
@dmgarland
dmgarland / movie_server_test.rb
Created April 5, 2013 15:43
Movie Server Test
require 'test/unit'
require 'rack/test'
require_relative '../movie_server'
class MovieServerTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
@dmgarland
dmgarland / gist:5303972
Created April 3, 2013 18:41
Bit.ly in a few lines...
require 'sinatra'
set :urls, {
:xyz => "http://www.generalassemb.ly"
}
get '/:short_url' do
full_url = settings.urls[params[:short_url].to_sym]
if full_url
redirect full_url