Skip to content

Instantly share code, notes, and snippets.

Evgeny Zislis kesor

Block or report user

Report or block kesor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kesor
kesor / cloudtrail-template-elasticsearch.json
Last active May 23, 2019
An ElasticSearch Index template for CloudTrail events
View cloudtrail-template-elasticsearch.json
PUT _template/cloudtrail
{
"index_patterns": ["cloudtrail-*"],
"settings": {
"number_of_shards": 1,
"mapping": {
"total_fields": {
"limit": 10000
}
}
@kesor
kesor / sql_mongodb_dump_middleware.py
Created Jan 10, 2012
Django MongoDB + SQL dump middleware
View sql_mongodb_dump_middleware.py
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
from django.db import connection
from pymongo.connection import Connection
from time import time
import struct
import bson
from bson.errors import InvalidBSON
class SqldumpMiddleware(object):
@kesor
kesor / an upstart unicorn.conf
Last active Feb 7, 2019
Unicorn that receives USR2 signal on upstart's "stop unicorn", but also allows upstart to respawn it when for some reason it crashed on its own.
View an upstart unicorn.conf
# unicorn
description "unicorn ruby app server"
start on (local-filesystems and net-device-up IFACE=lo and runlevel [2345])
stop on runlevel [!2345]
env WORKDIR=/data
env PIDFILE=/data/tmp/pids/unicorn.pid
env CFGFILE=/data/config/unicorn.rb
@kesor
kesor / mysql_rotate_large_table.sql
Last active Jan 24, 2019
Rotate huge tables to old_tablename without affecting continued writes to these tables and keeping existing indexes and auto_increment counters.
View mysql_rotate_large_table.sql
DROP PROCEDURE IF EXISTS rotateAudit;
delimiter ;;
CREATE PROCEDURE rotateAudit(
pv_database VARCHAR(64),
pv_table VARCHAR(64)
)
BEGIN
SET @createDbStatement := CONCAT('CREATE DATABASE IF NOT EXISTS archive_',pv_database);
SET @createStatement := CONCAT('CREATE TABLE ',pv_database,'.new_',pv_table,' LIKE ',pv_database,'.',pv_table);
SET @insertStatement := CONCAT('INSERT INTO ',pv_database,'.new_',pv_table,' SELECT * FROM ',pv_database,'.',pv_table,' ORDER BY id DESC LIMIT 50000');
@kesor
kesor / docker_workshop_microservices_cheat_sheet.md
Last active Jan 24, 2019
docker workshop cheat sheet #2 - microservices
View docker_workshop_microservices_cheat_sheet.md
View bash-container.txt
root@89de118f2aa3:~# ps -ef ; date ; nohup ./zombie & ; sleep 2 ; ps -ef ; sleep 65 ; date ; ps -ef
bash: syntax error near unexpected token `;'
root@89de118f2aa3:~# ps -ef ; date ; (nohup ./zombie &) ; sleep 2 ; ps -ef ; sleep 65 ; date ; ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 16:41 ? 00:00:00 /bin/bash
root 364 1 0 16:47 ? 00:00:00 ps -ef
Wed May 20 16:47:37 UTC 2015
nohup: appending output to 'nohup.out'
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 16:41 ? 00:00:00 /bin/bash
View convert_yaml_to_json.py
#!/usr/bin/env python
import sys
import yaml
import json
with open(sys.argv[1], 'r') as fd_r:
with open(sys.argv[2], 'w') as fd_w:
json.dump(yaml.load(fd_r), fd_w)
@kesor
kesor / nginx-passwd.sh
Created May 21, 2017
nginx passwd generate
View nginx-passwd.sh
#!/bin/sh
USERNAME=kopter
PASSWORD=$(openssl rand -base64 12)
SALT=$(openssl rand -base64 3)
SHA1=$(printf "$PASSWORD$SALT" | openssl dgst -binary -sha1 | xxd -ps | sed 's#$#'"`echo -n $SALT | xxd -ps`"'#' | xxd -r -ps | base64)
HEADER=$(printf "$USERNAME:$PASSWORD" | base64)
printf "user: $USERNAME | password: $PASSWORD | %s:{SSHA}%s | Authorization: Basic $HEADER\n" $USERNAME $SHA1
View ecs-autoscaling-lambda.py
import os
import boto3
import datetime
import dateutil
DEFAULT_MAX_MEM = 3000
LOW_CLUSTER_CPU_TH = 20
HIGH_CLUSTER_CPU_TH = 65
CONTAINERS_MAX_MEM = {
'cluster1': 1200,
View test-peer-discovery.go
package main
import (
"fmt"
"os"
"strings"
"time"
)
func printFatal(e error) {
You can’t perform that action at this time.