Skip to content

Instantly share code, notes, and snippets.

Amiel Martin amiel

Block or report user

Report or block amiel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
amiel / application_decorator.rb
Created Nov 3, 2011
Some handy I18nization for my ApplicationDecorator
View application_decorator.rb
class ApplicationDecorator < Draper::Base
# See +ApplicationDecorator.humanize+
def humanize(attribute, key = model.send(attribute), default = key.to_s.humanize)
self.class.humanize attribute, key, default
# By default, humanize the attributes listed.
# Contrived Example:
amiel / my_uploader.rb
Created May 22, 2012
Simple watermarking with Thumbkit and CarrierWave
View my_uploader.rb
class MyUploader < CarrierWave::Uploader::Base
include Thumbkit::Adapters::CarrierWave
# Watermark should always be processed after thumbkit, ensuring that we always
# have a valid image and we don't need to change the extension
def watermark(watermark_image, options = {})
cache_stored_file! if !cached?, watermark_image).watermark!(options)
import Adapter from 'ember-data/adapters/json-api';
import UrlTemplates from "ember-data-url-templates";
export default Adapter.extend(UrlTemplates, {
urlTemplate: '/shops{/shopId}/languages{/id}',
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
amiel /
Created Oct 28, 2011
post-commit git hook for simple deploys

Put the ruby file in .git/hooks/post-commit

Create a deploy script as .deploy_*


# File: .deploy_production
scp -R html

Then use "deploy *" in your commit message.

View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
init() {
this.set('myArray', []);
getNewItem() {
amiel / my-controller.js
Created May 8, 2014
ember-validators with server validation errors
View my-controller.js
MyController = Ember.Controller.extend({
actions: {
save: function() {
this.get('model').save().then(function() {
// Success, maybe transitionToRoute or whatever
}, function(xhr) {
// Oh noes, we had an error, maybe it's a validation error
if (xhr.status == 400) {
$.parseJSON(xhr.responseText).each(function(attribute, errors) {
this.get('errors').set(attribute, errors);
amiel / adapters.user.js
Last active Dec 23, 2016 — forked from samselikoff/mirage.config.js
Mirage dev boilerplate
View adapters.user.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
buildURL(type, id) {
return `/users/${id}.json`;
amiel / controllers.application.js
Last active Sep 9, 2016
Example PromiseProxyMixin issue
View controllers.application.js
import Ember from 'ember';
const { inject } = Ember;
export default Ember.Controller.extend({
myService: inject.service(),
appName: 'Ember Twiddle',
amiel / delete.js
Created Jun 16, 2016
Usage of delete in javascript
View delete.js
object = { foo: 'bar', foobar: undefined };
$.param(object); // => "foo=bar&foobar="
delete object.foobar;
$.param(object); // => "foo=bar"
You can’t perform that action at this time.