Skip to content

Instantly share code, notes, and snippets.

@dwoz
dwoz / Debian Wheezy LXC How To
Last active June 25, 2018 19:21
An lxc container creation script that works on a Debain Wheezy host and created a Debian Wheezy guest. Put this file into /usr/share/lxc/templates/ and the name should remain 'lxc-create-wheezy'. Run with lxc-create -n <container name> -t debian-wheezy
== Prepare Debian Wheezy for LXC ==
Install lxc and some utils.
apt-get install lxc bridge-utils libvirt-bin debootstrap
Add a cgroup filesystem that will be mounted at boot. Edit /etc/fstab and add:
cgroup /cgroup cgroup defaults 0 0
@dwoz
dwoz / colors.sh
Created September 16, 2013 04:18
Output ascii colors
#!/bin/bash
#
# Modified from here:
# http://misc.flogisoft.com/bash/tip_colors_and_formatting
#
color16()
{
#Foreground
for clfg in {30..37} {90..97} 39 ; do
@dwoz
dwoz / gist:2a89f1c9b9f5159b2a15
Last active August 29, 2015 14:14
Dump github issues to csv
#!/usr/bin/env python
import requests
import json
from requests.auth import HTTPBasicAuth
import sys
import StringIO
import csv
from getpass import getpass
# Set this from the app in github.com
param(
[Parameter(Mandatory=$true)]
[string]
$AdminPassword
)
Set-StrictMode -Version Latest
Set-ExecutionPolicy -executionpolicy remotesigned -force
$pstoolsUrl="https://download.sysinternals.com/files/PSTools.zip"
echo "Set Password"
net user Administrator $AdminPassword
<powershellArguments>-ExecutionPolicy unrestricted</powershellArguments>
<powershell>
$command = @"
winrm quickconfig -quiet;
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}';
winrm set winrm/config '@{MaxTimeoutms="1800000"}';
winrm set winrm/config/service/auth '@{Basic="true"}';
winrm set winrm/config/service '@{AllowUnencrypted="true"}';
net stop winrm;
sc config winrm start= auto;
@dwoz
dwoz / wsgi_profiler.py
Created July 2, 2017 22:17
Configure profiler via Apache's SetEvn directive
'''
Configure profiler via Apache's SetEvn directive
'''
class Profiler(object):
'''
Simple wrapper around werkzeug's ProfilerMiddleware. This allow enabling
the profile via apache's SetEnv directive:
#!/usr/bin/python3
# simple_udp_client.py
import socket
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
MESSAGE = "Hello, World!"
#!/usr/bin/env python3
# simple_tcp_client.py
import socket
TCP_IP = '127.0.0.1'
TCP_PORT = 5005
BUFFER_SIZE = 1024
class TzMapper(object):
def __init__(self, u_to_w):
self.u_to_w = {(k.lower(),v) for k,v in u_to_w}
self.w_to_u = {(v.lower(), k) for k,v in u_to_w}
def add(self, k, v):
self.u_to_w[k.lower()] = v
self.w_to_u[v.lower()] = k
def remove(self, k):
@dwoz
dwoz / buildm2.ps1
Last active September 21, 2018 19:03
function Build-M2 {
Param(
[parameter(Mandatory=$true)]
[String]
$PythonExe
)
if ( -not (Get-Command choco -errorAction SilentlyContinue )) {
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))