Skip to content

Instantly share code, notes, and snippets.

View Marahin's full-sized avatar
:shipit:
self.class.new

Jasiek Matusz Marahin

:shipit:
self.class.new
View GitHub Profile
[1] pry(main)>
[2] pry(main)> A = [1]
=> [1]
[3] pry(main)> A << 2
=> [1, 2]
[4] pry(main)> A
=> [1, 2]
[1] pry(main)> A = [1].freeze
=> [1]
[2] pry(main)> A.frozen?
=> true
[1] pry(main)> A = [1]
=> [1]
[2] pry(main)> A = [2]
(pry):2: warning: already initialized constant A
(pry):1: warning: previous definition of A was here
=> [2]
@Marahin
Marahin / constant_change.rb
Last active October 24, 2018 11:02
Workaround for the constant assignment warning
[2] pry(main)> B = [2]
=> [2]
[3] pry(main)> B << 3
=> [2, 3]
@Marahin
Marahin / constant.rb
Created October 10, 2018 19:33
Ruby's constant not so constant
[1] pry(main)> A = 1
=> 1
[2] pry(main)> A = 2
(pry):2: warning: already initialized constant A
(pry):1: warning: previous definition of A was here
=> 2
[3] pry(main)> A
=> 2
@Marahin
Marahin / script.sh
Created October 2, 2018 08:30
GREP to ignore all leading whitespace characters and find only lines that are not commented out with a "#"
grep '^[[:blank:]]*[^[:blank:]#;]' file.conf
➜ ~ pry
[1] pry(main)> 76561198173573574.0 == 76561198173573570.0
=> true
[2] pry(main)> 76_561_198_173_573_574 == 76561198173573570.0
=> false
[3] pry(main)> 76_561_198_173_573_574 == 76_561_198_173_573_570
=> false
[4] pry(main)> 76_561_198_173_573_574 == 76_561_198_173_573_574
=> true
[5] pry(main)> puts "#{76_561_198_173_573_574}"
➜ artsh_helper git:(master) go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/marahin/Code/go"
GORACE=""
GOROOT="/opt/go"
# golang.org/x/sys/unix
../src/golang.org/x/sys/unix/dirent.go:68: undefined: direntReclen
../src/golang.org/x/sys/unix/dirent.go:74: undefined: direntIno
../src/golang.org/x/sys/unix/dirent.go:82: undefined: direntNamlen
../src/golang.org/x/sys/unix/syscall_linux.go:825: ParseDirent redeclared in this block
previous declaration at ../src/golang.org/x/sys/unix/dirent.go:64
../src/golang.org/x/sys/unix/syscall_linux_amd64_gc.go:13: gettimeofday redeclared in this block
previous declaration at ../src/golang.org/x/sys/unix/syscall_linux_amd64.go:67
../src/golang.org/x/sys/unix/syscall_unix_gc.go:12: Syscall redeclared in this block
previous declaration at ../src/golang.org/x/sys/unix/syscall_unix.go:52
➜ xgo git:(master) ✗ docker build -t xgo-pngzlib .
Sending build context to Docker daemon 1.006MB
Step 1/2 : FROM karalabe/xgo-latest
---> 84e22b5b5304
Step 2/2 : RUN apt install -y libpng-dev zlib1g-dev
---> Using cache
---> 06ff979c622d
Successfully built 06ff979c622d
Successfully tagged xgo-pngzlib:latest