Skip to content

Instantly share code, notes, and snippets.

View groovili's full-sized avatar

Maksym Ivanov groovili

  • Kyiv, Ukraine
View GitHub Profile
@groovili
groovili / lambda_cloudwatch_schedule.tf
Last active November 13, 2018 16:18
AWS CloudWatch schedule for lambda execution
resource "aws_lambda_function" "check" {
filename = "./check.zip"
function_name = "check"
role = "arn:aws:iam::424242:role/something"
handler = "main"
runtime = "go1.x"
source_code_hash = "${base64sha256(file("./check.zip"))}"
}
resource "aws_cloudwatch_event_rule" "every_twelve_hours" {
@groovili
groovili / dpgo.md
Created July 6, 2018 08:14 — forked from jsam/dpgo.md
dpgo

Design patterns with Go

Course Materials

  • Handouts / Worksheets
  • Slides
  • Code Examples
  • Videos

Course objectives

@groovili
groovili / singleton.go
Created July 6, 2018 08:14 — forked from jackypanster/singleton.go
singleton in golang
package singleton
import (
"sync"
)
type singleton struct {
}
var instance *singleton
@groovili
groovili / latency.txt
Created July 3, 2018 19:13 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
package main
import (
"fmt"
"sync"
"time"
)
type Fetcher interface {
Fetch(url string) (body string, urls []string, err error)
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
func _walk(t *tree.Tree, ch chan int) {
if t == nil {
return
@groovili
groovili / git-tags-add-and-delete.sh
Last active May 12, 2018 07:20 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# add tag
git tag 12345
# push tags to remote
git push --tags
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
@groovili
groovili / int_2_roman.php
Last active December 13, 2017 15:39
CLI script to convert integer to roman number
<?php
function getPeriod(int $int, int $n): int {
$m = '1';
$m .= str_repeat(0, $n);
return $int * ((int) $m);
}
function getRomanNumber(int $input): string{
<?php
function cm(array $ar1, array $ar2, int $rc = 0): array
{
$duplicatePositions = [];
$merged = [];
foreach($ar1 as $key => &$value){
if($dk = array_search($value, $ar2, true)){
$duplicatePositions[$dk] = $ar2[$dk];