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
module KappaOne
## I want the value of 'test' to be memoized & available in class KappaOneOne and KappaOneTwo
def test
@test ||= some_timetaking_method
end
class KappaOneOne
def initialize
@val = test.to_s
end
@Marahin
Marahin / kappa.rb
Last active February 9, 2017 10:50
✗ pry
[1] pry(main)> module Kappa
[1] pry(main)* def Kappa.parser
[1] pry(main)* if ! @name
[1] pry(main)* sleep(5)
[1] pry(main)* @name = 'John'
[1] pry(main)* end
[1] pry(main)* @name
[1] pry(main)* end
[1] pry(main)*
➜ xgo git:(master) ✗ ./xgo -x -v --targets=windows/amd64 ~/Code/go/src/git.3lab.re/marahin/artsh_helper_11
Checking docker installation...
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:31:53 2017
OS/Arch: darwin/amd64
➜ xgo git:(master) ✗ ./xgo -x -v --deps=https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz\?r\=\&ts\=1500380157\&use_mirror\=netcologne\ https://dropbox.gimb.us/b/eafaa5ae36898da07a3dac1ad08f8ecc.gz --targets=windows/amd64 ~/Code/go/src/git.3lab.re/marahin/artsh_helper_11
Checking docker installation...
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:31:53 2017
OS/Arch: darwin/amd64
➜ 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
# 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
➜ 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"
➜ ~ 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}"
@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
@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