Skip to content

Instantly share code, notes, and snippets.

View shmdt's full-sized avatar
💭
🇺🇦

Kovalenko Anton shmdt

💭
🇺🇦
View GitHub Profile
@shmdt
shmdt / install_postgis_osx.sh
Created February 7, 2017 15:55 — forked from juniorz/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@shmdt
shmdt / pg_hba.conf
Last active March 24, 2017 07:43 — forked from slenderock/pg_hba.conf
# ubuntu: sudo nano /etc/postgresql/<< version >>/main/pg_hba.conf
# Позволяет любому пользователю локальной системы подключиться
# к любой базе данных, используя любое имя базы данных через
# доменные сокеты Unix (по умолчанию для локальных подключений).
#
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
# То же, но для локальных замкнутых подключений по TCP/IP.
@shmdt
shmdt / 1 Gist conventions
Created March 24, 2017 07:49 — forked from PavloBezpalov/1 Gist conventions
Deploy Rails 5.0.0.beta3 to VPS(Ubuntu 14.04.4 LTS). Nginx, Puma, Capistrano3, PostgreSQL, RVM.
<<APP>> change this variables
upstream puma_<%= fetch(:nginx_config_name) %> { <%
flags = 'fail_timeout=0'
@backends = [fetch(:puma_bind)].flatten.map do |m|
etype, address = /(tcp|unix|ssl):\/{1,2}(.+)/.match(m).captures
if etype =='unix'
"server #{etype}:#{address} #{fetch(:nginx_socket_flags)};"
else
"server #{address.gsub(/0\.0\.0\.0(.+)/, "127.0.0.1\\1")} #{fetch(:nginx_http_flags)};"
end
end
@shmdt
shmdt / database.yml.example mysql2
Created April 11, 2017 09:35 — forked from erichurst/database.yml.example mysql2
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@shmdt
shmdt / sphinx-macosx.sh
Created April 14, 2017 07:41 — forked from ubermuda/sphinx-macosx.sh
Installing sphinxsearch on macosx
# first sphinx
brew install sphinx
# the formula does not install libsphinxclient :/
wget http://sphinxsearch.com/files/sphinx-2.0.4-release.tar.gz
tar xzf sphinx-2.0.4-release.tar.gz
cd sphinx-2.0.4-release/api/libsphinxclient/
CXXCPP="gcc -E" ./configure --prefix=/usr/local
make
make install
@shmdt
shmdt / sinatra_render_html.rb
Created May 24, 2017 08:25 — forked from kinopyo/sinatra_render_html.rb
How to render static HTML files in Sinatra.
require 'sinatra'
get '/' do
File.read(File.join('public', 'index.html'))
# or
# send_file File.join(settings.public, 'index.html')
end
@shmdt
shmdt / Gemfile
Last active June 19, 2017 09:15 — forked from ctalkington/Gemfile
Nginx, Sinatra, and Puma.
source :rubygems
gem "puma"
gem "sinatra"
@shmdt
shmdt / gist:67229e42a6160c2c95ce336bf27b3625
Created September 14, 2017 12:21 — forked from i556/gist:1661623
Cross Domain iframe Resizing
http://mohumohu/parent.html
http://hogehoge.com/iframe.html
//parent.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
@shmdt
shmdt / rails-jsonb-queries
Created April 11, 2018 06:57 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")