Skip to content

Instantly share code, notes, and snippets.

View kzaitsev's full-sized avatar

Kirill Zaitsev kzaitsev

  • Limassol, Cyprus
View GitHub Profile
@kzaitsev
kzaitsev / schedule.rb
Created February 10, 2014 21:37
sochi 2014
require 'nokogiri'
require 'excon'
require 'active_support/time'
require 'pp'
sch = []
(2..17).each do |day|
day_of_month = day + 6
response = Excon.get("http://www.sochi2014.com/ezhednevnoe-raspisanie-den-#{day}")
page = Nokogiri::HTML(response.body)
module Slugeable
extend ActiveSupport::Concern
included do
extend FriendlyId
friendly_id :slug_candidates, use: :slugged
def slug_candidates
if defined?(self.posted_at)
"#{posted_at}-#{name}"
$ cat /var/log/upstart/drone.log
2014/04/06 15:04:10 Database already up-to-date.
2014/04/06 15:04:10 starting drone version 2a009fa on port :8081
2014/04/06 20:03:56 Database already up-to-date.
2014/04/06 20:03:56 starting drone version 2a009fa on port :8081
2014/04/06 20:05:20 Database already up-to-date.
2014/04/06 20:05:20 starting drone version 2a009fa on port :8081
2014/04/06 20:11:11 error updating github status: Not Found
starting service container bradrydzewski/postgres:9.1
creating build image
Program.all.each do |p|
p.update_attribute(:hours, "до 8 часов") if p.hours.blank?
p.update_attribute(:peoples, "до 300 человек") if p.peoples.blank?
end
namespace :deploy do
before 'deploy:assets:precompile', :clean_css_cache do
on roles(:app), in: :sequence, wait: 5 do
within release_path do
if test("[ -d #{shared_path}/tmp/cache/assets ]")
if test("[ -d #{shared_path}/tmp/cache/assets/production ]")
if test("[ -d #{shared_path}/tmp/cache/assets/production/sprockets ]")
out = capture("grep -r -l 'application.css' #{shared_path}/tmp/cache/assets/production/sprockets/")
out.split("\n").each do |o|
execute :rm, o.gsub("\r", '').to_s
@kzaitsev
kzaitsev / example.rb
Last active August 29, 2015 14:02
example.rb
hash = {lists: @lists}
hash.merge!(default: @lists.index(@default_list)) if @default_list
hash.to_json
if ENV['RAILS_ENV'] == 'production'
puts "USING PATCHED CARRIERWAVE"
module CarrierWave
module Uploader
module Url
def url(options = {})
if file.respond_to?(:path)
package migrationutil
import (
m "github.com/drone/drone/server/database/migrationutil"
)
// Test create table
type Migrate_100000000001 struct{}
@kzaitsev
kzaitsev / gist:0ad1f2b6597af930db63
Created December 4, 2014 13:54
PostGIS search point in districts polygons
scope :contains, -> (point) { where("ST_contains(polygon, ST_Transform(ST_GeomFromText('#{point}', 4326), 4326))") }
<!doctype html>
<html>
<head>
</head>
<body>
<h1>Web Font Loader Demos</h1>
<p>
Demonstrations of pure CSS and JavaScript-enhanced use of @font-face.
</p>