Skip to content

Instantly share code, notes, and snippets.

Avatar

Josip Delic delijati

  • Potsdam (Berlin)
View GitHub Profile
@delijati
delijati / structlog_render_level_in_uppercase.py
Last active Sep 14, 2020 — forked from mauler/structlog_render_level_in_uppercase.py
Renders log entry level in uppercase when using structlog library
View structlog_render_level_in_uppercase.py
import structlog
def _add_log_level_upper(logger, method_name, event_dict):
event_dict["level"] = method_name.upper()[0]
return event_dict
level_styles = structlog.dev.ConsoleRenderer.get_default_level_styles()
new_styles = {}
@delijati
delijati / ec2-fingerprint-key
Created May 29, 2020 — forked from jtriley/ec2-fingerprint-key
Simple Python script that computes both public and private RSA key fingerprints as used by Amazon EC2
View ec2-fingerprint-key
#!/usr/bin/env python
import hashlib
import optparse
import paramiko
from Crypto.PublicKey import RSA
def insert_char_every_n_chars(string, char='\n', every=64):
return char.join(
View ecs.py
from troposphere import \
AWSHelperFn, Base64, Cidr, Condition, Equals, GetAtt, Join, Not, Output, Parameter, Ref, \
Region, Select, Split, StackName, Sub, Tags, Template
from troposphere.autoscaling import \
AutoScalingGroup, LaunchTemplateSpecification, LifecycleHookSpecification
from troposphere.awslambda import \
Code, Function, Permission
from troposphere.ec2 import \
CreditSpecification, IamInstanceProfile, InternetGateway, LaunchTemplate, LaunchTemplateData, \
Route, RouteTable, SecurityGroup, SecurityGroupRule, Subnet, SubnetRouteTableAssociation, VPC, \
@delijati
delijati / cfn_run.sh
Created May 14, 2020 — forked from gcchaan/cfn_run.sh
troposphere runner
View cfn_run.sh
#!/bin/bash
# https://gist.github.com/gcchaan/ad8fd83a68467503ec3e6392ebbd519a
set -ef -o pipefail
function message(){
echo 🍣 "$1"
}
function help(){
View Dockerrun.aws.json.template
{
"AWSEBDockerrunVersion": "1",
"Authentication": {
"Bucket": "bucket_name",
"Key": "docker/dockercfg"
},
"Image": {
"Name": "company/<image>"
},
"Ports": [
@delijati
delijati / dump.py
Last active Apr 17, 2019
dump all models when load sqlalchemy
View dump.py
import os
import json
import hashlib
import datetime
from database import db
from sqlalchemy import event
def literal_sql(context):
@delijati
delijati / orm_example.js
Created Apr 5, 2019
Knex objection ORM
View orm_example.js
'use strict';
// $ npm install knex objection sqlite3
const {Model} = require('objection');
const knex = require('knex')({
client: 'sqlite3',
connection: {
filename: './db.sqlite'
},
View main.py
# air on higher value squares will try to flow to lower value squares
# a square can only hold a certain amount of air ( Depends on square value
# ). If square is full, air will not flow into it.
import sys
import pygame
import random
from noise import pnoise2
View spot_price.py
# python spot_price.py g2.2xlarge
import sys
import boto3
import datetime
def main(argv):
if len(argv) < 2:
print("No instance provided!")
sys.exit()
View yar_log_dump.sh
#!/bin/bash
set -x
LOCAL_DIR=/home/hadoop/yarn_logs
mkdir $LOCAL_DIR
for row in $( yarn application -appStates ALL -list | awk '/application_/{print $1 "," $2}' )
do
fields=($(echo $row | tr "," "\n"))
yarn logs -applicationId ${fields[0]} > $LOCAL_DIR/yarn_${fields[0]}_${fields[1]}.log