Skip to content

Instantly share code, notes, and snippets.

View vjt's full-sized avatar
💭
looking at the stars

Marcello Barnaba vjt

💭
looking at the stars
View GitHub Profile
@vjt
vjt / awesome-nginx.conf
Created January 31, 2011 19:43
*AWESOME* nginx configuration for Ruby/Rack web applications
#
# mmm m m mmm mmm mmm mmmmm mmm
# " # "m m m" #" # # " #" "# # # # #" #
# m"""# #m#m# #"""" """m # # # # # #""""
# "mm"# # # "#mm" "mmm" "#m#" # # # "#mm"
#
# nginx configuration For Ruby/Rack web applications
#
# Cooked up with style, care and a bit of *secret*
# nerdy spice. :-)
#!/bin/sh
# System startup script for Redis for OpenSUSE >= 11.4
#
# Author: Marcello Barnaba <[email protected]>
# Tue Jul 31 17:32:27 CEST 2012
#
# LSB-compatible service control script; see http://www.linuxbase.org/spec/
# Install it in /etc/init.d/redis and run insserv /etc/init.d/redis
# Define configurations in /etc/init.d/redis/NAME.conf
@vjt
vjt / antani_require.rb
Created January 11, 2011 13:56
ruby require tree
# Wanna debug who the hell is requiring that damn gem
# you don't wanna see on earth? Here we go! :-)
#
# debugger rescue nil is required (ha ha) because, if
# you require ruby-debug, the debugger method will be
# defined *before* all debugger components are loaded
#
# Please note that, because this method is defined in
@vjt
vjt / rails2_3-ruby1_9-encoding-fix.rb
Created November 9, 2010 18:25
Rails 2.3 + Ruby 1.9 + Encoding "issues" fix
# Keywords: Rails 2.3, Ruby 1.9
# Error: invalid byte sequence in US-ASCII
# Error: incompatible character encodings: UTF-8 and ASCII-8BIT
#
# This patch overwrites every ActionView::Helpers::TagHelper
# method and the "value" and "value_before_type_cast" methods
# of ActionView::Helpers::InstanceTag, to force the UTF8
# encoding on their return value, if applicable.
#
# This is done because the source encoding of Rails' files is
# CouchDB replication configuration restore,
# after a restart via the init script.
# Configure your replicas in a plain text file:
-----8<------------------------------------------------------->8------
# Credentials to access the database,
# in the username:password format.
#
@vjt
vjt / html2rtf.rb
Created September 16, 2010 19:58
# HTML to RTF conversion routine
# Requires panmind-rtf gem, version 0.4.1 and up
# Really quick & dirty, needs love and documentation
# Injects a .to_rtf method into any Nokogiri NodeSet
# and returns an RTF::Document instance
#
# If you find this code useful, contribute back to the
# panmind-rtf gem! http://github.com/Panmind/rtf
#
# (C) 2010 mind2mind.is, spinned off http://panmind.org/
/**
* Usage:
*
* js> "some:string.you?wanna-escape".escapeChars(/[:\.\?-]/g);
* ==> "some%3Astring%2Eyou%3Fwanna%2Descape"
*
* The full power of regexes is in your hands, use it for good!
*
* - [email protected]
* Fri Aug 6 21:26:20 CEST 2010
# $Id: Portfile 66285 2010-04-08 08:09:09Z [email protected] $
# Tweaked upstream privoxy Portfile to install the latest CVS
# version that fixes hang bugs in the 3.0.16 release -- while
# retaining IPv6 support :-).
#
# [email protected] - Fri Jul 30 18:14:38 CEST 2010
#
PortSystem 1.0
#!/bin/sh
# Glue script to make a lessc compiler installed via RVM to work nicely
# with the Textmate Less Bundle (http://github.com/appden/less.tmbundle)
# - [email protected] - Public Domain
#
# Replace the following with the rvm Ruby version you want lessc run with
#
RUBY=ruby-1.9.1-p378@some_gem_set
# Rails 2.3.5, Ruby 1.9. ERB returns templates with an ASCII-8BIT encoding, unless they contain
# an unicode character, and when you render a partial with unicode chars into a layout without,
# the infamous "incompatible character encodings: ASCII-8BIT and UTF-8" error comes out.
#
# This module monkey-patches module_eval into the ActionView::Base::CompiledTemplates module to
# convert the first argument encoding to UTF-8, if needed.
#
# Put it into lib/patches/compiled_templates.rb and require it into the config.after_initialize
# block of your environment.rb.
#