Skip to content

Instantly share code, notes, and snippets.

@icleversoft
icleversoft / query.rb
Created September 2, 2016 16:53
another approach
tenant.invoices.joins(:line_items)
.includes(line_items:[:accounting])
.where('line_items.type=?', 'SimpleLineItem')
.where('line_items.description ilike ?', '%er%')
.map(&:line_items).flatten
.map(&:description)
.select{|x| x.match(/er/i)}
.sort{|a,b| a.downcase<=>b.downcase}
.uniq.first(5)
@icleversoft
icleversoft / 0_reuse_code.js
Created November 11, 2015 18:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@icleversoft
icleversoft / .vimrc.after
Last active November 6, 2015 07:06
My vimrc file
set background=dark
colorscheme railscasts " base16-railscasts railscasts
set relativenumber " show relative line numbers
@icleversoft
icleversoft / unicorn
Last active August 29, 2015 14:17 — forked from shapeshed/unicorn
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@icleversoft
icleversoft / .powenv
Created September 7, 2014 15:05
.powenv
# detect `$rvm_path`
if [ -z "${rvm_path:-}" ] && [ -x "${HOME:-}/.rvm/bin/rvm" ]
then rvm_path="${HOME:-}/.rvm"
fi
if [ -z "${rvm_path:-}" ] && [ -x "/usr/local/rvm/bin/rvm" ]
then rvm_path="/usr/local/rvm"
fi
# load environment of current project ruby
if
@icleversoft
icleversoft / Readme
Last active August 29, 2015 14:04
Script for daily backup of a mongodb database
1. Set appropriate permissions to the file
$ chmod 755 mongobackup
Then add the following entry to your crontab list
-------------------------------
@daily /home/user/mongobackup
-------------------------------
@icleversoft
icleversoft / 15_best_rails_gems
Created July 6, 2014 10:17
15 best rails gems (July 2014)
From my point of view, the gems that I’ll show later in this article represent the best options to develop in an Agile and DRY way and to achieve complex solutions in the shortest time possible.
These gems are the “core” of each our Gemfile because they allow to solve the most common problems that face in every application. In support of these gems, there are lot of gems that allow you to develop social functions, audit templates, integration with external APIs and more.
Devise (https://rubygems.org/gems/devise): Since some years ago, it represents the authentication mechanism preferred by all Rails developers. Powerful, flexible, allows to integrate with OAuth authentication systems with a minimal effort.
Haml (https://rubygems.org/gems/haml): Allows you to write valid XHTML concisely. The learning curve is relatively short.
Gritter (https://rubygems.org/gems/gritter): After years of flash messages in the classic div in the page, we moved to Growl like notifications. Thanks to these pop-ups, we can s
require_relative "task"
desc "Send an invite"
task :invite do |name, email|
puts "Invitation sent to '#{name} <#{email}>'"
end
# Example:
#
# $ rake invite "Paul Engel" [email protected]
@icleversoft
icleversoft / mapping
Last active December 29, 2015 17:39
Greek char normalized map
GR_UPPERS = {
"Α" => "α", "Β" => "β", "Γ" => "γ", "Δ" => "δ", "Ε" => "ε", "Ζ" => "ζ",
"Η" => "η", "Θ" => "θ", "Ι" => "ι", "Κ" => "κ", "Λ" => "λ", "Μ" => "μ",
"Ν" => "ν", "Ξ" => "ξ", "Ο" => "ο", "Π" => "π", "Ρ" => "ρ", "Σ" => "σ",
"Τ" => "τ", "Υ" => "υ", "Φ" => "φ", "Χ" => "χ", "Ψ" => "ψ", "Ω" => "ω"
}
GR_ALPHA = [
"ἀ", "ἁ", "ἂ", "ἃ", "ἄ", "ἅ", "ἆ", "ἇ",
"Ἀ", "Ἁ", "Ἂ", "Ἃ", "Ἄ", "Ἅ", "Ἆ", "Ἇ",
@icleversoft
icleversoft / elasticsearch.rb
Created November 14, 2013 07:17
Elasticsearch formula for using the latest (0.90.7) version of the elasticsearch server within brew package manager 1. brew install elasticsearch 2. brew edit elasticsearch 3. replace editor's contents with the contents below 4. brew unlink elasticsearch 5. brew install elasticsearch
require 'formula'
class Elasticsearch < Formula
homepage 'http://www.elasticsearch.org'
url 'http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.tar.gz'
sha1 '6cdfe366f3496b587bf440e153567d635ab64559'
head 'https://github.com/elasticsearch/elasticsearch.git'
depends_on 'maven' if build.head?