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 crypt import crypt | |
from fabric.api import * | |
from fabric.contrib.files import append, uncomment | |
env.user = 'root' | |
env.use_ssh_config = True | |
def create_user(name, password): | |
with hide('stdout'): | |
run('useradd -m %s' % 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
class Restartable(object): | |
def __init__(self, iterable): | |
self._iterable = iterable | |
self._cache = None | |
def __iter__(self): | |
if not self._cache: | |
if iter(self._iterable) is iter(self._iterable): | |
self._cache = list(self._iterable) | |
else: |
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 re | |
import os | |
import fnmatch | |
from collections import defaultdict | |
def find_files(directory, pattern): | |
for root, dirs, files in os.walk(directory): | |
for basename in files: | |
if fnmatch.fnmatch(basename, pattern): | |
filename = os.path.join(root, basename) |
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
get_help_section_text <- function (func, section) { | |
funcq <- substitute(func) | |
if (!is.character(func)) { | |
func <- deparse(funcq) | |
} | |
Rd <- utils:::.getHelpFile(help(func)) | |
data <- tools:::.Rd_get_section(Rd, section) | |
result <- character() | |
if (length(data)) { | |
result <- tools:::.Rd_get_text(data) |
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
#!/usr/bin/env bash | |
if [ -z $2 ]; then | |
echo "Create a bootable USB stick from an ISO image." | |
echo | |
echo "Usage: $0 <iso> <disk>" | |
echo | |
echo "Target disks:" | |
diskutil list | grep '^/dev' | grep 'external' | sed -e 's/disk/rdisk/' -e 's/:$//' -e 's/^/ /' | |
exit 1 | |
fi |
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
# creates localized version of a string using Google Translate | |
import re | |
import json | |
import requests | |
from urllib.parse import quote_plus | |
def translate(text, source, target): | |
url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl={source}&tl={target}&dt=t&q={text}' | |
r = requests.get(url.format(source=source, target=target, text=text)) |
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/bash | |
# This script should set up a bare Ubuntu box (like the one in DigitalOcean) | |
# with everything needed to run a Docker-based environment. | |
# | |
# To set up a fresh box, login as root and run: | |
# | |
# $ curl https://gist.githubusercontent.com/elifiner/f1e19b49bf65369b82bc9d6734abc16d/raw | sh - | |
USER=eli |
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/bash | |
# This script will set up a non-root user on an empty Ubuntu box. | |
# | |
# Login as root and run: | |
# | |
# $ curl https://gist.githubusercontent.com/elifiner/1a5ed9cb06db1c0fc59a7426e4adc1b1/raw | sh - | |
USER=guru | |
adduser --disabled-password --gecos "" $USER |
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 | |
# This script will set up a DNS server on your OSX that will redirect all programs.test, | |
# bookingguru.test and rgconnect.test to the correct local IP addresses. | |
# | |
# Run it using: | |
# | |
# $ curl -s https://gist.githubusercontent.com/elifiner/a4bbe415eff43df9fa970977d1a7d278/raw?$RANDOM | sh - | |
TLD=test |
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
<?php | |
/** | |
* A simple wrapper around PDO for building quick DB accessing scripts. | |
* Was built during the Jun 19th, 2017 data recovery fiasco at RetreatGuru. | |
*/ | |
class Database { | |
public $db; |
OlderNewer