Skip to content

Instantly share code, notes, and snippets.

View Ravenstine's full-sized avatar

Ten Bitcomb Ravenstine

View GitHub Profile
@Ravenstine
Ravenstine / ruby_snippets.md
Last active April 1, 2016 23:20
Ruby Snippets

Ruby Snippets

Sometimes, you don't need a gem for it.

This is a list of useful "snippets" for Ruby that are small but provide a lot of power. Copy them, modify them, and make them your own!

Snippets

Auto-assign Arguments to Instance Variables

@Ravenstine
Ravenstine / ravenstines_blocklist.md
Last active October 15, 2016 17:55
Ravenstine's Bullshit Google Results Blocklist

Ravenstine's Bullshit Google Results Blocklist

This is my list of domains that I block from Google search results using the Personal Blocklist plugin for Google Chrome.

Criteria

Here is the list of reasons why I block these domains:

  • Spreads misinformation or misleads the reader
  • Has a social, religious, or political bias
  • Uses clickbait headlines
@Ravenstine
Ravenstine / gist:57048e83261aa1215458b0d2d44ff677
Created June 6, 2016 04:44
Ember.js: Detecting route changes from within a component

I had a case where I wanted components to know if the current route has changed so behavior within their scope could be triggered. This was very hard to do, but this is what I came up with and it seems to work pretty well:

  didInsertElement() {
    Ember.run.scheduleOnce('afterRender', this, function() {
      let router = this.container.lookup('router:main');
      router.addObserver('currentPath', function(){
        // ... do something here
      });
 });
class AddContentToArticles < ActiveRecord::Migration
def change
add_column :articles, :content, :text
end
end
var module = module || ({}).__defineSetter_('exports', function(m){window = window || {}; window.ThisModule = m; return m;})
(function(){
module.exports = "hello world";
})(module)
<rss version="2.0"
xmlns:dc="http://purl.org/dc/element/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>Instant Articles | 89.3 KPCC</title>
<link>http://www.scpr.org</link>
<description>Instant Articles from KPCC's reporters, bloggers and shows.</description>
<item>
<title>Yahoo's Burbank layoffs, closure consolidates its operations at Silicon Beach</title>
@Ravenstine
Ravenstine / include.js
Created August 26, 2016 17:32
A simple function to include non-module JavaScript code in a Node.js project.
var self = this;
var include = function(){
var len = Object.keys(arguments).length;
var code = '';
var i = 0;
while(i < len){
var file = arguments[i];
code += (fs.readFileSync(embeditorRoot + "/" + file + '.js', "utf8") + "\n");
i++;
}
@Ravenstine
Ravenstine / match_group_names.rb
Created August 26, 2016 22:56
Did you know that you can name your match groups in a Regex?
"https://twitter.com/eh1030/status/12345/photo/1".match(/^(?<url>https?:\/\/twitter\.com\/[-a-zA-Z0-9+&@#%?=~_|!:,.;]+\/status(es){0,1}\/(?<tweetId>\d+)\/{0,1})/)
# => #<MatchData "https://twitter.com/eh1030/status/12345/" url:"https://twitter.com/eh1030/status/12345/" tweetId:"12345">
@Ravenstine
Ravenstine / Dockerfile
Created September 8, 2016 16:25
KPCC Audiogram Dockerfile
FROM ubuntu:16.04
# Install dependencies
RUN apt-get update --yes && apt-get upgrade --yes
RUN apt-get install git nodejs npm \
libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ \
ffmpeg \
libgroove-dev zlib1g-dev libpng-dev \
redis-server --yes
@Ravenstine
Ravenstine / DEPLOYMENT.md
Created September 8, 2016 16:27
KPCC Audiogram Deployment

Deployment

Prerequisites:

  • Docker w/ running docker-machine
  • brew install awscli

Instructions

  1. If you haven't already, run aws configure and enter your access ID and access secret, a long with us-west-1 as the region. Then initialize your environment by running eval $(docker-machine env default) and eval $(aws ecr get-login --region us-west-1). It may be wise to place those last two commands in your ~/.bash_profile if you are going to be interacting with Docker and Amazon ECS a lot.