Skip to content

Instantly share code, notes, and snippets.

View keeran's full-sized avatar
💭
bug fixes and performance improvements

Keeran Raj Hawoldar keeran

💭
bug fixes and performance improvements
View GitHub Profile

Keybase proof

I hereby claim:

  • I am keeran on github.
  • I am keeran (https://keybase.io/keeran) on keybase.
  • I have a public key whose fingerprint is 54AA 570F 0263 840F FE46 34B0 3294 85D7 6FDE B7EC

To claim this, I am signing this object:

FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y --force-yes build-essential curl git
RUN apt-get install -y --force-yes zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev
ADD http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz /tmp/ruby-2.1.0.tar.gz
RUN cd /tmp; \
tar xzf ruby-2.1.0.tar.gz; \
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1="\[\033[0;33m\]\u@\h \w \[\033[0m\] \$(parse_git_branch) \n\[\033[0;33m\]>\[\033[0m\] "
@keeran
keeran / app.rb
Created August 22, 2014 13:22
lazy catch all http service
require 'sinatra'
require 'pp'
before do
if request.request_method == 'OPTIONS'
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Access-Control-Allow-Methods"] = "POST"
response.headers["Access-Control-Allow-Headers"] = "Origin, X-Requested-With, Content-Type, Accept"
halt 200
end
194.199.35.66 - - [12/Apr/2015:09:24:00 -0400] "GET /_ee/_fslib/swfupload/Changelog.txt HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:00 -0400] "GET /sqlite/main.php HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:00 -0400] "GET /auth/hybridauth/install.php HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:01 -0400] "GET /hybridauth/install.php HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:01 -0400] "GET /hybridauth/hybridauth/install.php HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:01 -0400] "GET /bigdump/bigdump.php HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:02 -0400] "GET /bigdump.php HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:02 -0400] "GET /dump/bigdump.php HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:02 -0400] "GET /admin/bigdump.php HTTP/1.0" 404 389 "-" "-"
194.199.35.66 - - [12/Apr/2015:09:24:02 -0400] "GET /admin/dump/bigdump.php HTTP/1.0" 404 389 "-" "-"
# /features/authentication/homepage.feature
Feature: Homepage
Scenario Outline: Popular Activity
Given I am a new visitor
When I go to /notes
Then I should see an error message
# /features/steps/authentication/homepage_steps.rb
# (copied from login example)
class Item
include DataMapper::Resource
has n, :cat_as, :through => Resource
has n, :cat_bs, :through => Resource
end
class CatA
include DataMapper::Resource
has n, :items, :through => Resource
# in spec_helper.rb
def mock_warden(scope)
warden = mock('warden')
warden.stub!("authenticate_#{scope}!").and_return(true)
warden.stub!(:authenticate!).and_return(true)
return warden
end
module ControllerExampleGroupBehaviour
Given /^I will confirm on next step$/ do
begin
evaluate_script("window.alert = function(msg) { return true; }")
evaluate_script("window.confirm = function(msg) { return true; }")
rescue Capybara::NotSupportedByDriverError
end
end
$("#SearchForm #name").autocomplete("/customers/search.json",{
minChars: 2,
highlight: false,
delay: 100,
width: 310,
parse: function(data){
var array = new Array();
for (var i=0; i < data.length; i++)
{
array[i] = {data:data[i], value: data[i].first_name, result: data[i].last_name + ", " + data[i].first_name}