Skip to content

Instantly share code, notes, and snippets.

View br3nt's full-sized avatar

br3nt

View GitHub Profile
@br3nt
br3nt / post-receive.rb
Last active September 16, 2019 00:23 — forked from ryanflorence/post-receive.rb
A git hook to be installed on a remote server. The remote's repo will updated when a push is made.
#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
@br3nt
br3nt / sketch-never-ending.md
Created November 29, 2018 00:38 — forked from Bhavdip/sketch-never-ending.md
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

@br3nt
br3nt / description.markdown
Created February 27, 2017 23:54 — forked from runemadsen/description.markdown
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

@br3nt
br3nt / dispatcher.js
Last active November 29, 2015 10:05 — forked from neilj/window-controller.js
Cross-tab window communication
function Dispatcher(channel_name, broadcast_to_self) {
this.channel_name = channel_name ? 'dispatcher:' + channel_name : 'dispatcher:default_channel';
this.id = Math.random();
this.isMaster = false;
this.others = {};
this.broadcast_to_self = broadcast_to_self === undefined ? true || !!broadcast_to_self;
this.callbacks = {};
window.addEventListener( 'storage', this, false );
window.addEventListener( 'unload', this, false );