Skip to content

Instantly share code, notes, and snippets.

View alex-fedorov's full-sized avatar

Oleksii Fedorov alex-fedorov

View GitHub Profile
xrandr --output DP2 --mode 1280x1024 --same-as eDP1 ; xrandr --output eDP1 --mode 1280x1024 --same-as DP2
HELLO world
cmd/cgo/ast.go
278: error_(token.NoPos, "unexpected type %T in walk", x, visit)
cmd/compile/internal/gc/align.go
340: * type T *struct { next T }
cmd/compile/internal/gc/const.go
138: if t != nil && t.Etype == TIDEAL && n.Val().Ctype() != CTINT {
cmd/compile/internal/gc/dcl.go

Code quality proposal for Golang

Maintaining Single Responsibility Principle

When creating a package, please create a README.md for it with its name and short explanation of its responsibility. Then each time you add/modify any functionality you can refer to README.md and see if it is suitable to put it in this package or it needs to have its own package.

When creating a file inside of package, please put short comment in the beginning of the file what it should contain, what is the job of this submodule.

#!/usr/bin/env bash
set -e
## Developer Environment
# setup
mkdir -p ~/setup
cd ~/setup
@alex-fedorov
alex-fedorov / a.rb
Last active August 29, 2015 14:22
DI example
# Without DI:
# It knows what kind of datastore it has
# This way you just mixed URL, HTTP methods and stuff here
class Person
API_URL = "#{ROOT_API_URL}/api/v2/people"
def save
return insert if new?
update
end
  • hello
    • world
    • test
      • bga
        • bga
          • bga
            • bga
              • bga
                • bga
  • bga
@alex-fedorov
alex-fedorov / rsion.rb
Created June 4, 2015 09:31
Rsion plugin
def rsion
puts "This is Rsion, baby"
end
@alex-fedorov
alex-fedorov / short.rb
Last active August 29, 2015 14:12
Very weird singleton example in ruby (with help of eigenclasses)
# Short version of previous file (if you don't care about class names)
SomeClass = Class.new do
class << self
class << self
def instance; singleton_class end
class << self
def some_method
"here go dragons"
end
@alex-fedorov
alex-fedorov / better_struct.rb
Last active August 29, 2015 14:11
BetterStruct
class BetterStruct < Struct
class << self
def new(*required, **properties)
super(*(required + properties.keys)) do
define_singleton_method(:_default_values) do
properties
end
end
end