Skip to content

Instantly share code, notes, and snippets.

View lukes's full-sized avatar

Luke Duncalfe lukes

View GitHub Profile

I'm trying to run the rails test suite but I keep getting this error:

$ bundle exec rake postgresql:build_databases
createdb: database creation failed: ERROR:  encoding UTF8 does not match locale en_US
DETAIL:  The chosen LC_CTYPE setting requires encoding LATIN1.
createdb: database creation failed: ERROR:  encoding UTF8 does not match locale en_US
DETAIL:  The chosen LC_CTYPE setting requires encoding LATIN1.
@lukes
lukes / application-controller.js.coffee
Created August 6, 2014 23:13
Simplest Ember 5 Star Rating component
App.ApplicationController = Ember.ObjectController.extent
starRatingValue: Ember.computed(->
"3"
)
@lukes
lukes / initializers-current-user.js
Last active August 29, 2015 14:07
Using Ember.ObjectProxy for currentUser
// (Rename to current-user.js and place in /initializers)
// Ember now complains that you can't type inject a controller into a controller
// so use an Ember.ObjectProxy for currentUser instead.
//
// Ember.ObjectProxy allows you to set a content value, and will delegate
// all getters and setters to its content.
import DS from "ember-data";
import CurrentUser from "../models/current-user";
@lukes
lukes / controllers-application.js
Created October 6, 2014 22:17
Making currentPath available to all controllers
import Ember from 'ember';
export default Ember.ObjectController.extend({
currentPathDidChange: function() {
this.set('path.content', this.get('currentPath'));
}.observes('currentPath')
});
@lukes
lukes / adapters-open-weather-map.js
Last active August 29, 2015 14:07
Ember OpenWeatherMapAdapter
import Ember from 'ember';
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
headers: {
"x-api-key": "[Your OpenWeatherMap API Key]"
},
findQuery: function(store, type, query) {
@lukes
lukes / Brocfile.js
Created December 7, 2014 20:38
Enable fingerprinting for all environments except development
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp({
// Custom settings for broccoli-assets-rev
// See http://www.ember-cli.com/#asset-compilation
fingerprint: {
enabled: true
}
});
@lukes
lukes / rant.js
Created December 18, 2014 21:38
<rant> to actual rant
// <rant> to actual rant
// (requires modern browsers)
var rants = document.getElementsByTagName('rant');
for (i=0;i<rants.length;i++) {
var rant = new SpeechSynthesisUtterance(rants[i].innerHTML);
window.speechSynthesis.speak(rant);
}
@lukes
lukes / models-mymodel.js
Created March 23, 2015 02:30
Ember DS.attr('object') -- (Allow declaring JSON as a valid property for an Ember model)
// save to app/models
import DS from "ember-data";
export default DS.Model.extend({
myProperty: DS.attr('object');
});
@lukes
lukes / application.js
Last active August 29, 2015 14:18
Reliably return the currentUser after login or app reload (with Ember simple-auth-devise)
// Save as routes/application.js
import Ember from 'ember';
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(ApplicationRouteMixin, {
beforeModel: function(transition) {
this._super(transition);
{
"name":"Afghanistan", // english name
"country-code":"004", // unique numeric code
"alpha-2":"AF", // unique 2-character code
"alpha-3":"AFG", // unique 3-character code
"sub-region-code":"034", // geographical sub-region code
"region-code":"142", // macro geographical (continental) region code
"iso 3166-2":"ISO 3166-2:AF" // ISO 3166-2 code for principle subdivision
}