Skip to content

Instantly share code, notes, and snippets.

View Ravenstine's full-sized avatar

Ten Bitcomb Ravenstine

View GitHub Profile
@Ravenstine
Ravenstine / rails_on_startup.md
Last active March 6, 2016 22:07
Run a Rails app on startup in Raspbian/Debian Linux

Judgment

I should be able to run a Rails app on a Raspberry Pi automatically on startup with minimal configuration, muss, or fuss.

Instructions

  1. Install the Whenever gem for writing a schedule to Crontab. (this is actually optional since you can edit crontab manually, but Whenever is convenient for having the schedule stored in the Rails project) gem install whenever or gem 'whenever', require: false in your Gemfile
  2. Install Nginx. sudo apt-get install nginx
  3. In your Nginx configuration(probably /etc/nginx/nginx.conf), make sure the http section includes other configuration files from the sites-enabled folder. Add the line include /etc/nginx/sites-enabled/*; to the http section if it isn't there.
  4. Create /etc/nginx/sites-enabled/default and add server configuration for your Rails app. Here is an example file:
class PolyFence(list):
def __init__(self, obj_name, tolerance=0):
self.obj_name = obj_name
self.compute_convex_hull(tolerance)
def select(self):
for vertex in self:
cmds.select(vertex.obj_name, add=True)
def draw(self):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" style="font-family: Georgia, serif;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>89.3 KPCC | The Short List</title>
<link href="/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />
<style data-premailer="ignore" type="text/css">
<![CDATA[@media only screen and (max-width: 600px){body,table,td,p,a,li,blockquote{ -webkit-text-size-adjust:none !important;}}@media only screen and (max-width: 600px){body{width:100% !important;min-width:100% !important;}}@media only screen and (max-width: 600px){table[id=bodyTable]{padding:10px !important;}}@media only screen and (max-width: 600px){table[id=templateContainer]{max-width:600px !important;width:100% !important;}}@media only screen and (max-width: 600px){h1{font-size:28px !important;line-heigh
@Ravenstine
Ravenstine / reactor.cr
Created September 8, 2015 05:29
A very simple event loop written in Crystal. (crystal-lang.org)
module Reactor
class Task
property :block
def initialize(timestamp=Time.now, milliseconds=0, &block : Loop ->)
@block = block
@timestamp = timestamp.epoch_ms
@milliseconds = milliseconds
end
def run reactor
@Ravenstine
Ravenstine / adjusted_kml_file.kml
Last active September 1, 2015 20:48
adjusted_kml_file
<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns='http://www.opengis.net/kml/2.2'>
<Document>
<name>testmap1</name>
<description><![CDATA[]]></description>
<Folder>
<name>Untitled layer</name>
<Placemark>
<name>Point 1</name>
<styleUrl>#icon-503-DB4436-nodesc</styleUrl>
@Ravenstine
Ravenstine / tx.kml
Created September 1, 2015 05:23
test
<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns='http://www.opengis.net/kml/2.2'>
<Document>
<name>testmap1</name>
<description><![CDATA[]]></description>
<Folder>
<name>Untitled layer</name>
<Placemark>
<name>Point 1</name>
<styleUrl>#icon-503-DB4436-nodesc</styleUrl>
@Ravenstine
Ravenstine / project_full_circle_map.html
Last active August 31, 2015 21:15
Project Full Circle Map
<style>
#siteWrapper #page{
margin: none;
padding: none;
max-width: none;
}
main {
padding: 0 !important;
}
#fullcirclemap img{
@Ravenstine
Ravenstine / testmap.kml
Last active August 31, 2015 17:23
testmap
<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns='http://www.opengis.net/kml/2.2'>
<Document>
<name>Double Plus Good </name>
<description><![CDATA[Trip Map 1]]></description>
<NetworkLink>
<name>Double Plus Good </name>
<Link>
<href>http://mapsengine.google.com/map/kml?forcekml=1&amp;mid=z_Tk3EyXNpN8.k743LUvJRr1U</href>
</Link>
@Ravenstine
Ravenstine / queue_episode_retrieval_proposal.md
Last active August 29, 2015 14:26
Queue Episodes Retrieval Proposal

Queue Episode Retrieval - Proposed Technical Approach

For our upcoming SSO features, we need a way for a user to retrieve new episodes for their Favorite shows through the KPCC app. To sum up our requirements:

  • Users should be able to retrieve up to n most recent episodes from their favorite shows per download.
  • Episodes downloaded to a user's queue should sync up across devices
  • Finished or deleted episodes in the queue should not be re-downloaded.

Through proofing out some approaches, I came to the conclusion that the simplest approach is the right one for what we want to achieve.

@Ravenstine
Ravenstine / gist:1e6bcc19e221989fa992
Created August 5, 2015 16:14
queue_episode_retrieval_proposal_v1.md
## hello