Skip to content

Instantly share code, notes, and snippets.

@marvell
marvell / wg_easy_setup.sh
Created November 25, 2022 08:58
wg-easy setup
#!/bin/bash
curl -fsSL https://get.docker.com | sh
docker run -d \
--name=wg-easy \
-e WG_HOST=$(curl -sL4 https://ifconfig.io) \
-e WG_PERSISTENT_KEEPALIVE=25 \
-e WG_DEFAULT_ADDRESS=192.168.210.x \
-v /etc/wg-easy:/etc/wireguard \
@marvell
marvell / gen.sh
Created August 18, 2021 14:44
Generate KUBECONFIG for Yandex.Cloud Managed Kubernetes. https://cloud.yandex.ru/docs/managed-kubernetes/operations/create-static-conf
#!/bin/bash
FOLDER_ID=<FOLDER_ID>
CLUSTER_ID=<CLUSTER_ID>
CLUSTER_NAME=<CLUSTER_NAME>
DIR=./$CLUSTER_NAME
set -xe
db.NASA_MCDAODHD.aggregate([
{ "$group": {
"_id": { "uid": "$loc", "sid": "$dt" },
"dups": { "$push": "$_id" },
"count": { "$sum": 1 }
}},
{ "$match": { "count": { "$gt": 1 } }}
]).forEach(function(doc) {
doc.dups.shift();
db.NASA_MCDAODHD.remove({ _id: { "$in": doc.dups } });
@marvell
marvell / Dockerfile
Created November 30, 2015 09:32
Dockerfile tips
# Отключаем любые promt
ENV DEBIAN_FRONTEND noninteractive
# Удаляем мусор из имиджа
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Использование glibc для alpine
FROM alpine:3.2
RUN apk --update add curl ca-certificates && \
curl -Ls https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk > /tmp/glibc-2.21-r2.apk && \
@marvell
marvell / tile_hash.go
Created August 4, 2015 09:33
Get tile hash by ZXY
func getTileHash(z, x, y int) int64 {
positions := make(map[int][2]int)
for currentZoom := 1; currentZoom <= z; currentZoom++ {
tileSize := int(math.Pow(2, float64(z-currentZoom)))
centerX, centerY := tileSize-1, tileSize-1
if currentZoom > 1 {
n := int(math.Pow(2, float64(currentZoom-1)))
centerX += positions[currentZoom-1][0] * n
@marvell
marvell / gist:01d053ebd2090c8b056a
Created June 28, 2015 13:00
enable ability to select text in QuickLook
defaults write com.apple.finder QLEnableTextSelection -bool true
killall Finder
docker run --name=redis -d redis
docker run --name=postgres -e POSTGRES_PASSWORD=secret -d postgres
docker exec postgres createdb -U postgres -E utf-8 sentry
docker run --rm -it --link=postgres:postgres --link=redis:redis -v $(pwd):/home/user/.sentry sentry sentry upgrade
docker run --name=sentry --env="VIRTUAL_HOST=sentry.ndr.su" --link=postgres:postgres --link=redis:redis -v $(pwd):/home/user/.sentry -d sentry
docker run --name=sentry-celery --link=postgres:postgres --link=redis:redis -v $(pwd):/home/user/.sentry -d sentry sentry celery worker -B
@marvell
marvell / remove_apt_cache
Created May 18, 2015 15:29
Remove APT cache (for Dockerfile)
apt-get clean autoclean
apt-get autoremove --yes
rm -rf /var/lib/{apt,dpkg,cache,log}/
#!/usr/bin/env bash
set -x
pid=0
# SIGUSR1-handler
my_handler() {
echo "my_handler"
}
@marvell
marvell / tunneling_over_ssh
Created April 30, 2015 15:45
Проброс портов с удаленной машинки на локальную через SSH
$ ssh -f -N -L 9906:127.0.0.1:3306 [email protected]