Skip to content

Instantly share code, notes, and snippets.

@IvanBayan
IvanBayan / local_db_test.py
Created January 14, 2022 09:07 — forked from macloo/local_db_test.py
Test your MySQL database connection for Flask-SQLAlchemy
#!/Users/username/Documents/python/projectname/env/bin/python
# change username and projectname above to match yours - the path must match the path in YOUR virtualenv
"""
edit line 1 to match what YOU get when you are in YOUR virtualenv and type:
which python
# NO SPACES in first 3 chars in line 1: #!/
# make sure env is activated!
#!/usr/bin/env python3
# Requires python3 and pexpect_serial
# Tha script changes root password to toor1984 and enables dropbear
# Should work with dgnwg05lm (lumi.gateway.mieu01)
import sys
import serial
import argparse
from pexpect_serial import SerialSpawn
parser = argparse.ArgumentParser()
@IvanBayan
IvanBayan / timatic.py
Created November 19, 2019 09:00 — forked from hezhao/timatic.py
IATA Timatic API
# API
GULF_AIR = 'https://www.timaticweb.com/cgi-bin/tim_website_client.cgi?SpecData=1&VISA=&page=visa&PASSTYPES=PASS&NA=CN&AR=00&DE=US&user=STAR&subuser=STARB2C'
STAR_ALLIANCE = 'https://www.timaticweb.com/cgi-bin/tim_website_client.cgi?SpecData=1&VISA=&page=visa&PASSTYPES=PASS&NA=CN&AR=00&DE=US&user=GF&subuser=GFB2C'
KLM = 'https://www.timaticweb.com/cgi-bin/tim_website_client.cgi?SpecData=1&HEALTH=1&VISA=1&NA=AT&EM=AT&DE=AU&PASSTYPES=PASS&user=KLMB2C&subuser=KLMB2C'
# Web
AIR_BIRLIN = 'http://www.timaticweb.com/cgi-bin/login_website.cgi?user=MALLORCA&subuser=ABCUST&password=SHUTTLE'
EMIRATES = 'http://www.emirates.com/english/plan_book/essential_information/visa_passport_information/find_visa_requirements/visa_passport_information_results.aspx?NC=AR&NV=Argentina&DC=AT&DV=Austria&h=79fb1336bcc87035c550b97e3825699d8667b952'
@IvanBayan
IvanBayan / lineinfile_delegation.yml
Created October 31, 2019 09:28
An example how to avoid race condition with lineinfile delegated to one host
---
- hosts: all
gather_facts: no
tasks:
- name: Create a virtual machine on given ESXi hostname
vmware_guest:
hostname: "{{ vcenter_address }}"
username: "{{ domain_user }}"
password: "{{ domain_pass }}"
@IvanBayan
IvanBayan / flac2mp3.sh
Last active March 6, 2020 08:41
Split flac and encode it to mp3/ogg
#!/bin/bash -x
# Requered tools: cuetools, shntool, id3v2, vorbis-tools, lame
#
LAMEOPTS="-b 320 --quiet"
OGGOPTS="-b 320 --quiet"
usage () {
echo Usage: "$(basename $0)" "-f /path/to.flac -s /path/to.cue -e mp3|ogg"
@IvanBayan
IvanBayan / dir_cleanup.py
Created October 3, 2018 06:57
Cleanup dir. Delete all files with same hash or delete all files with same hash which matched to regexp.
import hashlib
import os
import argparse
import re
def make_hash(filename):
with open(filename, 'rb') as afile:
hasher = hashlib.md5()
buf = afile.read(6553600)
while len(buf) > 0:
@IvanBayan
IvanBayan / git.migrate
Created September 28, 2016 13:16 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.