Skip to content

Instantly share code, notes, and snippets.

@justinwiley
justinwiley / cucumber-capybara-capistrano.feature
Created August 31, 2011 18:48
Integrating Cucumber Capybara Smoketest with Capistrano
@test_deploy @javascript # @test_deploy tag setup in cucumber.yml profile, @javascript runs in capybara-webkit
Feature: Smoke Test
In order to test that the application is deployed
As a caring developer
I want to check a few features of the site
Background:
Given we are in the deploy environment
Scenario: Logging in and checking basic navigation
@justinwiley
justinwiley / ubuntu-rvm-pre-requisites.sh
Created January 10, 2012 20:01
Installing pre-requisites for successful rvm install under Ubuntu
# without having to resort to local rvm package install
sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline6-dev libxml2-dev libsqlite3-dev libcurl4-openssl-dev;
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer );
rvm install ruby-1.9.3-p0
@justinwiley
justinwiley / gist:1616969
Created January 15, 2012 19:44
sample twilio
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Pause length="1"/>
<Say voice="woman">
Thank you for calling about our survey regarding your recent U.N.C. ER experience.
If you would like to speak with someone directly, please contact UNC Patient Relations at (919) 966-5006
or visit our website at www. u.n.c. healthcare.org / health patient care. Have a nice day.
</Say>
<Pause length="1"/>
<Hangup/>
@justinwiley
justinwiley / dci-rest-creation.rb
Created January 26, 2012 19:46
DCI + Rails new and create
# ---role
module BookCreater
def create_book(attrs)
self.books.create! attrs
end
end
module BookUpdater
@justinwiley
justinwiley / cheap.js
Created April 25, 2012 20:41
A truly terrible way to prevent SQL injection
//validation for entering query
var notAllowed = ['select','SELECT','*','SeLeCt','sElEcT','{','}','(',')'];
for(var i = 0; i < notAllowed.length; i++){
if(document.frmSurvey.txtComments.value.indexOf(notAllowed[i]) != -1){
alert('The word "' + notAllowed[i] + '" is not allowed');
document.frmSurvey.txtComments.value = document.frmSurvey.txtComments.value.substr(0, document.frmSurvey.txtComments.value.indexOf(notAllowed[i]));
return false;
}
}
@justinwiley
justinwiley / gist:4074864
Created November 14, 2012 21:13
chef-client fails
jwiley@mix ~ (master)$ % chef-client -v
bash: fg: %: no such job
jwiley@mix ~ (master)$ sudo true && curl -L https://www.opscode.com/chef/install.sh | sudo bash
[sudo] password for jwiley:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6397 100 6397 0 0 23831 0 --:--:-- --:--:-- --:--:-- 34026
Downloading Chef for ubuntu...
Installing Chef
(Reading database ... 357980 files and directories currently installed.)
@justinwiley
justinwiley / gist:4680507
Created January 31, 2013 05:29
Outcome, Response
Outcome
[0.14195468819753526, 0.1774433602469191, -0.07097734409876763, -0.1774433602469191, -0.14195468819753526, -0.14195468819753526, 0.1774433602469191, 0.10646601614815145, 0.07097734409876763, 0.07097734409876763, -0.1774433602469191, -0.1774433602469191, -0.10646601614815145, 0.10646601614815145, 0.07097734409876763, -0.07097734409876763, -0.07097734409876763, -0.10646601614815145, 0.07097734409876763, 0.14195468819753526, 0.035488672049383815, 0.07097734409876763, 0.1774433602469191, 0.035488672049383815, 0.07097734409876763, 0.0, 0.07097734409876763, 0.0, 0.035488672049383815, 0.07097734409876763, 0.035488672049383815, 0.14195468819753526, 0.1774433602469191, 0.1774433602469191, -0.035488672049383815, -0.035488672049383815, -0.10646601614815145, 0.1774433602469191, 0.14195468819753526, 0.07097734409876763, 0.10646601614815145, 0.10646601614815145, 0.10646601614815145, -0.10646601614815145, 0.10646601614815145, -0.07097734409876763, 0.07097734409876763, 0.10646601614815145, 0.0, 0.1774433602469191, -0
irb(main):020:0* class Foo
irb(main):021:1> def def_methods
irb(main):022:2> method_name = "meth-#{rand(1000)}"
irb(main):023:2> self.class.class_eval do
irb(main):024:3* define_method method_name do
irb(main):025:4* method_name.to_s.capitalize
irb(main):026:4> end
irb(main):027:3> end
irb(main):028:2> end
irb(main):029:1> end
@justinwiley
justinwiley / gist:789e2f74a14cdb7814c4
Created December 4, 2014 21:15
arrayfire build w CMAKE_CXX_FLAGS
vagrant@vagrant-ubuntu-trusty-64:~/arrayfire/build$ free -m
total used free shared buffers cached
Mem: 238 53 184 0 3 12
-/+ buffers/cache: 37 200
Swap: 0 0 0
vagrant@vagrant-ubuntu-trusty-64:~/arrayfire/build$ make clean
vagrant@vagrant-ubuntu-trusty-64:~/arrayfire/build$ ls
arch.c CMakeCache.txt CMakeFiles cmake_install.cmake CTestTestfile.cmake examples gtest.patch install_manifest.txt Makefile src test third_party
vagrant@vagrant-ubuntu-trusty-64:~/arrayfire/build$ rm -rf ./*
vagrant@vagrant-ubuntu-trusty-64:~/arrayfire/build$ vi ../CMakeLists.txt
#lang racket/base
(require "remote.rkt")
; Everything up to this mark will be stripped and replaced
; for the embedded version.
; %%%END-OF-HEADER%%%
;----------------------------------------------------------------------------------
; Data that will be pre-cached before the first frame is rendered.
; The uri macro defines the name and adds a cache command to the init command list.
(uri WAV-ACTIVATE "http://s3.amazonaws.com/o.oculuscdn.com/netasset/wav/ui_object_activate_01.wav")