Skip to content

Instantly share code, notes, and snippets.

@akovardin
akovardin / valsort.go
Last active July 2, 2018 20:47 — forked from kylelemons/valsort.go
Valsort
package main
import "fmt"
import "sort"
func main() {
m := map[string]int{
"One": 1,
"Two": 2,
"Three": 3,
@akovardin
akovardin / panic-recover.go
Last active July 2, 2018 20:51 — forked from fipar/panic-recover.go
Panic/Recover
package main
import (
"fmt"
"time"
)
func mainLoop() {
fmt.Println("starting main loop, this will die after dividing by 0")
i := 0
@akovardin
akovardin / smtp-gmail-send.go
Last active February 18, 2019 10:02 — forked from jpillora/smtp-gmail-send.go
Send email using Go via GMail
package main
import (
"log"
"net/smtp"
)
func main() {
send("hello there")
}
@akovardin
akovardin / tumblr-download.go
Last active July 2, 2018 20:40 — forked from indraniel/tumblr-download.go
Go and tumblr
/*
This is a go program to download pictures from a tumblr blog page.
To Build:
go build -o tumblr-download tumblr-download.go
To Run:
# download the photos on the first page of tumblr blog
@akovardin
akovardin / md5-example.go
Last active July 26, 2018 17:31 — forked from sergiotapia/md5-example.go
Go MD5 string
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@akovardin
akovardin / README.md
Created March 6, 2018 23:12 — forked from rjeczalik/README.md
Go, multiple packages and coveralls.io

Go, multiple packages and coveralls.io

Single profile for single Go package

For Go projects that consist of only one package, the following Travis configuration is enough to get started with coveralls.io. You may want to encrypt your $COVERALLS_TOKEN via Travis encryption keys though.

language: go
go:
 - 1.3.1
@akovardin
akovardin / image-proxy.conf
Created July 11, 2018 11:05 — forked from tmaiaroto/image-proxy.conf
Nginx Image Filter Resize Proxy Service
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.
@akovardin
akovardin / Makefile
Created October 21, 2018 20:17
Makefile for Go Projects
GOPATH=$(shell pwd)/vendor:$(shell pwd)
GOBIN=$(shell pwd)/bin
GOFILES=$(wildcard *.go)
GONAME=$(shell basename "$(PWD)")
PID=/tmp/go-$(GONAME).pid
build:
@echo "Building $(GOFILES) to ./bin"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o bin/$(GONAME) $(GOFILES)
@akovardin
akovardin / gomake.md
Created September 4, 2019 23:15 — forked from rkravchik/gomake.md
Golang alternatives to makefiles.

Go build tasks utilities

Инструментов мало. Тема сообществом мало проработана. Возможно, makefile всех устраивает.

Первая группа: замена утилиты make:

  • makex понимает уже существующие makefiles.

Вторая группа: разнородные инструменты:

  • goxc в своё время популярный сборщик для кроссплатформенной разработки.
@akovardin
akovardin / DownloadAndSaveAudioFile.swift
Created January 19, 2020 21:20 — forked from UmairSharif99/DownloadAndSaveAudioFile.swift
Function to download audio file from url and save it in documents directory
func downloadAndSaveAudioFile(_ audioFile: String, completion: @escaping (String) -> Void) {
//Create directory if not present
let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.libraryDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
let documentDirectory = paths.first! as NSString
let soundDirPathString = documentDirectory.appendingPathComponent("Sounds")
do {
try FileManager.default.createDirectory(atPath: soundDirPathString, withIntermediateDirectories: true, attributes:nil)
print("directory created at \(soundDirPathString)")