Skip to content

Instantly share code, notes, and snippets.

@begin29
begin29 / kubernetes_run.md
Last active February 15, 2024 11:30
Kubernetes cheat sheet

Kubectl run

Create an NGINX Pod

kubectl run nginx --image=nginx

Generate POD Manifest YAML file (-o yaml). Don't create it(--dry-run)

kubectl run nginx --image=nginx --dry-run=client -o yaml

@begin29
begin29 / create_customer_and_send_trigger.rb
Last active October 28, 2022 17:02
identify/create customer and trigger event on customer_io
def user_params(user)
{
id: user.cio_id,
first_name: user.first_name,
last_name: user.last_name,
email: user.email,
}
end
cio_client = Customerio::Client.new(ENV['CUSTOMER_IO_SITE_ID'], ENV['CUSTOMER_IO_API_KEY'])
@begin29
begin29 / mutex_sync_reading.rb
Created July 18, 2019 08:48
in line 7 sometimes will be [...true, false...] values because that is not within synchronize block (line 8)
mutex = Mutex.new
flags = [false, false, false, false, false, false, false, false, false, false]
threads = 50.times.map do
Thread.new do
100000.times do
puts flags.to_s
mutex.synchronize do
flags.map! { |f| !f }
end
def match_urls_in_cities(file_names)
cities_count = {}
file_names.each do |file_name|
File.open(file_name, "r") do |f|
f.each_line do |line|
city_name = line.match(/(.*)\t/)[0].gsub("\t", "")
cities_count[city_name] ||= 0
cities_count[city_name] += 1 if is_url_present?(line)
end
end
@begin29
begin29 / vim config
Created March 2, 2019 12:23
everyday using vim config
func Backspace()
if col('.') == 1
if line('.') != 1
return "\<ESC>kA\<Del>"
else
return ""
endif
else
return "\<Left>\<Del>"
endif
@begin29
begin29 / spec_chars.rb
Last active July 12, 2017 15:58
list of usual special characters
["*", "%", "`", "-" ,"\\", "/", "[", "]", "{", "}", "&", "#", "$", "@", "!", "^", "(", ")", "'", '"', ',' ]
@begin29
begin29 / custom_pryrc.rb
Created June 26, 2017 08:32
custom pryrc with scratch file
load 'scratch.rb'
include Scratch
default_command_set = Pry::CommandSet.new do
command "scratch!", "reload scratch" do |str|
load 'scratch.rb'
end
end
Pry.config.commands.import default_command_set
@begin29
begin29 / js_equal.txt
Created June 22, 2017 10:52
how js compare statements works
# if(statement)
https://i.stack.imgur.com/MKgie.png
#if statement1 == statement2
https://i.stack.imgur.com/5bdbd.png
#if st1 === st2
https://i.stack.imgur.com/mmvud.png
@begin29
begin29 / ubuntu_applets
Created June 5, 2017 20:09
list of ubuntu default programs and applets
# network manager applet
nm-applet
@begin29
begin29 / apache_settings.sh
Created May 10, 2017 06:44
apache settings
# add new user to apache authorization
# /etc/apache2/.htpasswd - authorization file, can be rewtitted by website
# apache configuration
sudo htpasswd /etc/apache2/.htpasswd another_user