Skip to content

Instantly share code, notes, and snippets.

View kzaitsev's full-sized avatar

Kirill Zaitsev kzaitsev

  • Limassol, Cyprus
View GitHub Profile
require 'resolv'
require 'dry/types'
require 'dry/validation'
require 'pp'
module MyTypes
include Dry.Types()
REGEX256 = Resolv::IPv4::Regex256
REGEXP = {
require 'dry-types'
require 'dry-validation'
module Types
include Dry::Types.module
end
ctx = Dry::Validation.Schema do
required(:some_int).filled(Types::Strict::Int)
required(:some_bool).filled(Types::Strict::Bool)
require 'test_helper'
class NoisyString
def coerce(value, options = {})
value.to_s.upcase
end
end
class User
include ShallowAttributes
@kzaitsev
kzaitsev / 00.howto_install_phantomjs.md
Last active August 29, 2015 14:26 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
<!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>
@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))") }
package migrationutil
import (
m "github.com/drone/drone/server/database/migrationutil"
)
// Test create table
type Migrate_100000000001 struct{}
if ENV['RAILS_ENV'] == 'production'
puts "USING PATCHED CARRIERWAVE"
module CarrierWave
module Uploader
module Url
def url(options = {})
if file.respond_to?(:path)
@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
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