Skip to content

Instantly share code, notes, and snippets.

View nodirt's full-sized avatar

Nodir Turakulov nodirt

View GitHub Profile
// Package better is a better implementation of log.Logger
package better
type Logger struct {
}
func (l *Logger) Print(v ...interface{}) {
//....
}
package main
import (
"better"
"log"
)
// Logger is a subset of log.Logger methods that we need.
type MyLogger interface {
Print(v ...interface{})
// Package better is a better implementation of log.Logger
package better
type Logger struct {
}
func (l *Logger) Print(v ...interface{}) {
//....
}
@nodirt
nodirt / sort012.py
Last active December 17, 2015 08:19
Sorting an array consisting of 0, 1 and 2
import random
def sort012(array):
n = len(array)
p0 = 0 # end of the '0' block
p2 = n - 1 # beginning of the '2' block
i = 0
while i <= p2:
x = array[i]
package code;
public class MinWordRegion {
public static class Result {
/** zero-based */
public int start;
/** zero-based */
public int end;
public int length() {
@nodirt
nodirt / gist:6662833
Last active December 23, 2015 16:29
Problem: given a long sequence of numbers, find those *two* that have odd number of occurrences. Limitations: * the sequence can be traversed only once * 10 KB of memory
/*
Problem: given a long sequence of numbers, find those *two* that have odd number of occurrences.
Limitations:
* the sequence can be traversed only once
* 10 KB of memory
*/
using System;
using System.Collections.Generic;
// helloworld.proto
syntax = "proto3";
package helloworld;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
type greeterService struct{}
func (s *greeterService) SayHello(c context.Context, req *helloworld.HelloRequest) (*helloworld.HelloReply, error) {
if req.Name == "" {
return nil, grpc.Errorf(codes.InvalidArgument, "Name unspecified")
}
return &helloworld.HelloReply{
Message: "Hello " + req.Name,
}, nil
client := &prpc.Client{Host: "prpc-helloworld.appspot.com"}
greeter := helloworld.NewGreeterPRPCClient(client)
ctx := context.Background()
res, err := greeter.SayHello(ctx, &helloworld.HelloRequest{
Name: "nodir",
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
@nodirt
nodirt / keybase.md
Created February 12, 2016 08:02
keybase.md

Keybase proof

I hereby claim:

  • I am nodirt on github.
  • I am nodir (https://keybase.io/nodir) on keybase.
  • I have a public key whose fingerprint is C907 0A16 B427 AE00 C122 FD90 3A20 9BAE 675C FA5E

To claim this, I am signing this object: