Skip to content

Instantly share code, notes, and snippets.

View bryanp's full-sized avatar

Bryan Powell bryanp

View GitHub Profile
@bryanp
bryanp / gist:2128765
Created March 20, 2012 00:08
pakyow > heroku
bryanp-mbp:desktop bryan$ pakyow new pakyow-heroku
bryanp-mbp:desktop bryan$ cd pakyow-heroku
bryanp-mbp:pakyow-heroku bryan$ bundle init
Writing new Gemfile to /Users/bryan/Desktop/pakyow-heroku/Gemfile
bryanp-mbp:pakyow-heroku bryan$ mate Gemfile
bryanp-mbp:pakyow-heroku bryan$ bundle install
Fetching source index for http://rubygems.org/
Using i18n (0.6.0)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
@bryanp
bryanp / gist:2152493
Created March 21, 2012 20:21
Pakyow View Processor
# Goes in application class at same level as routes block.
parsers do
parser [:md, :markdown] do |content|
Nokogiri::HTML.fragment(RDiscount.new(content).to_html).to_html
end
parser :haml do |content|
Haml::Engine.new(content).render
end
@bryanp
bryanp / gist:2428216
Created April 20, 2012 12:35
Pakyow Server Handler Config Example
configure(:env) do
server.handler = 'puma'
end
@bryanp
bryanp / gist:3056711
Created July 5, 2012 21:49
Pakyow 0.8 View Method Usage
# View:
# <div class="post" data-scope="post">
# <h1 data-prop="title">Title goes here.</h1>
#
# <p data-prop="body">
# Body goes here.
# </p>
# </div>
#
# <div class="post" data-scope="post">
--- view:
<div scope="post">
<h1 prop="title"></h1>
</div>
--- data:
[
{ title: 'one', important: false },
@bryanp
bryanp / rvalues_at.rb
Created November 18, 2013 19:16
Method for finding values in nested hash.
class Hash
def rvalues_at(keys)
Array(keys).inject([]) { |arr, key| key.is_a?(Hash) ? arr.concat(self[key.keys[0]].rvalues_at(key.values[0])) : arr << self[key] }
end
end
hash = {
one: 1,
two: 2,
three: {
@bryanp
bryanp / gist:7678061
Last active December 29, 2015 13:29
Pakyow 0.8 - session middleware example
Pakyow::App.define do
# ...
middleware do
use Rack::Session::Cookie, :key => 'myapp.session', :secret => 'shhh'
end
end
@bryanp
bryanp / 1 Setup
Last active August 29, 2015 13:56
Pakyow 0.8 Benchmarks
Ruby 2.1.0
Sinatra 1.4.4
Pakyow 0.8.0
Thin 1.6.1
Tested on an 8GB Digital Ocean Droplet
Benchmark command: siege -r 1000 -b http://localhost:3000
@bryanp
bryanp / gist:9605202
Created March 17, 2014 18:22
Pakyow Request Path / View Mapping
REQ PATH VIEW PATH
/ index.html
/foo foo.html OR foo/index.html
/foo/bar foo/bar.html OR foo/bar/index.html

Keybase proof

I hereby claim:

  • I am bryanp on github.
  • I am bryanp (https://keybase.io/bryanp) on keybase.
  • I have a public key whose fingerprint is 1520 20FE 448B 78B0 0458 6B86 CCFD 09CD B246 C9BE

To claim this, I am signing this object: