This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update(dl_url, force_update=False): | |
""" | |
Attempts to download the update url in order to find if an update is needed. | |
If an update is needed, the current script is backed up and the update is | |
saved in its place. | |
""" | |
import urllib | |
import re | |
from subprocess import call | |
def compare_versions(vA, vB): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <iostream> | |
#include "boost/program_options.hpp" | |
#include "boost/filesystem.hpp" | |
#include "boost/any.hpp" | |
namespace po = boost::program_options; | |
inline void PrintUsage(const boost::program_options::options_description desc) { | |
std::cout << "Usage: " << app_name << " [options]" << std::endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import logging.handlers | |
LOG_FILE = 'path/to/logfile' | |
LOG_SIZE = 1024*1024*200 | |
LOG_COUNT = 9 | |
log_file = LOG_FILE | |
dir_path = os.path.dirname(log_file) | |
if os.access(dir_path, os.W_OK): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Configure eth0 | |
# vi /etc/sysconfig/network-scripts/ifcfg-eth0 | |
DEVICE="eth0" | |
NM_CONTROLLED="yes" | |
ONBOOT=yes | |
HWADDR=A4:BA:DB:37:F1:04 | |
TYPE=Ethernet | |
BOOTPROTO=static | |
NAME="System eth0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sh import ErrorReturnCode, git | |
from cStringIO import StringIO | |
import tarfile | |
def git_get(git_repo, git_branch, git_path, destination_path=".", use_compression=True, verbose=False): | |
git_dir = os.path.dirname(git_path) | |
git_file = os.path.basename(git_path) | |
if git_dir.replace("/", "") == git_file: | |
git_file = '' | |
if git_dir.replace("/","").strip() == "": | |
git_loc = git_branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
import os | |
def output_to_pager(text): | |
try: | |
# args stolen fron git source, see `man less` | |
pager = subprocess.Popen(['less', '-F', '-R', '-S', '-X', '-K'], | |
stdin=subprocess.PIPE, | |
stdout=sys.stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import ConfigParser | |
import sys | |
def main(argv=None): | |
# Do argv default this way, as doing it in the functional | |
# declaration sets it at compile time. | |
if argv is None: | |
argv = sys.argv[1]: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def get_config_path(project_name=None, config_name=None): | |
''' | |
Gets the config location based on the XDG Base Directory Specification. | |
If no config is found, the home directory based path is returned. | |
''' | |
if not project_name: | |
project_name = os.path.basename(__file__).split('.')[0] | |
if not config_name: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
"http://whatismyip.akamai.com/", | |
"http://icanhazip.com", | |
"http://wtfismyip.com/text", | |
"http://whatsmyip.me/", | |
"http://api.ipify.org/", | |
"http://ip.catnapgames.com", | |
"http://ip.ryansanden.com", | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
# CREATE block and create them in separate commands _after_ all the INSERTs. | |
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
# The mysqldump file is traversed only once. | |
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
OlderNewer