This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<style> | |
div { | |
position:relative; | |
} | |
#images div { | |
float:left; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(File.dirname(__FILE__) + '/../config/environment') unless defined?(Rails) | |
class DbIndexes | |
def initialize(app, message = "Database Indexes") | |
@app = app | |
@message = message | |
end | |
def call env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
folder=/media/storage/Backup/ | |
file=$folder/backup_$(date +"%Y_%m_%d_%H-%M") | |
echo 'Change directory and remove files older than 7days' | |
cd $folder | |
find *.tgz -mtime +7 |xargs rm | |
echo 'Backup process...' | |
if [ -d $folder ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'daemons' | |
require 'optparse' | |
require 'ostruct' | |
# Daemons sets pwd to /, so we have to explicitly set RAILS_ROOT | |
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Waiting for desktop loaded | |
sleep 10 | |
wmctrl -o 1500,0 && /opt/google/chrome/google-chrome 2>&1 & | |
sleep 2 | |
wmctrl -o 3000,0 && opera 2>&1 & | |
sleep 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'daemons' | |
require 'optparse' | |
require 'ostruct' | |
# Daemons sets pwd to /, so we have to explicitly set RAILS_ROOT | |
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
d1=[83,51] | |
d2=[85,31] | |
d3=[18,137] | |
A = d2[0] - d1[0]; | |
B = d2[1] - d1[1]; | |
C = d3[0] - d1[0]; | |
D = d3[1] - d1[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Checking the memcached & sphinx running | |
if $0 == 'script/server' | |
# Check for memcached | |
begin | |
# check if memcached is running; if it is, use that instead of the default memory cache | |
Timeout.timeout(0.5) { TCPSocket.open("localhost", 11211) { } } | |
config.cache_store = :mem_cache_store, %w(localhost:11211), { :namespace => 'zimaletto', :timeout => 60 } | |
$stderr.puts "\033[0;32mUsing memcached on localhost:11211\033[0;34m" | |
rescue StandardError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script/performance/benchmarker 50 "Banner.within_street('М').collect(&:street)" | |
user system total real | |
#1 20.300000 0.030000 20.330000 ( 25.248899) | |
script/performance/benchmarker 50 'Banner.search("^М*", :per_page => 10000).collect(&:street)' | |
user system total real | |
#1 107.010000 0.100000 107.110000 (109.985505) | |
script/performance/benchmarker 1000 'BannerFormat.all' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/posts_controller.rb | |
class PostsController < ApplicationController | |
def index | |
@posts.all_cached # Retrive only at once by every 5 minutes | |
expires_in 5.minutes, :private => false, :public => true | |
end | |
end | |
# app/models/post.rb | |
Class Post |
OlderNewer