Skip to content

Instantly share code, notes, and snippets.

@tarmann
tarmann / components.my-component.js
Created August 3, 2017 13:36
computed('val') vs computed('val.[]')
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
replace(){
this.set('data', []);
},
add(){
this.get('data').pushObject('something');
import Ember from 'ember';
export default Ember.Component.extend({
init(){
this._super(...arguments);
this.set('state', 'stopped');
},
didStateChanged: Ember.observer('state', function(){
@tarmann
tarmann / mailinator.js
Created October 22, 2013 12:31
Bookmarklet for Mailinator accounts
javascript: (function () {
var user = prompt('What user account you want to access?', 'defaultUser');
window.location.href = 'http://mailinator.com/inbox.jsp?to=' + user;
}());
@tarmann
tarmann / gist:5626210
Last active December 17, 2015 14:39
JavaScript: Underscore Mixin Namespace
/*
* Usage: _.namespace('App.Namespace.Here');
*
*/
_.mixin({
namespace: function (path) {
var objects = path.split('.'),
namespace = window;
@tarmann
tarmann / Underscore.js
Created May 21, 2013 19:52
JavaScript: Underscore Mixin for Namespacing
_.mixin({
namespace: function (path) {
var objects = path.split('.'),
namespace = window;
_.each(objects, function(obj, i){
namespace[obj] = namespace[obj] || {};
namespace = namespace[obj]
});
@tarmann
tarmann / ui.forms.cascadingdropdowns.js
Created May 21, 2013 09:31
JavaScript: Cascading Dropdowns
/**
* UI Forms Cascading Dropdowns
*
* CHANGES:
* - Remove hardcoded if for 'unit', since this is not part of the module functionality
* - Added extra params functionality on order to send more info on the request
*
* TODO:
* - add option to cache the content
*/
@tarmann
tarmann / gist:5618587
Last active December 17, 2015 13:39
JavaScript: Backbone Sync for legacy web server
Backbone.sync = function (method, model, options) {
var params = _.extend({
type: 'POST',
dataType: 'json',
url: model.url,
traditional: true,
contentType: 'application/x-www-form-urlencoded;charset=UTF-8'
}, options);
@tarmann
tarmann / gist:5618580
Last active December 17, 2015 13:39
JavaScript: Underscore Serialize JSON
_.mixin({
serialize: function (obj) {
var urlParams = _.map(obj, function (val, key) {
var value = (_.isObject(val)) ? JSON.stringify(val) : String(val);
return String(key) + '=' + value;
});
return urlParams.join('&');
}
});
@tarmann
tarmann / gist:5571546
Created May 13, 2013 21:08
Shell: Git Alias
alias gl='git pull'
alias gp='git push'
alias gd='git diff'
alias gc='git commit'
alias gca='git commit -a'
alias gco='git checkout'
alias gb='git branch'
alias gs='git status'
alias grm="git status | grep deleted | awk '{print \$3}' | xargs git rm"
@tarmann
tarmann / gist:5563532
Last active December 17, 2015 06:09 — forked from killerbytes/gist:3280922
CSS: Image Replacement
//image replacement
.ir {
font: 0/0 "image replace";
position: relative;
display: inline-block;
background-repeat: none;
}