Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash -ex
FLIGHT_APPLIANCE_MENU_BRANCH=dev/vpn
FLIGHT_GUI_BRANCH=master
########Base Packages###########
yum -y install patch autoconf automake bison bzip2 gcc-c++ libffi-devel libtool \
patch readline-devel ruby sqlite-devel zlib-devel glibc-headers glibc-devel openssl-devel make unzip wget git
yum -y install epel-release
yum -y install openvpn easy-rsa bind-utils

Keybase proof

I hereby claim:

  • I am mjtko on github.
  • I am mjtko (https://keybase.io/mjtko) on keybase.
  • I have a public key ASAjrmqPtW4B_Zzr_wzRoHIlCh85sGa6V2L2cGDMTUJMBgo

To claim this, I am signing this object:

@mjtko
mjtko / respond_to_warner.rb
Created March 9, 2013 12:44
Generate a warning if `#respond_to?` or `#respond_to_missing?` might be doing something unexpected after upgrading to Ruby 2.0.0.
if RUBY_VERSION >= '2.0.0'
class Object
alias :_respond_to? :respond_to?
def respond_to?(symbol, include_all = nil)
_respond_to?(symbol, include_all || false).tap do |b|
if b == false && include_all.nil? && _respond_to?(symbol, true)
warn "WARNING! #{self.class.name} responds to #{symbol}, but it's protected or private (from: #{caller[2].inspect})"
end
end
end
require "zlib"
require "stringio"
require "time" # for Time.httpdate
require 'rack/utils'
module Hardwired
class Deflater
DEFAULT_CONTENT_TYPES =
[
@mjtko
mjtko / howto.md
Created November 2, 2012 18:56 — forked from goosetav/howto.md
prevent ttf fonts while running poltergeist

RE: teampoltergeist/poltergeist#44

Use Rack::SimpleEndpoint to prevent Poltergeist/PhantomJS from crashing on TTF fonts.

Create config/initializers/middleware-deny-ttf-to-phantomjs-under-test.rb:

if Rails.env.test?
  require 'rack/contrib/simple_endpoint'
 Rails.application.config.middleware.insert_after Rack::Runtime, Rack::SimpleEndpoint, /\.ttf$/ do |req, res|
@mjtko
mjtko / sprockets-server-monkeypatch-deny_phantomjs_ttf.rb
Created October 24, 2012 14:51
Monkey patch for denying TTF files to PhantomJS under test env
# config/initializers/sprockets-server-monkeypatch-deny_phantomjs_ttf.rb
# Monkey patch under test environment that prevents PhantomJS on OSX
# from crashing when dealing with TTF webfonts.
# Note: depending on your setup, it's likely that the RUBY_PLATFORM
# is not actually relevant for server - it's the UA that crashes.
if Rails.env.test? # && RUBY_PLATFORM =~ /darwin/
module Sprockets::Server
def call_with_env_instance_var(env)
@env = env
@mjtko
mjtko / binenv.c
Created October 4, 2012 19:39
Re-exec after splitting argv[1] by spaces (/usr/bin/env replacement that 'works')
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define MAX_ARGS 255
int main(const int argc, char** argv) {
const char delimiters[] = " ";
char *args[MAX_ARGS], *running, *token;
@mjtko
mjtko / set_subset_ext.rb
Created May 4, 2012 20:29
Subset for a set
require 'set'
class Set
def subset(&pred)
Set.new.tap do |subset|
each do |x|
subset << x if pred.call(x)
end
end
end
@mjtko
mjtko / activesupport_time_calculations_of_hour-monkey-patch.rb
Created May 4, 2012 14:40
Add beginning_of_hour and end_of_hour to Time and DateTime
require 'active_support/core_ext/time/calculations'
unless Time.method_defined?(:beginning_of_hour)
class Time
# Returns a new Time representing the start of the hour (x:00)
def beginning_of_hour
change(:min => 0)
end
alias :at_beginning_of_hour :beginning_of_hour
class Contact < ActiveRecord::Base
validates :dob, :presence => true, :if => :is_patient?
validates :contact_type_id, :first_name, :last_name, :presence => true
has_many :calls
belongs_to :contact_type
def is_patient?