Skip to content

Instantly share code, notes, and snippets.

@spieker
spieker / test.md
Created March 29, 2017 18:36
Start Phoenix project with Docker
docker run -it --rm --name elixir-inst1 -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e APP_NAME=foo elixir \
  mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez; \
  apt-get update; \
  apt-get install -yy nodejs-legacy; \
  mix phoenix.new $APP_NAME; \
  cd $APP_NAME; \
  mix deps.get
@spieker
spieker / localized-transform.js
Last active December 5, 2016 10:26
Translated attribute for ember-data
import Transform from 'ember-data/transform';
export default Transform.extend({
deserialize(serialized) {
return Ember.Object.create(serialized);
},
serialize(deserialized) {
return deserialized;
}
@spieker
spieker / application.controller.js
Last active August 23, 2017 23:46
nested attributes ember example
import Ember from 'ember';
import Serializer from '../serializers/author';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
serialized: Ember.computed(function() {
return JSON.stringify(this.get('model').serialize(), null, 2);
})
});
module Concerns
module AasmStateEvent
extend ActiveSupport::Concern
included do
attr_accessor :state_event
end
# It behaves just like `save!`, but when `state_event` was set through
# `assign_attributes` before, `save!` uses the given state with a `!` to
@spieker
spieker / pundit_namespaces.rb
Last active January 24, 2018 01:34
Namespaces for Pundit policies
# This concern enables namespaces in Pundit. In order to use it, put this
# module into the `app/controllers/concerns` folder of your project and then
# include the module into the controller you want to namespace the policies in
# after the include of Pundit.
#
# To secify the namespace to use, overwrite the `pundit_namespace` method on
# your controller then.
#
# Example
# =======
module.exports = App.Item = App.Model.extend
_attrs: ['title', 'note']
token: null
title: null
note: null
max_assignments_count: 0
assignments_count: 0
save: (viddleToken) ->
if @get('isNew')
@constructor.createRecord(@,
@spieker
spieker / .gitignore
Created March 16, 2012 16:51
nav-composer
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/