Skip to content

Instantly share code, notes, and snippets.

View blahutka's full-sized avatar

blahutka blahutka

View GitHub Profile
@blahutka
blahutka / Gemfile
Created January 20, 2016 11:33 — forked from terraboops/Gemfile
Simple Mechanize Scraper
source 'https://rubygems.org'
gem 'mechanize'
@blahutka
blahutka / riot_model.js
Last active August 29, 2015 14:21
Riot model
// Source: https://github.com/muut/riotjs/issues/727
var Model = function (attrs) {
// init
this.attributes = attrs || {}
riot.observable(this)
// set method
this.set = function (key, val, options) {
<comment-box>
<h1>{ opts.title }</h1>
<comment-list url={ opts.url } comments={ comments } />
<comment-form url={ opts.url } />
this.comments = []
add(comment) {
this.comments.push(comment)
@blahutka
blahutka / input_parser.coffee
Last active August 29, 2015 14:12
Question parser
App = Ember.Application.create()
App.Router.map ->
# put your routes here
App.IndexRoute = Ember.Route.extend(model: ->
parsedInput: 'ol'
)
# spec_helper.rb
require 'rspec'
require 'watir-webdriver'
require 'page-object'
require 'page-object/page_factory'
require 'require_all'
require_all 'lib/pages'
RSpec.configure do |config|
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
module CapybaraWithPhantomJs
include Capybara
# Create a new PhantomJS session in Capybara
def new_session
# Register PhantomJS (aka poltergeist) as the driver to use
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app)
end
@blahutka
blahutka / gist:5690891
Last active December 17, 2015 23:39
Formtastic + erector
module Erector::Rails
class FormBuilder
def method_missing(method_name, *args, &block)
if parent.respond_to?(method_name)
return_value = parent.send(method_name, *args, &block)
case return_value
when ActiveSupport::SafeBuffer
template.concat(return_value)
.fc {
direction: ltr;
text-align: left; }
.fc table {
border-collapse: collapse;
border-spacing: 0; }
.fc .btn {
line-height: 1.2em; }
html .fc {
@blahutka
blahutka / nginx
Created February 21, 2012 11:11
Start nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d script for Ubuntu 8.10 and lesser versions.
# Description: nginx init.d script for Ubuntu 8.10 and lesser versions.
### END INIT INFO