Skip to content

Instantly share code, notes, and snippets.


Viktor Petersson vpetersson

Block or report user

Report or block vpetersson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
vpetersson /
Created Sep 8, 2013
Simple snippet for creating servers on CloudSigma via the python module.
import cloudsigma
name = 'SomeName'
drive = cloudsigma.resource.Drive()
server = cloudsigma.resource.Server()
gb_in_bytes = 1024 * 1024 ** 2
test_disk = {
View gist:6531944
# Partition the new disk as LVM
echo -e "n\np\n1\n\n\nt\n8e\nw" | sudo fdisk $NEWDEV
# Initiate the disk
sudo pvcreate $NEWDEV\1
import pytumblr
import requests
from pprint import pprint
from re import findall
from urlparse import urlparse
tumblr_blog = ''
wordpress_site = ''
source_file = '/Users/mvip/Desktop/pages.txt'
vpetersson / gist:4bb3a87f2af6998332d9
Created Oct 30, 2014
BitTorrent Sync sample config
View gist:4bb3a87f2af6998332d9
"device_name": "My Sync Device",
"listening_port" : 0, // 0 - randomize port
/* storage_path dir contains auxilliary app files if no storage_path field: .sync dir created in the directory
where binary is located. otherwise user-defined directory will be used */
// "storage_path" : "/home/user/.sync",
/* set location of pid file */
// "pid_file" : "/var/run/btsync/",
vpetersson / gist:5df345dbf41197c455f5
Last active Aug 29, 2015
Set up Wordpress with docker
View gist:5df345dbf41197c455f5

Start a MySQL Container

$ docker run -d \
    --name mysql \
    -e MYSQL_ROOT_PASSWORD=mysecretpassword \

Start a WordPress container

vpetersson / gist:3b791362ca5ab581709d
Created Feb 25, 2015
Concat strings in Bash with multiple strings.
View gist:3b791362ca5ab581709d
$ export FOO="One ""Two ""Three"
$ echo $FOO
One Two Three
vpetersson / gist:26472c0a78e78234bad0
Last active Aug 29, 2015
CloudSigma Python util script
View gist:26472c0a78e78234bad0
import requests
import json
import sys
import cloudsigma
import base64
import random
import string
import re
from urlparse import urlparse
from datetime import date
vpetersson / gist:6b1da35edbe3f7dc7ca4
Last active Aug 12, 2017
Example on how to create a 'Secret URL' for Nagios in Apache.
View gist:6b1da35edbe3f7dc7ca4
# Example from
ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
Alias /nagios3/stylesheets /etc/nagios3/stylesheets
Alias /nagios3 /usr/share/nagios3/htdocs
<Location /abc123>
# Hard code credentials
AuthBasicFake nagiosadmin nagiosadmin
vpetersson / gist:f20efe6194460cc28d49
Last active Oct 8, 2019
Parse and dump a sitemap (using Python)
View gist:f20efe6194460cc28d49
#! /usr/bin/env python
# -*- coding: utf-8 -*-
Inspired by Craig Addyman (
Enhanced by Viktor Petersson ( / @vpetersson
from bs4 import BeautifulSoup
import requests
vpetersson / gist:611a62970d0d558bc94e
Created May 21, 2015
APT issue with
View gist:611a62970d0d558bc94e
$ sudo apt-get update
Ign trusty InRelease
Ign trusty-updates InRelease
Hit trusty Release.gpg
Hit trusty-updates Release.gpg
Hit trusty Release
Hit trusty-updates Release
Hit trusty/main Sources
Hit trusty/universe Sources
Hit trusty/main amd64 Packages
You can’t perform that action at this time.