Skip to content

Instantly share code, notes, and snippets.

@turhn
turhn / nginx.conf
Last active March 12, 2016 23:23
Sinatra Application, serve static index.html using nginx
server {
# ...nginx stuff
index index.html;
# ...more nginx stuff
}
@turhn
turhn / configure_proxy_protocol.md
Created February 11, 2016 23:44 — forked from pablitoc/configure_proxy_protocol.md
Configuring Proxy Protocol

##Install AWS CLI Tools##

  1. Install AWS CLI Tools. You can also use the EC2 API Tool if you are more comfortable with them. But this write-up uses the EC2 CLI.
  2. Create a user via Amazon IAM or download the security accessID and securitykey you will need it to query Amazon CLI.
  3. using Terminal cd into .aws directory cd ~/.aws edit or create new file named config paste the following contents inside.
    `[default]`
    `aws_access_key_id = ACCESS_ID`
    `aws_secret_access_key = SECRET_ID`
    `output = json OR bson OR text`
    `region = PREFERRED_AWS_REGION`

Save the file as "config"

@turhn
turhn / lcommitid.rb
Created November 20, 2015 14:14
AWS Get Last Deployment's Commit Id
#!/usr/bin/env ruby
require 'json'
class Deployments
def initialize(app_name, deployment_group)
@app_name, @deployment_group = app_name, deployment_group
end
def latest_successful_deployments
@turhn
turhn / parallels-tools-4.2.inode.c.patch
Created November 12, 2015 10:02
Parallels Tools Linux 4.2.0 Patch
--- parallels2/prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c 2015-07-09 06:22:30.000000000 -0700
+++ parallels/prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c 2015-07-09 06:22:30.000000000 -0700
@@ -650,12 +650,21 @@
return tgt_path;
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
+#define compat_follow_link_t char*
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)

#Rules

On Infrastructure

  • There is one system, not a collection of systems.
  • The desired state of the system should be a known quantity.
  • The "known quantity" must be machine parseable.
  • The actual state of the system must self-correct to the desired state.
  • The only authoritative source for the actual state of the system is the system.
  • The entire system must be deployable using source media and text files.
@turhn
turhn / run_command_on_git_revisions.sh
Created January 21, 2015 02:40
run-command-on-git-revisions
#!/bin/bash
#
# This script runs a given command over a range of Git revisions. Note that it
# will check past revisions out! Exercise caution if there are important
# untracked files in your working tree.
#
# This came from Gary Bernhardt's dotfiles:
# https://github.com/garybernhardt/dotfiles
#
# Example usage:
root@vagrant-ubuntu-trusty-64:~# sh -x /etc/init.d/unicorn start
+ set -e
+ USAGE=Usage: /etc/init.d/unicorn <start|stop|restart|upgrade|rotate|force-stop>
+ USER=vagrant
+ APP_NAME=safir
+ APP_ROOT=/vagrant
+ RAILS_ENV=production
+ export RBENV_ROOT=/home/vagrant/.rbenv
+ export PATH=/home/vagrant/.rbenv/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/home/vagrant/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ SET_RUBY=cd /vagrant && rbenv rehash && rbenv local 2.2.0

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@turhn
turhn / karma.rake
Created December 8, 2014 13:23
Configuring a Rake Task for karma and jasmine
require 'open3'
namespace :karma do
task :start => :environment do
with_tmp_config :start
end
task :run => :environment do
with_tmp_config :start "--single-run"
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')