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
sudo su
apt install -y python-pip
git clone https://github.com/google/google-api-python-client
cd google-api-python-client
python setup.py install install_egg_info
pip install gdrivefs
cd /sbin
ln -s /usr/local/bin/gdfs mount.gdfs
echo "/root/.gdfs.creds /mnt/gdrivefs gdfs allow_other,big_writes 0 0" >> /etc/fstab
gdfstool auth -u
# https://www.erlang-solutions.com/downloads/download-erlang-otp
# wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
# sudo dpkg -i erlang-solutions_1.0_all.deb
deb http://packages.erlang-solutions.com/ubuntu trusty contrib
deb http://packages.erlang-solutions.com/ubuntu saucy contrib
deb http://packages.erlang-solutions.com/ubuntu precise contrib
wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
from totp_auth import TotpAuth
def main(secret=None):
if not secret:
# WHEN SIGN UP
ta = TotpAuth()
else:
# WHEN SIGN IN
ta = TotpAuth(secret)
"""
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
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;
}
@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"
#!/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 / 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"
@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 / .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