Skip to content

Instantly share code, notes, and snippets.

View adw0rd's full-sized avatar
:octocat:
I may be slow to respond.

Mikhail Andreev adw0rd

:octocat:
I may be slow to respond.
View GitHub Profile
@adw0rd
adw0rd / bashrc
Last active May 2, 2022 16:32
Bashrc tips and tricks
# make bash autocomplete with up arrow
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
alias cls="find . -name '*.pyc' -delete -print ; find -name '*~' -delete -print"
# git hightlight cmd line (and show branch name)
# export PS1='\u@\h\w$(__git_ps1 " @%s")$ '
export PS1='\u@\h\w$(__git_ps1 " git:(%s)")/$ '
@adw0rd
adw0rd / ftp-airnet-kinopoisk-helper.js
Created February 29, 2012 03:53
Ftp-Airnet-Kinopoisk helper (greasemonkey)
// ==UserScript==
// @name Ftp-Airnet-Kinopoisk helper
// @namespace http://airnet.lan/
// @version 0.1
// @description airnet helper for kinopoisk
// @include ftp://ftp.airnet.lan/Video/*
// ==/UserScript==
var list = document.getElementsByTagName('table');
var el = list[0].getElementsByTagName('tr');
@adw0rd
adw0rd / .gitconfig
Created February 29, 2012 03:57
My git config
[user]
name = <SOME USERNAME>
email = <SOME EMAIL>
[github]
user = <SOME USERNAME>
token = <SOME TOKEN>
[core]
whitespace = trailing-space, space-before-tab, cr-at-eol
@adw0rd
adw0rd / myisam2innodb.py
Created February 29, 2012 04:14
Converter from MyISAM to InnoDB
from django.db import connection
exclude_tables = ("example", )
c = connection.cursor()
c.execute("SHOW TABLE STATUS WHERE ENGINE='MyISAM'")
for line in c.fetchall():
table_name = line[0]
if table_name in exclude_tables:
@adw0rd
adw0rd / supervisord
Created October 1, 2012 05:43
supervisord init-script
#!/bin/sh
# PROVIDE: supervisord
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf.local or /etc/rc.conf
# to enable supervisord:
#
# supervisord_enable="YES"
#!/usr/bin/env python
#
# Copyright 2012 Patrick Hetu <patrick.hetu@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@adw0rd
adw0rd / sendsms.py
Last active December 10, 2015 16:48
Specially designed for Nagios, but can be used universally. For convenience can make symlink to ``/usr/local/bin/sendsms``.
#!/usr/bin/env python
"""
Simple sms-sender via LittleSMS
---------------------------------
You must specify your ``USER_EMAIL`` and ``USER_APIKEY`` below.
Examples::
$ sendsms.py --recipients=79117654321,79317654321 --message="Some message"
function(url, params) {
var parser = document.createElement('a');
parser.href = url;
var chunks = [];
for(var param in params) {
chunks.push(encodeURIComponent(param) + "=" + encodeURIComponent(params[param]));
}
parser.search = (parser.search ? parser.search + '&' : '?') + chunks.join("&");
return parser.href;
}
"""
Time-based One-time Password Algorithm
Based on the pyotp: https://github.com/nathforge/pyotp
"""
import base64
import hashlib
import hmac
import datetime
import random
from totp_auth import TotpAuth
def main(secret=None):
if not secret:
# WHEN SIGN UP
ta = TotpAuth()
else:
# WHEN SIGN IN
ta = TotpAuth(secret)