Skip to content

Instantly share code, notes, and snippets.

View mwf's full-sized avatar

Ivan Korolev mwf

  • Avito
  • Moscow, Russia
View GitHub Profile
package main
import (
"fmt"
"math"
"time"
)
func isPrime(num int32) bool {
if num == 2 {
package main
import (
"fmt"
"math"
"time"
)
func isPrime(num int) bool {
if num == 2 {
@mwf
mwf / merge.go
Created July 2, 2020 00:29
Merge channels in Golang
package main
import (
"fmt"
)
// merge prints stuff from two channels.
//
// This example is a friendly reminder, that closed channel still produces events in loop.
// https://play.golang.org/p/6TwGnvyvhQC
@mwf
mwf / foo.proto
Created May 22, 2019 15:39
github.com/utrack/clay "application/x-www-form-urlencoded" marshaller
syntax = "proto3";
import "google/api/annotations.proto";
service Foo {
rpc ParseForm (FormData) returns (FormData) {
option (google.api.http) = {
post: "/form"
body: "*"
};
@mwf
mwf / escape_test.go
Last active May 22, 2019 14:33
Go escape analysis and allocations test
// go test -gcflags '-m' -benchmem -bench .
// BenchmarkAllocsFoo-4 5000000 387 ns/op 32 B/op 1 allocs/op
// BenchmarkAllocsFooPointer-4 3000000 481 ns/op 80 B/op 4 allocs/op
package main
import (
"fmt"
"io/ioutil"
"testing"
)
@mwf
mwf / bench_test.go
Last active February 11, 2019 15:08
Go Interface conversion benchmarks
package example
import (
"testing"
)
type foo struct {
name string
}
@mwf
mwf / Installation-tutorial-for-Git-Server-on-OS-X.md
Last active June 15, 2021 08:10
Mac OS X 10.9 - Create system user and allow ssh login

A small tutorial for how to set up Git Server on Mac OS X. The main dificulty was to create a "system" user (aka "daemon", uid<=500) and allow ssh login for it.

  1. I need 'git'-user to be system - not visible in standart users list.
  2. I need to allow ssh access only for some users/groups.

The tutorial for Git server setting up - http://git-scm.com/book/ca/Git-on-the-Server-Setting-Up-the-Server

So I need to create system user 'git' with homefolder.

System user creation script - http://serverfault.com/a/532860. I've modified it a little and uploaded here https://gist.github.com/mwf/20cbb260ad2490d7faaa#file-create_sys_user-sh.

class _Missing(object):
def __repr__(self):
return 'no value'
def __reduce__(self):
return '_missing'
_missing = _Missing()