Skip to content

Instantly share code, notes, and snippets.

View kdimatteo's full-sized avatar

Keith DiMatteo kdimatteo

View GitHub Profile
@bradwestfall
bradwestfall / S3-Static-Sites.md
Last active May 22, 2024 13:44
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

⚠ This post is fairly old. I don't keep it up to date. Be sure to see comments where some people have posted updates

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation
@pbojinov
pbojinov / canada_states_titlecase.json
Last active May 18, 2024 17:28 — forked from mshafrir/states_hash.json
US states & Canadian Provinces in JSON form
[
{
"name": "Alberta",
"abbreviation": "AB"
},
{
"name": "British Columbia",
"abbreviation": "BC"
},
{
@irazasyed
irazasyed / manage-etc-hosts.sh
Created March 7, 2015 09:16
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1
var httpResponseQueue = Ember.A();
var checkQueueInterval = null;
var checkQueue = function() {
for (var i = 0; i < httpResponseQueue.length; i++) {
var queuedItem = httpResponseQueue[i];
var found = fakehr.match(queuedItem.verb.toUpperCase(), queuedItem.url);
if (found) {
found.respond(queuedItem.status || 200, {'content-type': 'application/json'}, queuedItem.body);
@dgeb
dgeb / orbit-ember-data-adapter.js
Last active January 3, 2016 10:08
A very simple example Orbit adapter implementation for Ember Data that's hard coded with a single Orbit.LocalStorageSource. Note that the Orbit schema could easily be auto-generated from DS models. Also, DS relationships would have to be mapped to Orbit links (and the adapter would need to call `link` / `unlink` methods on Orbit stores).
export default DS.Adapter.extend({
orbitSource: undefined,
init: function() {
this._super();
Orbit.Promise = Ember.RSVP.Promise;
// TODO - autogenerate schema from DS models
var schema = {
idField: 'id',
@spint
spint / disable-back-swipe.js
Created November 15, 2013 09:31
Disabling back history navigation with swipe (chrome)
// http://stackoverflow.com/questions/15829172/stop-chrome-back-forward-two-finger-swipe
$(document).on('mousewheel', function(e) {
var $target = $(e.target).closest('.scrollable-h');
if ($target.scrollLeft () <= 4) {
$target.scrollLeft(5);
return false;
}
});
@XoseLluis
XoseLluis / Object.watch.js
Last active May 15, 2016 02:41
Polyfill for the Object.watch/Object.unwatch functions available in Mozilla browsers
/*
Polyfill for the Object.watch/Object.unwatch functions available in Mozilla browsers
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/watch
you have a test here:
http://www.telecable.es/personales/covam1/deployToNenyures/SourceCode/Object.watch.test.js
and can read more here:
http://deploytonenyures.blogspot.com.es/2013/02/objectwatch-polyfill.html
*/
@hagino3000
hagino3000 / method_missing.js
Last active January 16, 2020 13:11
__noSuchMethod__ for Chrome
/**
* Enable route to __noSuchMethod__ when unknown method calling.
*
* @param {Object} obj Target object.
* @return {Object}
*/
function enableMethodMissing(obj) {
var functionHandler = createBaseHandler({});
functionHandler.get = function(receiver, name) {
@geddski
geddski / nesting.js
Created January 14, 2012 05:08
helper function for nesting backbone collections.
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];