Skip to content

Instantly share code, notes, and snippets.

View tanraya's full-sized avatar

Andrew Kozlov tanraya

  • Astana, Kazakhstan
View GitHub Profile
# encoding: utf-8
require 'mechanize'
require 'stringex'
require 'tempfile'
require Rails.root.join('app/models/category')
require Rails.root.join('app/models/product')
class Parser
BASE_URL = "http://asiaopt.com"
URL_MASK = "#{BASE_URL}/products/page:%s"
definitions
definition1
definition2
definition3
synonymes
synonym1
definition1
definition2
definition3
synonym2
#########################################################################################
# Manage websites
class Dashboard::WebsitesController < ApplicationController
before_action :find_website, only: %w(show edit update destroy)
def index
@websites = current_user.websites
end
@tanraya
tanraya / pgsync
Created August 14, 2013 01:01
Synchronize postgres production database with local development. NOTE: you need to create .pgpass file on production first.
ssh er -t 'pg_dump -h localhost -U estrabota estrabota_production | gzip > /tmp/estrabota.gz'
scp er:/tmp/estrabota.gz ./tmp
psql -U postgres -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'estrabota_development';"
psql -U postgres -c "DROP DATABASE estrabota_development;"
psql -U postgres -c "CREATE DATABASE estrabota_development WITH TEMPLATE = template0 ENCODING = 'UNICODE' OWNER estrabota;"
gunzip -c ./tmp/estrabota.gz | psql -U postgres estrabota_development
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'example.ru' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.yandex.ru",
:port => 587,
:domain => 'example.ru',
:user_name => 'info@example.ru',
:password => 'passwd',
:authentication => 'plain'
{
count: function() {
return function (text, render) {
return counter++
}
},
hasDefinitions: function() { return this.definitions.length > 0 },
expandFirst: function() {
return counter == 1
},
module RandomORG
FORMAT = :plain
BASE = 10
RND = :new
COL = 1
MIN = 1
DIGITS = :on
LOWERALPHA = :on
UPPERALPHA = :on
UNIQUE = :on
grammar Interpolation
rule document
(text / variable / object / space)* {
def content
elements.map { |e| e.content }
end
}
end
######################################################################
# encoding: utf-8
require 'valid_email'
class Vacancy < ActiveRecord::Base
include Workflow
# Сколько рубрик разрешено иметь
RUBRICS = 1..3
# Разрешенные периоды публикации
@tanraya
tanraya / gist:3982789
Created October 30, 2012 20:26
Column Resizer
class @ColumnResizer
doc : null
columnsWrapper : null
dragging : false
currentGutter : null
snapped :
x1: 0,
x2: 0
gutterWidth : 20
spanWidth : 60