Skip to content

Instantly share code, notes, and snippets.

View vaniakov's full-sized avatar
🇺🇦

Ivan Kovalkovskyi vaniakov

🇺🇦
  • Lohika
  • Lviv, Ukraine
View GitHub Profile
@embano1
embano1 / README.MD
Created September 23, 2019 14:54
Dockerfile for Go modules and built cache efficiency

Also works across git branches if you keep the intermediate build images around, e.g. those <none> images in the docker images output.

FROM golang:1.12 AS builder

# enable Go modules support
ENV GO111MODULE=on

WORKDIR $GOPATH/src/github.com/myrepo/myapp
@hakib
hakib / custom_django_checks.py
Last active July 1, 2024 09:20
Custom django checks using Django check framework, inspect and ast.
"""
Custom django checks.
H001: Field has no verbose name.
H002: Verbose name should use gettext.
H003: Words in verbose name must be all upper case or all lower case.
H004: Help text should use gettext.
H005: Model must define class Meta.
H006: Model has no verbose name.
H007: Model has no verbose name plural.
@simonw
simonw / combined_recent.py
Last active January 30, 2019 18:55
combined_recent() function for union across querysets returning most recent objects. See https://simonwillison.net/2018/Mar/25/combined-recent-additions/
from django.db.models import Value, CharField
def combined_recent(limit, **kwargs):
datetime_field = kwargs.pop('datetime_field', 'created')
querysets = []
for key, queryset in kwargs.items():
querysets.append(
queryset.annotate(
recent_changes_type=Value(
@athityakumar
athityakumar / powerlevel9k.config
Created July 6, 2017 18:38
Powerlevel9k oh-my-zsh theme configuration for screenshots used in https://github.com/athityakumar/colorls
export ZSH=$HOME/.oh-my-zsh
export DEFAULT_USER='athityakumar'
TERM=xterm-256color
ZSH_THEME="powerlevel9k/powerlevel9k"
POWERLEVEL9K_MODE='awesome-fontconfig'
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
@svcavallar
svcavallar / rabbitmq_reconnect.go
Created September 20, 2016 22:23
Golang example to reconnect to RabbitMQ on a connection closed event
package main
import (
"flag"
"github.com/streadway/amqp"
"log"
"time"
)
var amqpUri = flag.String("r", "amqp://guest:guest@127.0.0.1/", "RabbitMQ URI")
import sys
def get_size(obj, seen=None):
"""Recursively finds size of objects"""
size = sys.getsizeof(obj)
if seen is None:
seen = set()
obj_id = id(obj)
if obj_id in seen:
return 0
@sosedoff
sosedoff / 1_simple.go
Created July 16, 2016 18:45
Golang Custom Struct Tags Example
package main
import (
"fmt"
"reflect"
)
// Name of the struct tag used in examples
const tagName = "validate"
@a-h
a-h / setup.tf
Last active December 8, 2023 14:56
Terraform - Creating an Instance with an S3 Bucket Policy
# Create an IAM role for the Web Servers.
resource "aws_iam_role" "web_iam_role" {
name = "web_iam_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
@ivan3bx
ivan3bx / custom_marshalling.go
Created May 6, 2016 18:20
Using type alias in custom JSON marshalling
package main
import (
"encoding/json"
"fmt"
"os"
)
type Foo struct {
One string