Skip to content

Instantly share code, notes, and snippets.

View diff-master-bundle.sh
#!/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 Nov 3, 2017
utf8mb4 for CircleCI in Rails
View circle.yml
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
Remove all comments from GitHub Pull Request
View no-comments.js
// 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
component init on route change?
View components.some-component.js
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
console.log('init!!1');
},
willDestroy() {
console.log('noooo dsetroyer');
View secrets_encrypt.php
<?php
/**
* Encrypts a "secrets.json" file using mcrypt
*
* Usage: php secrets_encrypt.php > secrets.ejson
*/
require(dirname(__FILE__) . '/key.php');
function _secrets_encrypt($string) {
View application.adapter.js
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 Aug 29, 2015
Ember.js dynamic component rendering
View render_component.js
/**
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 Aug 29, 2015
Sass breakpoints
View _breakpoints.scss
// 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 Jan 5, 2014
Old-school numbered pagination for middleman-blog – see http://i.imgur.com/oYa0Cfj.png
View blog.html.erb
<% 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 Dec 21, 2015
Use Rollbar (https://rollbar.com/) with Browserify
View rollbar.js
// 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"