Skip to content

Instantly share code, notes, and snippets.

View kolotaev's full-sized avatar
🦔
githubbing...

kolotaev

🦔
githubbing...
View GitHub Profile
@kolotaev
kolotaev / Dockerfile
Created April 13, 2017 14:33
trpl-ebook Dockerfile
# Docker image for trpl-ebook 'The Rust Programming Language' as EBook project.
# All you need to do is copy this file and build docker image from it and run command cargo run --release in container.
FROM scorpil/rust:1.12
RUN apt-get update && \
apt-get install --yes --no-install-recommends \
git \
ca-certificates \
inotify-tools \
version: '2'
services:
redis:
image: redis:alpine
container_name: redis_db
command: redis-server --appendonly yes
ports:
- 6379:6379
volumes:
@kolotaev
kolotaev / golang-pre-commit
Created October 25, 2017 11:29
Pre commit hook for golang
#!/bin/sh
# Script does not handle file names that contain spaces.
# It runs all the checks. If any of the checks fails, it doesn't stop, but rather collects all the errors.
has_errors=0
# get go files to check against
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
[ -z "$gofiles" ] && exit 0
@kolotaev
kolotaev / wget.py
Last active March 9, 2018 11:57
wget that interrupts its execution and resumes back
#!/usr/bin/env python3
# usage: ./wget.py link-to-download [interrupt-timeout]
import subprocess
import sys
download_timeout = 60 * 3 # 3 minutes - default
if len(sys.argv) < 2:
import gzip
import sys
s = """
aaaa
"""
se = s.encode("utf8")
sez = gzip.compress(se)
raw_size = len(se)
#!/bin/sh
# Script does not handle file names that contain spaces.
# It runs all the checks. If any of the checks fails, it doesn't stop, but rather collects all the errors.
has_errors=0
# get go files to check against
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$' | grep -v 'vendor\/')
[ -z "$gofiles" ] && exit 0
package main
import (
"fmt"
)
type String string
func (f String) Dasherize() String {
package main
import (
"fmt"
"net/url"
)
func main() {
u, _ := url.Parse("http://foo.bar?a=b")