Skip to content

Instantly share code, notes, and snippets.

upstream php {
server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}
server {
listen 80; ## listen for ipv4
# listen [::]:80 default ipv6only=on; ## listen for ipv6
@romiras
romiras / backup.rake
Last active August 29, 2015 14:17 — forked from stevebartholomew/gist:50180
MySQL backup rake task for Rails 2.3.x
# put this file into directory <RAILS_ROOT>/lib/tasks
namespace :db do
desc "Backup database"
task :backup do
RAILS_ENV = "development" if !defined?(RAILS_ENV)
settings = YAML.load(File.read(File.join(Rails.root, "config", "database.yml")))[RAILS_ENV]
bak_dir = ENV['BAK_DIR']
raise(RuntimeError, "==> Error: environment variable BAK_DIR not set.") if bak_dir.blank?
extra_parameters = ["--default-character-set=utf8"]
@romiras
romiras / linux-bak-full.sh
Created July 16, 2015 08:29
Full system backup with dar
#!/bin/bash
# Full system backup with dar. Refer to http://dar.linux.free.fr/doc/Tutorial.html
## Configuration
# path to store dar backup files
Storage=/mnt/disk/backup/Linux
# name of system
SysName=Ubuntu_`. /etc/os-release; echo ${VERSION_ID/*, /}`
@romiras
romiras / my.conf
Created October 20, 2015 09:06
Redmine, DokuWiki, ownCloud - powered by NGINX with PHP5-FPM & Passenger
upstream php-handler {
server 127.0.0.1:9000;
# server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name example.com localhost;
root /var/www;
@romiras
romiras / bulk_import.rb
Created February 21, 2013 10:16
A compact class which collects and inserts bulk of data into MySql. Used for inserting large data.
# A class which collects and inserts bulk of data
# Implemented for MySQL 5
# Count of records inserted at once is configured by MAX
class BulkImporter
MAX = 100
# posts_writer = BulkImporter.new( ActiveRecord::Base.connection, Post )
def initialize(connection, klass)
@romiras
romiras / nginx
Created December 4, 2013 11:46
nginx daemon script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@romiras
romiras / Makefile.win
Created January 13, 2016 13:16
TestDLL.exe - console program for testing DLL dependencies. Usage: testdll.exe libcairo-2.dll
# Project: TestDLL
# Makefile created by Dev-C++ 5.5.1
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = main.o
LINKOBJ = main.o
LIBS = -L"C:/Program Files/Development/Dev-Cpp/MinGW32/lib" -L"C:/Program Files/Development/Dev-Cpp/MinGW32/mingw32/lib" -static-libstdc++ -static-libgcc
INCS = -I"C:/Program Files/Development/Dev-Cpp/MinGW32/include"
@romiras
romiras / rezip.py
Created January 14, 2017 12:43
ReZip - tool for recompression Zip files, used to efficiently store in SCM
#!/usr/bin/env python3
"""Read zip format file from stdin and write new zip to stdout.
With the --store option the output will be an uncompressed zip.
Uncompressed files are stored more efficiently in VCS.
Example:
python rezip.py --store < file.docx > file.flat.docx
Based on https://github.com/costerwi/rezip
@romiras
romiras / simple_fuzzy_match.rb
Created December 30, 2016 12:54
Simple function for fuzzy string match
require 'active_support/all' # mb_chars
def simple_fuzzy_match(s1, s2)
levenshtein_distance( normalize_str(s1), normalize_str(s2) ) < 2
end
def normalize_str(s)
s.
mb_chars. # convert to multibyte string (ActiveSupport::Multibyte::Chars) - required in Ruby version below 2.4
downcase. # lower case for all characters
@romiras
romiras / Gemfile
Created May 8, 2019 07:31
EventMachine async URL fetcher
source "https://rubygems.org"
gem 'eventmachine'
gem 'em-http-request'