Skip to content

Instantly share code, notes, and snippets.

View slawosz's full-sized avatar

Sławosz Sławiński slawosz

View GitHub Profile
@slawosz
slawosz / why-go.md
Last active December 25, 2015 14:39
Why go programming language is so awesome?

I was asked once by https://github.com/jjperezaguinaga:

I am of the impression that you have a strong love fan for Go.
What's so cool about it? I'm kind of curious.

So here are my anwsers:

  • easy to learn: http://tour.golang.org took me about 15 hours to complete (with browsing documentation)
  • language is easy and minimalistic
  • awesome standard library
Commands:
* show_hotels
* show_locations
Hotel and locations will be loaded from csv file
gauges => {
"cpu" => {
"value" => 82
},
"memory_utilization" => {
"value" => 3028
},
"disk_read" => {
"value" => 22.2
}
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME", "1"]
@slawosz
slawosz / .zprofile
Last active December 20, 2015 20:09
export GOPATH=/vagrant/go
export GOROOT=/home/vagrant/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
array = [['Number', 'Name'], [1, 'Foo'], [2, 'Bar'], [3, 'Baz']]
array.each do |sub_array|
sub_array.each do |elem|
print elem
print ', '
end
print "\n"
end
array = [['Number', 'Name'], [1, 'Foo'], [2, 'Bar'], [3, 'Baz']]
pretty_table(array)
# printed result:
+--------+--------+
| Number | Name |
+--------+--------+
| 1 | Foo |
array = [['Number', 'Name'], [1, 'Foo'], [2, 'Bar'], [3, 'Baz']]
pretty_table(array)
# printed result:
+--------+--------+
| Number | Name |
+--------+--------+
| 1 | Foo |
@slawosz
slawosz / eventloop.rb
Created July 27, 2013 21:33
Echo server event loop in ruby
require 'socket'
server = TCPServer.new(2000)
clients = []
buffers = {}
while true
sockets = [server] + clients
readable, writable = IO.select(sockets)
readable.each do |sock|
begin
➜ threads cat read_nonblock.rb
require 'benchmark'
result = Benchmark.measure do
(1..4).map { |i|
f = File.open("tmp#{i}.txt", 'w')
1.upto(100_000) do
f.write_nonblock('a' * 100) rescue nil
end
}