Skip to content

Instantly share code, notes, and snippets.

View etozzato's full-sized avatar
💀
I work hard so my cat doesn't have to

Emanuele Tozzato etozzato

💀
I work hard so my cat doesn't have to
View GitHub Profile
@etozzato
etozzato / -
Created February 11, 2014 19:05
alias ssl_rails='sudo pkill nginx && rvmsudo nginx -c ~/Workspace/SCEA/painfree/community/config/nginx.conf.dev'
@etozzato
etozzato / merge-columns.js.coffee
Created April 18, 2014 19:43
push and pushObject on array
newColumn: ->
# NOPE!
# @get('newColumns').pushObject { title: @get('targetColumn'), type: @get('selectedNewColumn.id') }
_arr = @get('newColumns')
_arr.pushObject { title: @get('targetColumn'), type: @get('selectedNewColumn.id') }
@set('newColumns', _arr)
// I want to nullify segment_id for the model before saving if it was not changed;
// is it okay to mess with _dirtyAttributes ?
actions: {
updateParticipant: function() {
if (!this.get('model._dirtyAttributes').contains('segment_id')) {
this.get('model').set('segment_id', null);
}
return this.get('model').save().then(function() {
return console.log("NOTIFY THE USER!");
this.get('model').save().then(function() {
return console.log("OK");
}).catch(function() {
return console.log("KO");
});
# A very basic en-us inflector that relies on the UI programmer
# to provide the (optional) plural version of the irregular noun
#
# pluralize 3 'Friend'
# => Friends
# pluralize 0 'Octopus' 'Octopodes'
# => Octopodes
Ember.Handlebars.registerBoundHelper 'pluralize', (count, singular, plural) ->
plural = singular + 's' if typeof(plural) == 'object'
// My Annotation object has labels, but only carries the list of label values
// "labels":["terr","anno"]
// This is the form of the full annotationLabel
// {"id":1,"label":"Terrifying","value":"terr"}
// {"id":2,"label":"Annoying","value":"anno"}
Processing by Api::Admin::MarkerActivitiesController#create as JSON
Parameters: {"title"=>"THIS IS OKAY", "description"=>"default description", "social_is_active"=>true, "social_description"=>"default description", "labels_is_active"=>true, "labels_description"=>"default description", "label_data"=>"[FILTERED]", "sentiment_is_active"=>true, "sentiment_description"=>"default description", "image_attachment"=>{"name"=>"Screen Shot 2014-06-20 at 12.47.55 PM.png", "type"=>"image/png", "data"=>"[FILTERED]"}, "api_version"=>"v1", "project_id"=>"3078", "marker_activity"=>{}}
@etozzato
etozzato / gist:85da5cb66ab935d06ebf
Created October 13, 2014 23:20
Window Resize
// in the component's didInsertElement
$(window).on('resize', function() {
return Em.run.debounce(that, 'resizeWindow', 250);
});
// in the route's willTransition
$(window).off('resize');
for TABLE in $(psql table_name -c "\dt" | awk '{print $3}'); do psql table_name -c "select '$TABLE', count(*) from $TABLE;" | grep -A1 "\-\-\-\-" | tail -1; done
@etozzato
etozzato / dst.js
Last active August 29, 2015 14:08
Working with ActiveSupport::TimeZone
// MomentJS can use different types of timezone offset
// including the one obtained by ActiveSupport::TimeZone
var timezone_offset = "+01:00";
console.log(moment().zone(timezone_offset).format('LLLL'));
> Tuesday, October 28 2014 7:51 PM
console.log(moment().format('LLLL'));