Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
# Diffs the bundles of a branch with master.
#
BRANCH=$1
# Don't build master if we already have it
if [ ! -d "build_master" ]; then
echo 'Building "master" branch bundle...'
@Darep
Darep / circle.yml
Created November 3, 2017 11:17
utf8mb4 for CircleCI in Rails
database:
override:
- mv config/database.ci.yml config/database.yml
- RAILS_ENV="test" RACK_ENV="test" bundle exec rake db:create db:structure:load ts:configure ts:index ts:start --trace
@Darep
Darep / no-comments.js
Created May 30, 2016 07:01
Remove all comments from GitHub Pull Request
// Sometimes it's necessary to do a bit of clean-up
Array.prototype.forEach.call(document.querySelectorAll('.js-comment-delete button'), function(el, i) {
el.removeAttribute('data-confirm');
el.click();
});
@Darep
Darep / components.some-component.js
Created May 12, 2016 13:50
component init on route change?
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
console.log('init!!1');
},
willDestroy() {
console.log('noooo dsetroyer');
<?php
/**
* Encrypts a "secrets.json" file using mcrypt
*
* Usage: php secrets_encrypt.php > secrets.ejson
*/
require(dirname(__FILE__) . '/key.php');
function _secrets_encrypt($string) {
@Darep
Darep / application.adapter.js
Last active November 10, 2015 09:24
ember-data ok
import Ember from 'ember';
export default DS.ActiveModelAdapter.extend({
host: 'https://output.jsbin.com',
namespace: 'zufarix',
buildURL: function (modelName, id, snapshot, requestType, query) {
var url = this._super(modelName, id, snapshot, requestType, query);
url = url.replace('colors/', '') + '.json';
return url;
@Darep
Darep / render_component.js
Last active August 29, 2015 14:17
Ember.js dynamic component rendering
/**
Helper for rendering a component dynamically by supplying a name.
NOTE: Only works on Ember.js 1.9 and lower, does not work on 1.10+.
Ember 1.11 will have this feature built-in.
Usage: {{render-component widgetName someData=some.data}}
*/
Ember.Handlebars.registerHelper('render-component', function(context, options) {
var componentName = Ember.Handlebars.get(this, context, options);
var helper = Ember.Handlebars.resolveHelper(options.data.view.container, componentName);
@Darep
Darep / _breakpoints.scss
Last active August 29, 2015 14:14
Sass breakpoints
// Get value from a Sass list of key-value items (helper function)
@function match($collection, $key) {
@each $item in $collection {
$index: index($item, $key);
@if $index {
$return: if($index == 1, 2, $index);
@return nth($item, $return);
}
}
@return false;
@Darep
Darep / blog.html.erb
Created January 5, 2014 19:20
Old-school numbered pagination for middleman-blog – see http://i.imgur.com/oYa0Cfj.png
<% if paginate && num_pages > 1 %>
<div class="pagination">
<% if prev_page %>
<%= link_to '<i class="icon-arrow-left"></i> Prev', prev_page, class: 'prev page-numbers' %>
<% else %>
<span class="disabled"><i class="icon-arrow-left"></i> Prev</span>
<% end %>
<% for p in 1..num_pages %>
<% if p == page_number %>
@Darep
Darep / rollbar.js
Last active December 21, 2015 22:29
Use Rollbar (https://rollbar.com/) with Browserify
// Download rollbar.js and rollbar.min.js from:
// http://d37gvrvc0wt4s1.cloudfront.net/js/1/rollbar.js
// http://d37gvrvc0wt4s1.cloudfront.net/js/1/rollbar.min.js
//
// Place them into vendor/ and this code into lib/rollbar.js, or something
(function(w, d) {
w._rollbarParams = {
"server.environment": "production",
"notifier.snippet_version": "2"