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 / ruby-books.rb
Last active February 11, 2020 18:41
ruby, rails books
# === ruby books
# confident ruby
https://www.dropbox.com/sh/t4xu4t3hitqvqjy/AAAncKJ2s_9R-74WHv8zdVdYa?dl=0
# fareless refactoring
https://www.dropbox.com/sh/pobxg0jpz7ndho1/AACS84n6AAFnx1ppl4M2MNjLa?dl=0
# Sandy Metz Practical ruby design
https://www.dropbox.com/s/p8oejgchshk16ki/Sandi%20Metz%20-%20Practical%20Object-Oriented%20Design%20in%20Ruby.epub?dl=0
# Rails as she is spoke 2012
https://www.dropbox.com/s/jqvlcj15jv11hh3/Docfoc.com-Rails%20as%20She%20is%20Spoke.pdf?dl=0
# lean-publishing-growing-rails-applications-in-practice-2014
@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 / rebase.sh
Created December 2, 2015 19:18
How to fix pull request?
# I am working on new feature
$ git checkout -b some-new-feature
#Changed files, commit and push to source
git add . && git commit -m 'some cool changes' && git push origin some-new-feature
#After comments within pull request I need to fix some code
#After fix it and commit I can see 2 commits within git history
$ git add . && git commit -m 'some fix to cool changes' && git push origin some-new-feature
$ git log
@begin29
begin29 / linux.sh
Last active August 25, 2017 05:53
Linux commands and articles
#create link
ln -s /path/to/file /path/to/symlink
#see all available memory
df -h
#returns the number of lines, words, and bytes in a file. Can use -l, -w, -c to get just one of these.
wc
# change user password
@begin29
begin29 / spec_chars.rb
Last active July 12, 2017 15:58
list of usual special characters
["*", "%", "`", "-" ,"\\", "/", "[", "]", "{", "}", "&", "#", "$", "@", "!", "^", "(", ")", "'", '"', ',' ]
@begin29
begin29 / ruby-articles.rb
Last active July 8, 2017 02:53
ruby, rails useful articles
# factory patern in ruby
http://rubyblog.com.ua/2016/04/factory-method-pattern-in-ruby
#ruby recursion
https://www.leighhalliday.com/recursion-in-ruby
# ruby on rails optimisation tips
https://infinum.co/the-capsized-eight/articles/top-8-tools-for-ruby-on-rails-code-optimization-and-cleanup
# write faster ruby app