Skip to content

Instantly share code, notes, and snippets.

@konalegi
konalegi / elasticsearch@5.6.rb
Last active December 27, 2020 14:49
elasticsearch installation 5.6
class ElasticsearchAT56 < Formula
desc "Distributed search & analytics engine"
homepage "https://www.elastic.co/products/elasticsearch"
url "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.16.tar.gz"
sha256 "6b035a59337d571ab70cea72cc55225c027ad142fbb07fd8984e54261657c77f"
bottle :unneeded
keg_only :versioned_formula
@konalegi
konalegi / gist:251e87a16a84ab52fb4f6991e6fdd9af
Created January 15, 2019 09:04
polygon example for postgres
MULTIPOLYGON(((37.5056929 54.2008506,37.5062568 54.1994723,37.5099223 54.2006269,37.5118154 54.1988833,37.5153198 54.1969747,37.5145461 54.1966598,37.514212 54.1965582,37.5139981 54.1963549,37.5135704 54.1959795,37.5129823 54.1954869,37.5129288 54.1953462,37.5131828 54.1949552,37.5130491 54.1945329,37.5126214 54.1938761,37.511766 54.1930628,37.5113085 54.1925583,37.5047572 54.1987943,37.5043775 54.1986668,37.502154 54.1863217,37.5059916 54.1883161,37.5076028 54.1887404,37.507925 54.1909086,37.5098584 54.1911443,37.5114318 54.1909827,37.5129155 54.1896219,37.5117927 54.1892309,37.5118729 54.188965,37.5124076 54.1878701,37.5128353 54.187041,37.5165511 54.1879365,37.5160565 54.1887773,37.5158494 54.1891448,37.5160833 54.1891918,37.5165243 54.1893013,37.5192377 54.1899269,37.5207614 54.1905134,37.5220445 54.189575,37.5242098 54.1892778,37.5255197 54.1888242,37.5265088 54.1882924,37.5279523 54.1888711,37.5282999 54.188746,37.5297434 54.1878231,37.5307875 54.1874393,37.5266675 54.1859526,37.5251113 54.1854347,37.52
# This is decryption of signed cookies (note that doesn't apply for encrypted cookies)
# Only for rails 4.2
SIGNED_COOKIE_SALT = 'signed cookie' # it's just constant in rails code.
secret_key_base = ''
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
secret = key_generator.generate_key(SIGNED_COOKIE_SALT)
verifier = ActiveSupport::MessageVerifier.new(
secret,
digest: 'SHA1',
serializer: ActiveSupport::MessageEncryptor::NullSerializer
op = ::Admin::Client::Create.(params)
render_client(op.profile)
@konalegi
konalegi / exmaple.json
Created October 7, 2016 11:08
query exmaples
# index query
{
"meta": {
"total": 450
},
"data": [
{
"name": "user name",
require "minitest/autorun"
class SequenceParser
def self.calc_sequence(input)
words = []
input.each_char do |char|
last_elem = words.last
if last_elem.nil?
words << { elem_count: 1, elem: char }
else
@konalegi
konalegi / config
Last active September 21, 2015 10:24
sublime config
{
"bold_folder_labels": true,
"caret_style": "wide",
"color_scheme": "Packages/Railscasts Extended/Railscasts Extended.tmTheme",
"draw_white_space": "all",
"fade_fold_buttons": false,
"font_size": 11,
"highlight_line": true,
"ignored_packages":
[
[user]
email = jkonalegi@gmail.com
name = Danil Nurgaliev
[color]
diff = auto
status = auto
branch = auto
interactive = auto
[diff]
renamelimit = 0
@konalegi
konalegi / num_method.rb
Created April 13, 2015 19:37
numerical method
def f(x)
x**3 - 0.2 * x**2 - 0.2 * x - 1.2
# x**4 + 2 * x**3 - x - 1
end
def calc(x_min, x_max, old = 9999, accuracy = 0.0001)
found_x = (x_min + x_max) / 2
p found_x
val = f((x_max + x_min)/2)
return found_x if (old - found_x).abs < accuracy