Skip to content

Instantly share code, notes, and snippets.

View kirugan's full-sized avatar
:atom:
Creating awesomeness

Kirill kirugan

:atom:
Creating awesomeness
View GitHub Profile
@kirugan
kirugan / tinkoff.go
Created April 9, 2020 15:19
Small script to analyze payIn and payOut in tinkoff investment
package main
import (
"context"
"fmt"
"math/rand"
"os"
"time"
sdk "github.com/TinkoffCreditSystems/invest-openapi-go-sdk"
@kirugan
kirugan / fast.c
Created March 3, 2020 08:48
Fast frequency dictionary
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/mman.h>
typedef struct freq {
int freq;
char* word;
@kirugan
kirugan / state_machine.go
Created February 28, 2020 10:21
Interesting implementation of state machine in Golang
package main
import "fmt"
type connection struct {
closed bool
usage int
}
type state func(*connection) state
@kirugan
kirugan / restart_goland.sh
Created February 21, 2020 14:49
Constantly run GoLand ide after exit (useful after trial period expiration)
#!/bin/bash
while :
do
echo "Starting Goland...";
/Applications/GoLand.app/Contents/MacOS/goland;
done
@kirugan
kirugan / test.c
Created December 6, 2019 20:45
Free bits in pointers (tested on amazon graviton processors)
#include <stdio.h>
#include <stdint.h>
int main() {
int x = 10;
int* y = &x;
printf("Hey! %p (size=%zu)\n", y, sizeof(y));
uint64_t mask = 0;
for (int j = 63; j > 55; j--) {
@kirugan
kirugan / competition.cpp
Last active October 11, 2020 20:39
Template for competitive programming
#include <bits/stdc++.h>
using namespace std;
#define ALL(X) begin(X), end(X)
int main() {
// solution comes here
}
@kirugan
kirugan / failure_rate.go
Created June 7, 2019 13:25
Simple script that allows you to get experience with failure rate
package main
import (
"fmt"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
@kirugan
kirugan / infinite.go
Created March 20, 2019 21:15
Go scheduler design migh lead your code to freeze
package main
import (
"fmt"
"runtime"
"sync"
"time"
)
func main() {
@kirugan
kirugan / redis_client.go
Created March 1, 2019 17:41
debug pool
package main
import (
"context"
"fmt"
"github.com/gomodule/redigo/redis"
"sync"
"sync/atomic"
"time"
)
@kirugan
kirugan / condition_test.go
Created February 8, 2019 10:42
sync.Cond demonstration
package main
import (
"fmt"
"sync"
"time"
)
func main() {
nConnections := 10