Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
:trollface:

Victor Maslov Nakilon

💭
:trollface:
View GitHub Profile
@Nakilon
Nakilon / news.md
Last active Jul 27, 2021
The most important (in my opinion) changes in Ruby versions
View news.md

N -- new feature -- I may consider using it
B -- breaking change -- I should review my code

https://github.com/ruby/ruby/blob/ruby_2_1/NEWS

N def-expr now returns the symbol of its name instead of nil.
N Array#to_h converts an array of key-value pairs into a Hash.
N Enumerable#to_h converts a list of key-value pairs into a Hash.
N Binding#local_variable_get(symbol)
N Exception#cause provides the previous exception which has been caught at where raising the new exception.
View 1.1.bfn
~:00pv<@.$>#$<
5:~::<|-5-
\68*-+ v$\_
v0g00$<> #-
>\00p\00g:|
@Nakilon
Nakilon / autoexec.cfg
Last active Nov 3, 2017
CS:GO dedicated server
View autoexec.cfg
log on
hostname "Nakilon CS:GO old de_dust2 Dedicated Server"
rcon_password *****
host_info_show 2
host_players_show 2
exec banned_user.cfg
exec banned_ip.cfg
View logging_with_labels.rb
Google::Cloud::Logging::Logger.class_eval do
%i{ debug info warn error }.each do |level|
old = instance_method level
define_method level do |message, entry_labels = {}, &block|
logger_labels = @labels if @labels
begin
@labels = (@labels || {}).merge entry_labels
old.bind(self).(message, &block)
ensure
@Nakilon
Nakilon / example.rb
Created Jun 13, 2017
Simplified example of using google-cloud-monitoring to store custom metrics of my daemons RAM/fd leakage
View example.rb
require "google/cloud/monitoring/v3/metric_service_client"
client = Google::Cloud::Monitoring::V3::MetricServiceClient.new
project_path = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path JSON.load(File.read ENV["GOOGLE_APPLICATION_CREDENTIALS"])["project_id"]
create_custom_gauge_metric = lambda do |type, display_name, value_type, labels = {}|
metric_descriptor = Google::Api::MetricDescriptor.new( # googleapis-common-protos-1.3.5/lib/google/api/metric_pb.rb
type: "custom.googleapis.com/#{type}",
metric_kind: :GAUGE, # google-cloud-monitoring-0.24.0/lib/google/cloud/monitoring/v3/doc/google/api/metric.rb
value_type: value_type, # google-cloud-monitoring-0.24.0/lib/google/cloud/monitoring/v3/doc/google/api/metric.rb
display_name: display_name,
@Nakilon
Nakilon / google_vision.rb
Last active Nov 19, 2016
snippets about Google Vision usage (for DevFest Siberia 2016)
View google_vision.rb
ENV["GCLOUD_KEYFILE"] = "./key.json"
require "gcloud"
GV = Gcloud.new("my_app").vision
GV.annotate(
GV.image("./google_vision/temp.jpg"),
labels: true,
).gapi.to_h
@Nakilon
Nakilon / plus_vs_minus.rb
Last active Nov 2, 2016
the most straight code perfomance comparison ever, lol
View plus_vs_minus.rb
# either run it in irb or .join some thread to prevent program exit
i = 0
Thread.new do
puts i while sleep 1
end
Thread.new do
loop{ i += 1 }
end
View gist:955d64f353b103fa25d5e766f968f2bf
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKOJygfeqxk6yVuQdEdarz7BRtYKOa15NpzVhWdt9BltQY3y9R74UpEbYAd3/C3Fax+mQp4kJy7eBO4wxRBUl0/EIkMq691dwAajLK3U0nZylWRZDUjNpXMhZ8W1W95xv3/Li3o4ssi3Ns9Dkny7/aQOVPl/ggUFIG4jVebkxcv0b0b84Aq6jEGwIV8Og1Ps2FjoHvUw1SlAoNj2wRQfMW6BzbzOkyCeTwzl7gk2D1f8XysyY0WeJGQn3m3WnTAY8oSDLCCSzUNbP/swekdGf5j9M3ldhlf9OJb39/aq+dYCDItteu/KQj5av8btn4ntmv8Gf+y5O+n3AuXD7VQwh7 nakilon@nakibook.local
@Nakilon
Nakilon / Gemfile
Last active Sep 18, 2016
azona bot
View Gemfile
source "https://rubygems.org"
gem "net_http_utils", ?0, gist: "97549ceb58d21e1fcbc0e6cdaf92fce8"
gem "nokogiri"
gem "byebug"
View net_http_utils.gemspec
Gem::Specification.new do |spec|
spec.name = "net_http_utils"
spec.summary = ??
spec.version = "0.2"
spec.author = "Victor Maslov"
spec.files = %w{ net_http_utils.rb }
spec.require_path = "."
end