Skip to content

Instantly share code, notes, and snippets.

View Gowiem's full-sized avatar
🌤️
Stoked on Terraforming

Matt Gowie Gowiem

🌤️
Stoked on Terraforming
View GitHub Profile
@Gowiem
Gowiem / delete_keys.sh
Last active February 15, 2016 20:27
Clean up Redis by deleting keys
# Pull all keys matching wildcard from your Replica so you're not using KEYS on your primary.
$ redis-cli -h $ELASTI_CACHE_REPLICA_URL KEYS "*WILDCARD*" > keys.txt
# For each key that has been collected, prepend the DEL command.
$ sed ':a;N;$!ba;s/\n/\n DEL /g' keys.txt > del_keys.txt
# Feed the new DEL commands into your primary. Run via nohup + background as deleting millions of keys can take hours.
$ nohup redis-cli -h $ELASTI_CACHE_URL < del_keys.txt &
@Gowiem
Gowiem / ember-csrf.js
Created October 24, 2015 00:59
Use CSRF Token in each Ember AJAX Request
// If using rails: Place the csrf_meta_tag helper in primary layout in the head tag:
// = csrf_meta_tag
// Initializer
// Include the CSRF Token in each ajax Request.
Ember.$.ajaxSetup({
headers: {
'X-CSRF-Token': Ember.$('meta[name="csrf-token"]').attr('content')
}
});
@Gowiem
Gowiem / ember_update_notes.md
Last active August 29, 2015 14:20
Ember Update Notes

Ember Update Notes

Quick summary of the recent deprecations that have been added.

  1. We can no longer use the {{each}} helper without using in or as. For example:
// Not okay:
{{#each rules}}
  // context is a single rule, which is confusing...
{{/each}}
@Gowiem
Gowiem / graph.js
Created April 8, 2015 16:12
Reusable Chart Functions Example
/* Using this function:
updateGraph: function() {
if (this.hasData()) {
this.$('.waiting-for-data').hide();
d3.select(this.$()[0])
.datum(this.get('data'))
.call(Artisan.graphing.scatterChart());
} else {
this.$('.waiting-for-data').show();
@Gowiem
Gowiem / input-slider.handlebars
Created March 3, 2015 21:37
jQuery UI Input Slider Wrapper Component
<div class="slider"></div>
<div class="slider-value">
{{#if disabled}}
<span>{{value}}%</span>
{{else}}
{{input type="number" value=value}}
{{/if}}
</div>
@Gowiem
Gowiem / dependent_relationship_save_mixin.js
Last active August 29, 2015 14:15
Emberjs - Undirty Dependent Relationships on Save
// The following DependentRelationshipSaveMixin will undirty any associated models on save.
// These models have the `{ dependent: true }` flag set on their relation declaration. This is useful
// when using embedded relationships with the ember-data.dependent-relationships.js addon
// (https://gist.github.com/slindberg/8660986).
var commitAttributes = function(model) {
model._inFlightAttributes = model._attributes;
model._attributes = {};
model.adapterWillCommit();
return model;
@Gowiem
Gowiem / ember-data-init-issue.js
Created August 15, 2014 21:24
Ember-Data parent/child initialization issue
// This is what I would like to do...
//////////////////////////////////////
var OtherModel = DS.Model.extend({
parent: DS.belongsTo('parent')
});
var Parent = DS.Model.extend({
child: DS.belongsTo('other_model'),
init: function() {
this._super();
@Gowiem
Gowiem / arrayComputed.js
Created May 30, 2014 14:13
Error using Ember.arrayComputed
allRules: function() {
var options = {
initialize: function(array, changeMeta, instanceMeta) {
console.log("initialize array: ", array);
return array;
},
addedItem: function(array, item, changeMeta, instanceMeta) {
console.log("addedItem - item: ", item);
array.push(item);
return array;
@Gowiem
Gowiem / builder.handlebars
Created May 23, 2014 15:42
ActionRuleComponent
{{!-- creating the action rules --}}
{{#each actionRule in segment.actionRules}}
{{segment-action-rule actionRule=actionRule availableDimensions=availableDimensions}}
{{/each}}
{{!-- creating the rules inside the action-rule component handlebars --}}
<ol class="segment-action-child-rules segment-rules">
{{#each childRule in actionRule.rules}}
{{segment-builder-rule rule=childRule availableDimensions=availableDimensions canDeleteRules="true" addRuleButtonClicked="addRule" removeRule="removeRule"}}
{{/each}}
@Gowiem
Gowiem / ansible-git-error.txt
Created March 13, 2014 03:00
Ansible Git Error
TASK: [Check out repo] ********************************************************
failed: [rails-server] => {"cmd": ["/usr/bin/git", "ls-remote", "https://token:x-oauth-basic@github.com/some-other-user/some-repo.git", "-h", "refs/heads/master"], "failed": true, "rc": 128}
stderr: fatal: failed to stat '.': Permission denied
msg: fatal: failed to stat '.': Permission denied