Skip to content

Instantly share code, notes, and snippets.

View gist:c6f2b3509b65aed0371dd7d894039444
Delivered-To: temotor@gmail.com
Received: by 2002:a5d:488d:0:0:0:0:0 with SMTP id g13csp4151818wrq;
Mon, 27 Jan 2020 09:16:22 -0800 (PST)
X-Google-Smtp-Source: APXvYqxAIuuMNWRi8bdVIKq81O0ZWPCWj21zuE9mBvvy8izndkifgeLExOGjic9x0XoYxzajyxJx
X-Received: by 2002:a17:906:1903:: with SMTP id a3mr14586374eje.102.1580145382718;
Mon, 27 Jan 2020 09:16:22 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1580145382; cv=none;
d=google.com; s=arc-20160816;
b=OSbK3M16bsDG8WFa+i2E3bpgjsdgIS8uS5N4BXMlcEzm6Ebi8hdPMhs/TPdkWHpnvw
qRe/but6EXVjekw7zvNjxejBg1+wcLyZkMSQRBH5Rbb9YvUF6WEmAlfC+EMI4zTtBtEq
@temoto
temoto / guide.md
Created Aug 2, 2019
Atom + Go with modules config for 2019-08
View guide.md

How to setup Atom for Go development with 1.11+ modules support

For projects outside GOPATH.

  • go get github.com/saibing/bingo why: https://github.com/ckaznocha/ide-go/issues/42 Run which bingo and have full path in clipboard.
  • (Atom) install package go-plus for format/build/test-on-save It's great, but go-plus autocomplete doesn't work with modules. Settings, packages, go-plus, Autocomplete, set Scope blacklist *
  • (Atom) install package ide-go
@temoto
temoto / mqtt-color-temp-control.py
Last active Oct 22, 2018
Automate lights color temperature via MQTT enabled dimmer (like Sonoff). Temporary location, will be moved to full repository.
View mqtt-color-temp-control.py
#!/usr/bin/env python2
import os, sys, time
import astral, datetime
import paho.mqtt.client
# EDIT HERE TO CONFIGURE + run with env `mqtt_broker=addr:port mqtt_topic=cmnd/house/ct script.py`
config = 'midnight scale_down sunrise 0% noon scale_up sunset 100%'
lat, lng = (58.0, 56.316) # Perm
@temoto
temoto / parse.y.patch
Last active Dec 6, 2017
sqlite fail build with ENABLE_UPDATE_DELETE_LIMIT flag when sqlite3.c was configured without it, e.g. amalgamation from sqlite website
View parse.y.patch
--- a/src/parse.y 2017-12-06 05:26:36.000000000 +0300
+++ b/src/parse.y 2017-12-06 05:22:53.000000000 +0300
@@ -758,6 +758,13 @@
}
%endif
%ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
+%include {
+#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
+ #error To build SQLite with -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT you have to run ./configure with --enable-update-limit flag. \
+Most likely you are building amalgamation from http://www.sqlite.org/download.html which is not compatible with this feature. \
View keybase.md

Keybase proof

I hereby claim:

  • I am temoto on github.
  • I am temoto (https://keybase.io/temoto) on keybase.
  • I have a public key whose fingerprint is 1A40 5559 7839 D277 88D0 0647 F6C3 E55C 75EA CF08

To claim this, I am signing this object:

View phoneword.py
#!/usr/bin/env python3
import argparse
import bisect
import itertools
import sys
# % cat wordlist
# a b c
# pig bird
# rig sig
@temoto
temoto / mysql-loop
Last active Jul 31, 2016
Tool for DBA / Operations. Repeats command against chunks of large MySQL table, delay between runs adapts to minimise load (judged by mean execution time of N last runs).
View mysql-loop
#!/usr/bin/env python3
import argparse
import itertools
import subprocess
import sys
import time
pk_alphabet_level1 = '0123456789abcdefghijklmnopqrstuvwxyz'.replace('.', '')
pk_alphabet_level2 = '0.......8.......g.......o.....u.....'.replace('.', '')
@temoto
temoto / aws-iam-ssh-keys.py
Last active Mar 30, 2016
Sync (overwrite) IAM public SSH keys to my servers at regular intervals. Update keys immediately on change is possible but make it yourself. CloudTrail-CloudWatch-{write this poll service}.
View aws-iam-ssh-keys.py
#!/usr/bin/env python3
import botocore.session
import distutils.spawn
import codecs
import grp, pwd
import os
import shutil
import subprocess
import sys
from datetime import datetime
@temoto
temoto / mysql-convert-myisam-to-innodb.sh
Last active Mar 15, 2016
MySQL administration: convert MyISAM tables to InnoDB
View mysql-convert-myisam-to-innodb.sh
#!/bin/bash
sql_list="select table_schema, table_name from information_schema.tables where lower(engine) = 'myisam' and table_schema not in ('mysql', 'information_schema', 'performance_schema') order by data_length;"
mysql --batch --silent -e "$sql_list" |while read -r d t; do
printf "\n---\n$d.$t "
mysql --batch --silent -e "select (data_length+index_length)/1e6 from information_schema.tables where table_schema='$d' and table_name='$t';"
time mysql --batch --silent -e "alter table $d.$t engine='innodb';"
done
@temoto
temoto / megafon-account.bash
Last active Mar 3, 2016
Экспорт балансов Мегафона. Работает с TLSv1 уральского региона (информация актуальна 2016-03-03).
View megafon-account.bash
#!/bin/bash
# https://gist.github.com/temoto/efc4cf36fe388b41715b
set -e
umask 0077
cookie_path='/tmp/megafon-jar'
output_path=~/megafon-account.csv
username='EDIT'
password='EDIT'
url_base='https://EDIT'
url_path_init='/sc_cp_apps/login'