Skip to content

Instantly share code, notes, and snippets.

View petrblaho's full-sized avatar

Petr Blaho petrblaho

  • Brno, Czech Republic
View GitHub Profile
module MyApp
class IncViewsCounterFor < ::Liquid::Tag
Syntax = /(#{::Liquid::Expression}+)?/
def initialize(tag_name, markup, tokens, context)
if markup =~ Syntax
@name = $1
else
raise ::Liquid::SyntaxError.new("Syntax Error in 'inc_views_counter_for' - Valid syntax: inc_views_counter_for <content>")
@petrblaho
petrblaho / 1st
Created June 21, 2012 11:40
Rails routing for nested resources with :as parameter
api_post_comments GET /api/posts/:post_id/comments(.:format) comments#index
POST /api/posts/:post_id/comments(.:format) comments#create
new_api_post_comment GET /api/posts/:post_id/comments/new(.:format) comments#new
edit_api_post_comment GET /api/posts/:post_id/comments/:id/edit(.:format) comments#edit
api_post_comment GET /api/posts/:post_id/comments/:id(.:format) comments#show
PUT /api/posts/:post_id/comments/:id(.:format) comments#update
DELETE /api/posts/:post_id/comments/:id(.:format) comments#destroy
api_posts GET /api/posts(.:format) posts#index
POST /api/posts(.:format) posts#create
new_api_post GET /api/posts/new(.:format) posts#new
invitationCode: null hojoki.app.js:109
Port error: Could not establish connection. Receiving end does not exist. miscellaneous_bindings:232
XHR finished loading: "http://my.hojoki.com/api/hojoki/v1/validateSession". jquery.min.js:4
validateSession done: {"sessionID":"29BFB645289E9E447AB2ED906CFBC7D5","user":{"firstName":"Petr","lastName":"Blaho","hasProfileImage":false,"profileImageUrl":"https://secure.gravatar.com/avatar/a5b27a9cca728e4c7dfc3ce8b55c2082.png?s=64&d=http://my.hojoki.com/static/images/artwork/avatars/Hoki8.png","active":true,"primaryFOAFPersonURI":"http://schema.hojoki.com/eas/1.0/uri/hojoki.com/user#cKWqpQo5Y1bZg7NT8x8GWT5pcr4=","foafPersonURIs":["http://schema.hojoki.com/eas/1.0/uri/hojoki.com/user#cKWqpQo5Y1bZg7NT8x8GWT5pcr4="],"primaryEmailAddress":"petr.blaho@gmail.com","emailAddresses":["petr.blaho@gmail.com"],"beta":false,"locale":"cs_CZ","newsletter":true,"hasPassword":false,"pendingEmailAddresses":[],"mobile":{"parse":{"channel":"my_hojoki_com_128899"}}},"authenticationType":"openid_go
<template>
<name>Fedora 15 Template</name>
<os>
<name>Fedora</name>
<version>15</version>
<arch>x86_64</arch>
<install type='url'>
<url>http://download.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/x86_64/os/</url>
</install>
<rootpw>p@ssw0rd</rootpw>
@petrblaho
petrblaho / output1.txt
Created July 27, 2012 12:57
rspec style compare
ProviderAccountsController
API
when requesting XML
when using admin credentials
#index
with parent provider specified
when there are 3 provider accounts for specified provider
behaves like http OK
response status code
DEPRECATION WARNING: Passing the format in the template name is deprecated. Please pass render with :formats => [:xml] instead. (called from realtime at /usr/lib/ruby/1.8/benchmark.rb:308)
@petrblaho
petrblaho / genesis.txt
Created August 3, 2012 17:30
The Beginning
In the beginning — specifically on October 23, 4004 B.C., at noon — out of quantum foam fluctuation God created the Big Bang. The bang was followed by cosmological inflation. God saw that the Big Bang was very big, too big for creatures that could worship him, so He created the earth. And darkness was upon the face of the deep, so He commanded hydrogen atoms (which He created out of Quarks and other subatomic goodies) to fuse and become helium atoms and in the process release energy in the form of light. And the light maker he called the sun, and the process He called fusion. And He saw the light was good because now He could see what he was doing. And the evening and the morning were the first day.
And God said, Let there be lots of fusion light makers in the sky. Some of these fusion makers appear to be more than 4,004 light years from Earth. In fact, some of the fusion makers He grouped into collections He called galaxies, and these appeared to be millions and even billions of light years from Earth, so
<deployable name="My Deployable">
<description>This is an example deployment</description>
<assemblies>
<assembly name="samplehost" hwp="hwp1">
<image id="a2669b76-dcc0-11e1-a64c-525400d26afe" />
</assembly>
</assemblies>
</deployable>
@petrblaho
petrblaho / provider_accounts_spec.rb
Created August 8, 2012 16:05
saved in spec/requests/api/
require 'spec_helper'
describe "ProviderAccounts" do
let(:headers) { {
'HTTP_ACCEPT' => 'application/xml',
'CONTENT_TYPE' => 'application/xml'
} }
before(:each) do
user = FactoryGirl.create(:admin_permission).user
@petrblaho
petrblaho / f15.tpl
Created August 15, 2012 14:31
fedora 15 template for aeolus
<template>
<name>Fedora 15 Template</name>
<os>
<name>Fedora</name>
<version>15</version>
<arch>x86_64</arch>
<install type='url'>
<url>http://download.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/x86_64/os/</url>
</install>
<rootpw>p@ssw0rd</rootpw>
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.10)
actionpack (= 3.0.10)
mail (~> 2.4.0)
actionpack (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)