Skip to content

Instantly share code, notes, and snippets.

View dhiemstra's full-sized avatar

Danny Hiemstra dhiemstra

View GitHub Profile
@dhiemstra
dhiemstra / install-dnsmasq.sh
Created January 9, 2018 12:00
Install dnsmasq on OSX and configure the `*.fml` TLD as local
brew install dnsmasq
CONFIG_FILE="$(brew --prefix)/etc/dnsmasq.conf"
sudo mkdir -p /etc/resolver
sed -i 's/#strict-order/strict-order/g' $CONFIG_FILE
grep -q -F 'address=/.fml/127.0.0.1' $CONFIG_FILE || echo 'address=/.fml/127.0.0.1' >> $CONFIG_FILE
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/fml'
@dhiemstra
dhiemstra / aws.tf
Last active September 30, 2017 09:58
variable "aws_access_key" { default = "x" }
variable "aws_secret_key" { default = "x" }
# Should be given via command line
variable "branch" {}
variable "aws_region" {
default = "eu-central-1"
}
variable "r53_staging_zone_id" {
class HealthCheck
class << self
def run(port: 8000)
self.new(port: port).run
end
def background(port: 8000)
self.new(port: port).background
end
end
#!/usr/bin/env ruby
# Setenv
# TODO: Find something better for this..
# TODO: Find a way to get the project name
# TODO: Rename to pre-recieve?
HOME = "/Users/dhiemstra/Projects/docker/builder/local"
BIN_PATH = "#{HOME}/bin"
REPOS_PATH = "#{HOME}/repos"
BUILDS_PATH = "#{HOME}/builds"
0.10552698199171573 active_support
0.10818373601068743 active_support/time
0.11088466799992602 arel
0.11277171300025657 haml
0.11378979800792877 active_support/core_ext/hash/conversions
0.1375656950112898 active_support/core_ext/object/conversions
0.1413851780089317 nokogiri
0.14352535500074737 byebug/commands
0.14591897900390904 mail
0.14936679700622335 action_controller/base
export default {
// Simple
'dashboard.hello': 'Hello world',
// nested
'button': {
'add_user': {
'title': 'Add a user',
'text': 'Add',
'disabled': 'Saving...'
› dig em.dannyhiemstra.com
; <<>> DiG 9.8.3-P1 <<>> em.dannyhiemstra.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12643
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;em.dannyhiemstra.com. IN A
@dhiemstra
dhiemstra / after_restart.rb
Last active August 29, 2015 14:18
Notify AppSignal of EngineYard deploys
# notify appsignal
args = "--revision=#{config.active_revision} --user=#{config.deployed_by} --environment=#{config.environment_name}"
run "cd #{config.current_path} && bin/bundle exec appsignal notify_of_deploy #{args}"
@dhiemstra
dhiemstra / ey.rake
Created April 6, 2015 08:54
Rake task to execute some common rails commands on Engineyard
APP_NAME='..'
PATH="/data/#{APP_NAME}/current"
namespace :ey do
desc "Open production rails console"
task :console do
exec "ey ssh -t 'cd #{PATH} && bin/rails console production'"
end
desc "Open production psql command"
# Public: Returns an optimized hash object for mobile representation of weekly activities.
#
# The returned hash would look like this {"Monday" => [schedule_items], "Tuesday" => [], ...}
def current_week_for_mobile
start = proxy_association.owner.local_time.beginning_of_week
end = proxy_association.owner.local_time.end_of_week
(start..end).inject({}) do |memo,day|
memo[Date::DAYNAMES[day.wday]] = ScheduleItem.where(date: day.to_date)
memo