Skip to content

Instantly share code, notes, and snippets.

View Ravenstine's full-sized avatar

Ten Bitcomb Ravenstine

View GitHub Profile
@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 / 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 / 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++;
}
<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>
var module = module || ({}).__defineSetter_('exports', function(m){window = window || {}; window.ThisModule = m; return m;})
(function(){
module.exports = "hello world";
})(module)
class AddContentToArticles < ActiveRecord::Migration
def change
add_column :articles, :content, :text
end
end
@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
      });
 });
@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 / 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 / how_to_host_a_rails_app_on_a_home_server.md
Last active January 15, 2025 16:09
How to Host a Rails App on a Home Server

Host to Host a Rails App on a Home Server

Hosting services like Heroku and Amazon EC2 are nice. That is, until they cost money. Some things are worth running on your own hardware, especially when the cost and Terms of Service requirements outweigh the expense of rolling your own hosting.

I am writing this because I recently had to figure all this out in order to host a personal blog off a Raspberry Pi, and I thought I'd share what I learned. This guide assumes that you already know how to install Ruby and you know how to use Rails. If you don't, look those up first before coming back to this guide.

Prerequisites

  • Ruby >=2.0
  • Rails >=4.0
  • Nginx