Skip to content

Instantly share code, notes, and snippets.

View zekus's full-sized avatar
🏠
Working from home

Antonio Lorusso zekus

🏠
Working from home
View GitHub Profile
# By Henrik Nyh <http://henrik.nyh.se> 2008-01-30.
# Free to modify and redistribute with credit.
# modified by Dave Nolan <http://textgoeshere.org.uk> 2008-02-06
# Ellipsis appended to text of last HTML node
# Ellipsis inserted after final word break
# modified by Mark Dickson <mark@sitesteaders.com> 2008-12-18
# Option to truncate to last full word
# Option to include a 'more' link
@zekus
zekus / back-res.sh
Created November 6, 2010 01:47
a backup script for ispconfig-3
#!/bin/bash
version="0.9.4 from 2010-09-13"
# Always download the latest version here: http://www.eurosistems.ro/back-res
# Thanks or questions: http://www.howtoforge.com/forums/showthread.php?t=41609
#
# CHANGELOG:
# -----------------------------------------------------------------------------
# version 0.9.4 - 2010-09-13
# --------------------------
# Small fix: - Corrected small bug replaced tar with $TAR in the recovery line
@zekus
zekus / gist:1020543
Created June 11, 2011 13:13 — forked from retr0h/gist:1001477
RVM + HomeBrew + Nokogiri
export BREW_HOME=/usr/local
brew install libxml2
brew link libxml2
brew install https://github.com/adamv/homebrew-alt/raw/master/duplicates/libxslt.rb
brew link libxslt
brew install libiconv
brew link libiconv
gem install nokogiri -- --with-xml2-dir=$BREW_HOME/Cellar/libxml2/2.7.8 --with-xslt-dir=$BREW_HOME/Cellar/libxslt/1.1.26 --with-iconv-dir=$BREW_HOME/Cellar/libiconv/1.13.1/
@zekus
zekus / rubystyle.md
Last active May 6, 2019 01:47
Ruby Styleguide

Antonio Lorusso's Ruby Style Guide

( Originally taken from Dan Kubb who took it from somewhere else :P )

You may not like all rules presented here, but they work very well for me and have helped producing high quality code. Everyone is free to code however they want, write and follow their own style guides, but when you contribute to my code, please follow these rules:

Formatting

@zekus
zekus / capybara.rb
Created January 29, 2013 23:21
add synchronised has_path? to capybara
module Capybara
class Session
def has_path?(path)
synchronize do
current_path == path or raise Capybara::ExpectationNotMet
end
end
def synchronize(seconds=Capybara.default_wait_time)
start_time = Time.now
@zekus
zekus / gist:5141731
Last active December 14, 2015 20:09
intersect two hashes based on their keys.
class Hash
def intersect_by_keys(another_hash)
delete_if {|k, v| !another_hash.has_key?(k) }
end
end
{a: 'one', b: 'two'}.intersect_by_keys({a: 'three', d: 'four'}) #=> {:a=>"one"}
@zekus
zekus / Vagrantfile
Created June 20, 2013 22:34
the vagrant file to launch a Dokku test box ;)
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define :dokku do |dokku|
dokku.vm.box = "raring64"
dokku.vm.box_url = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box"
dokku.vm.network :private_network, ip: "192.168.33.10"
dokku.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
@zekus
zekus / gist:6133437
Created August 1, 2013 17:23
Make pow like rvm again
# run this in the project directory
rvm env . -- --env > .powenv
# -*- coding: utf-8 -*-
require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/string/inflections'
module ActiveModel
# == Active \Model \Errors
#
# Provides a modified +Hash+ that you can include in your object
# for handling error messages and interacting with Action Pack helpers.
class AppDelegate
include BW::KVO
attr_accessor :user
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame)
@window.makeKeyAndVisible