Skip to content

Instantly share code, notes, and snippets.

View vanakenm's full-sized avatar

Martin Van Aken vanakenm

View GitHub Profile
@vanakenm
vanakenm / seeds.rb
Last active December 27, 2017 13:58
EffinSeed
EffinQuote.create([
{
contents: "good luck with your bullshit",
url: "https://pbs.twimg.com/media/DQ2tB-xWkAAKKJh.jpg"
},
{
contents: "got it you're dim",
url: "https://pbs.twimg.com/media/DQ117aPW4AEmnWF.jpg"
}
])
connection.dialect = org.hibernate.dialect.H2Dialect
connection.driver_class = org.h2.Driver
connection.url = jdbc:h2:./database/dhis2;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE
connection.username = sa
connection.password =
<h1>Header</h1>
<h2 id="subheader">Subheader</h2>
<p>Paragraph</p>
<h2 id="subheader-2">Subheader 2</h2>
<h3 id="subsubheader-1">Subsubheader 1</h3>
@vanakenm
vanakenm / killpumas.sh
Created March 31, 2016 11:07
How to kill your servers
ps -ax | grep puma
# Example result:
27212 pts/3 Sl+ 0:03 puma 3.2.0 (tcp://localhost:3000) [maily-restaurants]
27249 pts/3 Sl+ 0:04 puma: cluster worker 0: 27212 [maily-restaurants]
29574 pts/3 Sl+ 0:01 puma: cluster worker 1: 27212 [maily-restaurants]
32569 pts/9 S+ 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclu
# Any line that starts with "puma" is a running server. To kill them, take their id and use the "kill" command:
class Doctor < ActiveRecord::Base
has_many :interns
has_many :consultations
has_many :patients, through: :consultations
validates :last_name, presence: true
validates :first_name, presence: true
end
# Before using, download the database [from the lecture](http://karr.lewagon.org/assets/02_sql_crud_doctors-cf43cfaf07025130e638de583d55e0ec.db)
# and save it as "doctors.db" in the same folder as this file
require 'sqlite3'
DB = SQLite3::Database.new("doctors.db")
class Doctor
attr_reader :id
attr_accessor :name, :age, :specialty
class Patient
attr_reader :name, :cured, :id
attr_accessor :room
def initialize(attributes)
@name = attributes[:name]
@id = attributes[:id].to_i
@cured = attributes[:cured] || false
@vanakenm
vanakenm / gist:e45578bcd70f2ecd133a
Created February 19, 2015 11:16
Deploying to Heroku - Co.Station version
Follow the lecture for the Heroku signup & install. Use the Heroku create & push (git push heroku master).
The next step is supposed to be: heroku run rake db:migrate (we want to migrate our DB on the production server).
This will not work on Co.Station Member network (the one we are using for the internet connection), due to port 5000 being blocked (whole story: https://devcenter.heroku.com/articles/one-off-dynos#troubleshooting)
Workaround: get to another connection. Anyone with a data plan can access Internet using his/her smartphone, and you can then create a small "HotSpot" (a wifi network) out of it. Switch your laptop to that network, run that rake command (which should work), and switch back (to avoid data costs but mostly because the connection is much faster).
@vanakenm
vanakenm / gist:d0f6cc4f8bb03f4fb224
Created February 2, 2015 10:32
One sentence pitch from Adeo Ressi (founder institute)
My company, _(insert name of company)_,
is developing _(a defined offering)_
to help _(a defined audience)_
_(solve a problem)_
with _(secret sauce)_
@vanakenm
vanakenm / gist:2433a0fabf7846c55558
Created January 16, 2015 17:15
Printing the students
students = [{name: "Laura", age: 10, enlisted: true},
{name: "Bob", age: 22},
{name: "Stephan", age: 18},
{name: "Lisa", age: 27, enlisted: true}]
def the_list(students)
students.map do |student|
enlisted = "* " if student[:enlisted]
"#{enlisted}#{student[:name]} #{student[:age]}"
end