Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# This script may be used to backup files having a specific extension
source="/path/to/source/dir"
dest="/path/to/rep/backup"
day=$(date +%d-%m-%Y)
# backup img files
@addame
addame / es.txt
Created February 17, 2012 01:07 — forked from karussell/Query-DSL-elasticsearch.txt
Bird's Eye View on ElasticSearch its Query DSL
Several times in a month there pop up questions regarding query structure on the ElasticSearch user group.
Although there are good docs explaining this in depth probably the bird view of the Query DSL is necessary to
understand what is written there. There is even already some good external documentation available:
http://www.elasticsearch.org/tutorials/2011/08/28/query-dsl-explained.html
And there were attempts to define a schema:
http://groups.google.com/group/json-schema/browse_thread/thread/ae498ee818155d50
https://gist.github.com/8887766ca0e7052814b0
@addame
addame / will_paginate.rb
Created November 23, 2011 14:28 — forked from leifcr/will_paginate.rb
Extends will_paginate to play well with Twitter's Bootstrap (http://twitter.github.com/bootstrap/). Suggested location: config/initializers/will_paginate.rb
# https://gist.github.com/1305042
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
# a dirty method to write all installed gems in a file as commands ready ... for installation
# useful when upgrading (even if rvm is a killer ;-) )
require "date"
def list_installed_gems
gems = `gem list`
all_gems = gems.chomp!.split(/\n/)
@f = File.open("gem_list_install_#{Date.parse(Time.now.to_s).to_s}.sh", "w")
# create install commande
#!/bin/sh
# Author: Carl Youngblood, 2010
# Based on http://www.novell.com/coolsolutions/feature/15380.html
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
# This is a script to install both ruby 1.8.7 and 1.9.1, with suffixed binaries and symlinks
mkdir -p /usr/local/src ; cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p160.tar.bz2
tar -xjvf ruby-1.8.7-p160.tar.bz2
cd ruby-1.8.7-p160
./configure --prefix=/usr --program-suffix=18 --enable-shared
make && sudo make all install
cd /usr/local/src
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
# alternative Block execution on empty Enumerable
# see : http://blog.sponagl.de/2009/1/23/alternative-block-execution-on-empty-enumerable
# 1.
ary = []
ary.each do |i|
puts i
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }