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 / great.cpp
Last active April 10, 2020 11:05
Playing with template for FixedPoint naive implementation
#include <iostream>
template<std::size_t T>
struct FixedPoint {
static constexpr int Size = T;
int value;
static_assert(Size < sizeof(value) * 8);
};
constexpr FixedPoint test(double d) {
@kirugan
kirugan / main.cpp
Created April 9, 2020 18:52
Diff between primitive type initialization using new[ ] operator
int main() {
auto a = new int[1000];
a[500] = 33;
auto b = new(a) int[1000];
std::cout << b[500] << std::endl;
return 0;
}
@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() {