Skip to content

Instantly share code, notes, and snippets.

View tejo's full-sized avatar

Matteo Parmi tejo

View GitHub Profile
require 'rspec/expectations'
require 'capybara/cucumber'
require 'capybara/poltergeist'
require 'spreewald/web_steps'
Capybara.run_server = false #Disable internal forking
if ENV['IN_BROWSER']
# On demand: non-headless tests via Selenium/WebDriver
# To run the scenarios in browser (default: Firefox), use the following command line:
@tejo
tejo / designer.html
Created July 26, 2014 01:20
designer
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../paper-slider/paper-slider.html">
<polymer-element name="my-element">
<template>
<style>
:host {
require 'json'
require 'typhoeus'
require 'logger'
module Yoox
class Config
class << self
attr_accessor :host, :logger, :api_key
@tejo
tejo / config.ru
Created March 5, 2012 22:02
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
# The following lines should come as no surprise. Except by
@tejo
tejo / gist:1852627
Created February 17, 2012 10:50
bmfetch
require 'net/http'
require 'uri'
require 'nokogiri'
require 'json'
url = URI.parse('http://www.bikemi.com/localizaciones/localizaciones.php')
res = Net::HTTP.start(url.host, url.port) {|http|
http.get('/localizaciones/localizaciones.php')
}
@tejo
tejo / gist:1758953
Created February 7, 2012 10:16
geocation class
GeoLocator = (function() {
function GeoLocator() {
this.watch = __bind(this.watch, this); this.watcher = navigator.geolocation.watchPosition(this.watch, this.geo_error, {
enableHighAccuracy: true,
frequency: 3000,
maximumAge: 2000,
timeout: 27000
});
this.map = new Map(document.getElementById("map"));
@tejo
tejo / boggle_it.coffee
Created January 15, 2012 12:26
italian boggle
Array::randomize = -> @sort -> 0.5 - Math.random()
class Boggle
constructor: ->
@dices = [
['A', 'Z', 'F', 'S', 'Qu', 'B'],
['G', 'C', 'S', 'V', 'P', 'A'],
['H', 'I', 'S', 'E', 'R', 'N'],
['A', 'I', 'O', 'B', 'M', 'C'],
['T', 'I', 'V', 'E', 'N', 'G'],
require 'csv'
namespace :locale do
namespace :translations do
desc 'export translations'
task :export => :environment do
params_check
locale = ENV['locale'].to_sym
model = translate_model
class Admin::BaseController < InheritedResources::Base
before_filter :persist_params, :only => :index
def persisted_params
(self.class.to_s + "_persisted").to_sym
end
def persist_params
session[persisted_params] ||= {}
[:page, :search].each do |k|
class Node < ActiveRecord::Base
attr_accessor :related_nodes_ids
after_save :save_related_nodes
before_destroy :clear_related_nodes
def related_nodes=(nodes_ids)
@related_nodes_ids = nodes_ids.compact.reject { |s| s.blank? }
end