Skip to content

Instantly share code, notes, and snippets.

View rpromyshlennikov's full-sized avatar

Rodion Promyshlennikov rpromyshlennikov

View GitHub Profile
@rpromyshlennikov
rpromyshlennikov / table_bootstrap_bug.html
Created January 16, 2016 07:59
Bug in bootstrap table
<table id="shop_sales_table"
class="table table-condensed table-striped table-hover"
data-search="true"
data-toolbar="#custom-toolbar">
<thead>
<tr>
<th rowspan="2" data-field="id_surr">#</th>
<th rowspan="2" data-field="id">Raw ID</th>
<th rowspan="2" data-field="time_sold" data-align="left">Время продажи</th>
<th colspan="3" data-field="products" data-align="left">Товары</th>
@rpromyshlennikov
rpromyshlennikov / semi_ext_net.sh
Created January 31, 2017 07:42
Semi-external network creation
#/bin/bash
source openrc
neutron net-create ext-net --router:external True
neutron subnet-create ext-net --name ext-subnet --allocation-pool start=171.100.1.3,end=171.100.1.100 --disable-dhcp --gateway 171.100.1.1 171.100.1.0/24
@rpromyshlennikov
rpromyshlennikov / cirros386_image_create.sh
Last active January 31, 2017 07:51
Cirros images downloading and creation
#/bin/sh
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-i386-disk.img
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
source openrc
glance image-create --name cirros386 --visibility public --disk-format qcow2 --container-format bare --progress < /root/cirros-0.3.4-i386-disk.img
glance image-create --name cirros64 --visibility public --disk-format qcow2 --container-format bare --progress < /root/cirros-0.3.4-x86_64-disk.img
@rpromyshlennikov
rpromyshlennikov / cirros_instance_with_int_net_create.sh
Last active January 31, 2017 07:52
Create private network, nanoflavor and cirros instance
#/bin/sh
source openrc
nova flavor-create m1.nano 42 64 0 1
neutron net-create internal001; neutron subnet-create --name internal001 internal001 192.168.200.0/24
nova boot --flavor m1.nano --image cirros64 --nic net-name=internal001 cirros_server
@rpromyshlennikov
rpromyshlennikov / auth_keys
Created January 31, 2017 10:02
openssh keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC3dCFNCYVxHQQD+/X1JJ9auAzpj15AkEl6yO4lJ1XL43ljxJbzWXXl3RN9vAjiBE1tvxEfuPEIxF7kO2sc1xPKtkw40RIwXrDIGfjlVCaBLtnxCPnCQX349UMSJl/AXpkHqKGVeAW+AO4zbeI8XnS9aDNMuX6ncgrLRMxWCxETL3J/IIE1LZ5v0QvyQBHuJc5jbyODVb4onff296SbjzYm96elJZcRFo4FzFaIcKtis+Sm4+6OAGCNDIXxfB9e5TK579x+L+ci/W1k83Fcz6NpQU/OM1R1CZVMap/Xet424aRMFPmA8sTF4hdYvWd6adBihco2isaW51b1Gkc+K9N9wELiEBMpdKQtqkPOvm98UhoRk7Wp+8+zSamj1uEs/7m6VCGFebq8V3xqTexWH2dCUznxZ5+KS6WLBh+3f4P6wG8VuWfgFjIUf7jjYKjidBXfSXFDxRkhf/LV8V0jLv+Ma1mjKBUX+rk7IFxm0X/PkjqNhVFlg3rH4Wre0+9WdsTCyzWS0HEaTxIKdPtwwULLEiwClO1LLebdlVjx9yhen0czXxMAHONbZeTvxN8ULfei+b7c07oYm16T8T9JAdiWn5nGxiT8TAUrCPBJMpbE4xQJLztYhAbMpfhFSdkKfTotFxTK9AKpTg4TZFY0NYOktFtV2R9ZnzP7hHZDSIg2Bw== [email protected]
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAp8ptUdiYi50N4DlKnv4HMmNqTAE/Q5V16flVecA3nIhf5eDyb0189pVxz0UA8KUh77wFS4aDhelFSoAdrkBVSLBFE+iX5D9oc9NICgclEjs8IzVwajRJXDloKwStaNYDgh5AHXl9ksSOa+MhHk4xtNYCFvCJIubwjEPWK9wMFwhhC7loQt96xybzCJehMmFRt8hq8TVwHrUwsHtzHA+o7rL8jip2EXow9m/VsnfQ
@rpromyshlennikov
rpromyshlennikov / switch-display-thinkpad.sh
Created March 13, 2017 21:33
xrandr (thinkpad monitor switcher) bound to XF86Display button
#!/bin/sh
#For identifying our monitors use xrandr tool and view output
LVDS=LVDS1 # could be another one like: LVDS, LVDS-1, etc
HDMI=HDMI1 # could be another one like: HDMI, HDMI-1, etc
EXTRA="--right-of $LVDS" # addtional info while dual display
# Lets check both LVDS and HDMI state from the string "$display connected "
xrandr | grep -q "$LVDS connected " && LVDS_IS_CON=1 || LVDS_IS_CON=0
xrandr | grep -q "$HDMI connected " && HDMI_IS_CON=1 || HDMI_IS_CON=0
@rpromyshlennikov
rpromyshlennikov / load.sh
Last active April 25, 2017 09:45
Make high load of system with provided quantity of processes
#!/usr/bin/env bash
count="${1}"
if [[ -z "${1}" ]]; then
count=20
fi
for ((process=1; process<="${count}"; process++)); do
(bash -c "while [ 1 ] ; do echo $((13**99)) 1>/dev/null 2>&1; done" &);
done
@rpromyshlennikov
rpromyshlennikov / parse_pings.py
Last active July 11, 2017 13:14
Network interruption reporter (based on simple ping cmd output analyzis)
import datetime as dt
import re
import subprocess
import sys
HOST = "ya.ru"
FILE_NAME_TEMPLATE = "ping_report_{}.txt"
def get_dt_from_line(line):
@rpromyshlennikov
rpromyshlennikov / atoi.py
Created September 15, 2017 16:32
Convert hex, oct stings to integer, because there is no base for int() for Python1.5.2
HEX_CHARS = {
'0': 0,
'1': 1,
'2': 2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
'8': 8,
@rpromyshlennikov
rpromyshlennikov / go_struct_from_tables.sql
Last active September 25, 2019 11:23
Generate Golang struct (model) from Postgres tables
WITH models AS (
WITH data AS (
SELECT
replace(initcap(table_name::text), '_', '') table_name,
replace(initcap(column_name::text), '_', '') column_name,
CASE data_type
WHEN 'timestamp without time zone' THEN 'time.Time'
WHEN 'timestamp with time zone' THEN 'time.Time'
WHEN 'boolean' THEN 'bool'
-- add your own type converters as needed or it will default to 'string'