Skip to content

Instantly share code, notes, and snippets.

View col's full-sized avatar
👨‍💻

Col col

👨‍💻
  • Jiva Ag
  • Melbourne, Australia
View GitHub Profile
@col
col / scopable.rb
Created March 17, 2013 11:46
A small ActiveRecord concern to help dry up scopes for belongs_to associations.
require 'active_support/concern'
module Scopable
extend ActiveSupport::Concern
module ClassMethods
##
# Creates scopes for all the belongs_to associations provided as args.
# For example 'scope_for :user' creates the following scopes.
@col
col / servo_test.ino
Created December 29, 2013 13:18
A simple Arduino sketch that allows you to control a brushless motor via an ESC (or any servo really) using inputs from the Arduino IDE serial monitor.
#include <Servo.h>
Servo esc;
int escPin = 9;
int minPulseRate = 1000;
int maxPulseRate = 2000;
int throttleChangeDelay = 100;
void setup() {
@col
col / basic_cube
Created May 17, 2014 02:15
Processing - 3D - OpenGL - Basic cube with rotation
import processing.opengl.*;
import controlP5.*;
ControlP5 MyController;
void setup()
{
size(400, 400, OPENGL);
MyController = new ControlP5(this);
MyController.addSlider("yRotation",0,6.28,20,20,20,200,10);
@col
col / drink_proto1.ino
Created November 12, 2014 02:00
This is the first Arduino script we used to run the cocktail maker prototype via wifi using an Arduino Yun.
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
YunServer server;
void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
Bridge.begin();
@col
col / Simple-JSON-API-Page-1.md
Last active July 4, 2022 12:51
Notes for creating a JSON API using Sinatra, SQL, DataMapper, Hal and hosted on Heroku.

Lightweight Ruby JSON API

Step 1 - Create a 'Hello World' Sinatra app

Create a Gemfile

source 'https://rubygems.org'

gem 'sinatra'
@col
col / Simple-JSON-API-Page-1.md
Last active August 29, 2015 14:09
Notes for creating a JSON API using Sinatra, SQL, DataMapper, Hal and hosted on Heroku.

Lightweight Ruby JSON API

Step 4 - Add a SQL data store

Firstly, lets add the heroku-postgresql addon to our project.

heroku addons:add heroku-postgresql
@col
col / readme.md
Last active November 28, 2017 22:53
Config Phoenix App For Dokku Deploy

Config Phoenix App For Dokku Deploy

  1. Set the hostname via an environment variable in prod.exs
  • url: [host: System.get_env("HOSTNAME"), port: 80],
  1. Set the secret key base via an environment variable in prod.secret.exs
  • secret_key_base: System.get_env("SECRET_KEY_BASE")
  1. Set the database connection url via an environment variable in prod.secret.exs
  • url: System.get_env("DATABASE_URL"),

Setup Dokku instance on Digital Ocean

Step 1 - Create a Droplet

  1. Goto https://www.digitalocean.com
  2. Create Droplet
  3. Choose 'One Click App' - 'Dokku 0.4.7 14.04'
  4. Choose size (I chose the $10 option)
  5. No additional requirements
  6. Setup an SSH Key
@col
col / Deploy a Phoenix app with Dokku.md
Last active March 28, 2025 04:03
Deploy a Phoenix app with Dokku
@col
col / setup_ssl_for_dokku_app.md
Last active January 19, 2016 09:37
Setup_SSL_for_Dokku_App.md

Setup SSL for Dokku App

Create an SSL certificate signing request

dokku certs:generate <app_name> <mydomain>

Answer all the questions.

Submit that to an SSL signing authoority / online vendor. Wait for the cert to be generated.