Skip to content

Instantly share code, notes, and snippets.

View kigster's full-sized avatar
:octocat:
@repos.select { |r| r.is_a?(Gem) }.publish("https://rubygems.org")

Konstantin Gredeskoul kigster

:octocat:
@repos.select { |r| r.is_a?(Gem) }.publish("https://rubygems.org")
View GitHub Profile
@kigster
kigster / gist:4751844
Last active August 1, 2020 23:46
PostgreSQL config file for high performance writes on Joyent Cloud, used by Wanelo.com in production (4K commits/second on a dedicated 80GB instance).
max_connections = 1500 # (change requires restart)
shared_buffers = 12000MB # min 128kB, based on 80GB RAM DB
temp_buffers = 8MB # min 800kB
work_mem = 64MB # min 64kB
maintenance_work_mem = 1500MB # min 1MB
wal_level = hot_standby # minimal, archive, or hot_standby
checkpoint_segments = 256 # in logfile segments, min 1, 16MB each
checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
max_wal_senders = 6 # max number of walsender processes
@kigster
kigster / gist:5557990
Created May 10, 2013 22:47
SSL errors uploading tags to boundary
[2013-05-10T15:37:41-07:00] INFO: Processing execute[Install the boundary daemon on SmartOS] action run (wanelo-base::boundary line 8)
[2013-05-10T15:37:42-07:00] INFO: Processing bprobe[admin.prod] action create (wanelo-base::boundary line 17)
[2013-05-10T15:37:42-07:00] INFO: Creating meter [admin.prod]
[2013-05-10T15:37:42-07:00] ERROR: Could not create meter [admin.prod], failed with SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
[2013-05-10T15:37:42-07:00] FATAL: Could not get meter id, failed with SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
[2013-05-10T15:37:42-07:00] ERROR: Could not save meter id as node attribute, failed with exit
[2013-05-10T15:37:42-07:00] FATAL: Could not get meter id, failed with SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
[2013-05-10T15:37:42-07:00] ERROR: Could not apply meter tag, failed with exit
[2013-05-10T15:37:42-07:00] F
ip address 142.254.103.242 255.255.255.240
no ip address 50.0.240.178 255.255.255.252
access-list outside_access_in extended permit tcp host 76.14.64.13 any eq ssh
no route outside 0.0.0.0 0.0.0.0 50.0.240.177 1
route outside 0.0.0.0 0.0.0.0 142.254.103.241 1
@kigster
kigster / order_summary_service.rb
Created September 22, 2015 21:00
Compacted using some meta-programming to avoid repeated code
require 'rspec'
require 'ostruct'
require 'Money'
I18n.enforce_available_locales = false
class Order < OpenStruct
end
module Api
class OrderSummaryItem < ::Struct.new(:id, :display_name, :value_cents, :display_value)
@kigster
kigster / LongExceptionDescription.rb
Created February 17, 2016 04:12
Cool way to provide a long multi-line description for an Exception
# taken from rspec-core's file pending.rb
if block_given?
raise ArgumentError, <<-EOS.gsub(/^\s+\|/, '')
|The semantics of `RSpec::Core::Pending#pending` have changed in
|RSpec 3. In RSpec 2.x, it caused the example to be skipped. In
|RSpec 3, the rest of the example is still run but is expected to
|fail, and will be marked as a failure (rather than as pending) if
|the example passes.
|
@kigster
kigster / irb.rb
Last active February 22, 2016 06:01
/Applications/RubyMine EAP.app/Contents/rb/testing/runner/irb.rb
require "irb"
$LOAD_PATH << `pwd`.chomp + '/lib'
Dir.glob('lib/*.rb').map{|f| f.gsub(%{lib/}, '')}.each do |file|
require file
end
IRB.start(__FILE__)
#!/usr/bin/env bash
[[ ! -x /usr/local/bin/airport ]] && \
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
[[ ! -x /usr/local/bin/watch ]] \
&& cd /usr/local/bin && sudo curl -O http://ktwit.net/code/watch-0.2-macosx/watch && sudo chmod 755 watch
watch_wifi() {
watch "airport -s | awk 'BEGIN{FS=\" -\"}{printf(\"%10d%s\n\", -\$2, \$0)}' | sort -nr"
}
#!/usr/bin/env bash
#
# (c) 2015-2016 Shippo Inc.
# Author: Konstantin Gredeskoul, kig@reinvent.one
# http://reinvent.one
#
# Run via http://sw.im/shippo
#
# This bootstrap script is supposed to be run as follows:
# curl -fsSL 'http://sw.im/shippo' | /usr/bin/env bash
@kigster
kigster / struct_optional_arguments.rb
Created August 9, 2016 00:11
This example demonstrates how to create Ruby Structs that use newer hash-style parameters, and are able to have default values for some of the properties. Raw
# This example demonstrates how to create Ruby Structs that use
# newer hash-style parameters, as well as the default values for
# some of the parameters, without loosing the benefits of struct's
# implementation of #eql? #hash, #to_s, #inspect, and other
# useful instance methods.
#
# Run this file as follows
#
# > gem install rspec
# > rspec struct_optional_arguments.rb --format documentation
@kigster
kigster / maintained-badges.markdown
Created May 28, 2017 08:52 — forked from ELLIOTTCABLE/maintained-badges.markdown
Replacements for StillMaintained badges

Since http://stillmaintained.com is, ironically, no longer maintained, here's some custom GitHub badges for your dead, stale, or frozen projects:

: https://img.shields.io/badge/maintained%3F-no!-red.svg?style=flat
: https://img.shields.io/badge/maintained%3F-seeking:_help_me!-yellow.svg?style=flat
: https://img.shields.io/badge/maintained%3F-rapidly_changing!-orange.svg?style=flat
: https://img.shields.io/badge/maintained%3F-yes!-brightgreen.svg?style=flat
: https://img.shields.io/badge/maintained%3F-feature--frozen-lightgrey.svg?style=flat

You can modify these using [Shields.