Skip to content

Instantly share code, notes, and snippets.

@rtomaszewski
rtomaszewski / bastion.py
Created August 28, 2012 23:43
example how to use paramiko to implement a bastion host pattern for command execution
#!/usr/bin/env python
import re
import time
import datetime
import paramiko
import traceback
DEBUG = 1
def myfunc(message):
"""
This is external function
@param message: this is string that is going to be printed
@return: none
"""
print("myfunc: %s" % message)
@rtomaszewski
rtomaszewski / wheel-scroling.au3
Created February 10, 2013 23:45
autoit script to change mouse wheel sensitivity
; This program adjust scroling of the mouse wheel on windows.
GLOBAL CONST $SPI_SETWHEELSCROLLLINES = 105
$SPIF_UPDATEINIFILE = 0x1
$SPIF_SENDWININICHANGE = 0x2
$SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE
$WHEEL_PAGESCROLL = 4294967295 ; Use this, if you want scroll one Screen at a time
@rtomaszewski
rtomaszewski / list_cs.py
Created April 6, 2013 21:22
list cloud servers using pyrax module
import os
import pyrax
conf = os.path.expanduser("rackspace_cloud_credentials.txt")
#pyrax.set_credential_file(conf, "LON")
pyrax.set_credential_file(conf)
cs = pyrax.cloudservers
servers = cs.servers.list()
print ("cloud server under your account:")
@rtomaszewski
rtomaszewski / bash-table.sh
Created June 17, 2013 18:49
Example of tables in Bash
#!/bin/bash
TESTS[0]=a,b,c
TESTS[1]=1,2,3
for row in "${TESTS[@]}"; do
IFS=","
set $row
col1=$1
col2=$2
@rtomaszewski
rtomaszewski / install_dotfiles
Last active December 30, 2015 17:59
install dotfiles
# (1) Example can be found here
# https://github.com/rtomaszewski/dotfiles
# (2)
#alias homeshick="source $HOME/.homesick/repos/homeshick/bin/homeshick.sh"
git clone git://github.com/andsens/homeshick.git $HOME/.homesick/repos/homeshick
source $HOME/.homesick/repos/homeshick/homeshick.sh
# (3)
homeshick clone rtomaszewski/dotfiles
@rtomaszewski
rtomaszewski / openstack_ssh_key_automation
Last active December 30, 2015 18:09
How to automatically deploy your public ssh key to Openstack cloud server How to create a new cloud server and automatically deploy ssh authorized_keys file with our public ssh key. http://rtomaszewski.blogspot.co.uk/2013/12/how-to-automatically-deploy-your-public.html
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
$ cd .ssh
mv id_rsa.pub id_rsa_auxiliary.pub
mv id_rsa id_rsa_auxiliary
# http://rtomaszewski.blogspot.co.uk/2013/10/home-directory-and-dotfiles-management.html
# https://github.com/rtomaszewski/dotfiles/blob/master/.bashrc_rado_aux
aptitude install git
aptitude install gcc
aptitude install python-dev
aptitude install python-pip
pip install pymongo
pip install bottle
# extract the hw1 archive file
# change to the directory
$ ls
root@mongo2:~/hw1# ls -la
total 24
drwxrwxr-x 3 root root 4096 Dec 18 23:57 .
drwxr-xr-x 11 root root 4096 Dec 18 23:57 ..
drwxr-xr-x 3 root root 4096 Feb 12 2013 dump
-rw-r--r-- 1 root root 598 Mar 27 2013 hw1-2.py
-rw-r--r-- 1 root root 2584 Dec 18 23:51 hw1-2.py.html
cd ~/mongo-course/week1/homework#
# python hw1-2.21394489c9ad.py
The answer to Homework One, Problem 2 is 1815
# python hw1-3.e594fc84d4ac.py
Bottle v0.11.6 server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.