Skip to content

Instantly share code, notes, and snippets.

@prashanthrajagopal
prashanthrajagopal / persistent_ssh.sh
Created May 5, 2014 18:24
Persistent Interactive SSH connection to multiple servers
#!/bin/bash
set -e
###############################################
### Add this to your ~/.ssh/config #
### ControlPath ~/.ssh/master-%r@%h:%p #
### ControlMaster no #
### Run this as ./persistent_ssh.sh box1 box2 #
###############################################
MY_PROMPT="$ "
@prashanthrajagopal
prashanthrajagopal / ruby_proxy.rb
Last active August 29, 2015 14:02
A simple proxy server in Ruby
require 'net/http'
require 'net/https'
require 'uri'
require 'pry'
class Proxy
def server(port)
puts "Starting Proxy server on port #{port}"
@socket = TCPServer.new('localhost', port)
loop do
@prashanthrajagopal
prashanthrajagopal / restart.bat
Last active August 29, 2015 14:02
Batch Script to restart a process if not already running. It runs every 5 seconds
@echo off
:loop
REM Check if the process is already running
tasklist /fi "imagename eq %1" | find /i "%1" > nil
if errorlevel 1 (
REM If not start the process
goto :main
) else (
REM Else keep checking every 5 seconds whether it is alive
@prashanthrajagopal
prashanthrajagopal / get_url.au3
Last active August 29, 2015 14:02
Get the browser from URL for firefox and IE with auto it
if $CmdLine[0] >= 1 Then
$userInput = $CmdLine[1]
Else
$userInput = InputBox("GetURL", "Enter the bame of the browser", "firefox", "", "")
EndIf
if $userInput == "firefox" Then
$window = "[CLASS:MozillaWindowClass]"
if not winexists($window)=1 then;
MsgBox(0, "GetURL", "Mozilla Firefox is not running")
@prashanthrajagopal
prashanthrajagopal / login.reg
Created June 17, 2014 05:48
Auto login windows on boot
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"AutoAdminLogon"="1"
"DefaultUserName"="test"
"DefaultPassword"="123456"
@prashanthrajagopal
prashanthrajagopal / auto_login.scpt
Created June 20, 2014 07:30
Applescript to enable Auto Login in OSX
set username to do shell script "whoami"
set uid to do shell script "id | cut -d' ' -f1 | cut -d'=' -f2 | cut -d'(' -f1"
do shell script "/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser " & username with administrator privileges
do shell script "/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUserUID " & uid with administrator privileges
display dialog "User " & username & " is now the default Auto Login."
@prashanthrajagopal
prashanthrajagopal / Diff
Last active August 29, 2015 14:02
Disable logoff, restart an shutdown from the menu drop down in osx
[100 +] prashanthrajagopal ~/StandardMenus.nib
=> diff objects.xib /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/English.lproj/StandardMenus.nib/objects.xib
185a186,212
> <object class="IBCarbonMenuItem" id="236">
> <string name="title">Sleep</string>
> <ostype name="command">slep</ostype>
> </object>
> <object class="IBCarbonMenuItem" id="237">
> <string name="title">Restart…</string>
> <boolean name="dynamic">TRUE</boolean>
@prashanthrajagopal
prashanthrajagopal / selenium_rc_client_sample.rb
Created June 27, 2014 06:51
A sample selenium RC client
require "selenium/client"
selenium = Selenium::Client::Driver.new("localhost", 4444, "*firefox", "http://www.google.com/", 60);
selenium.start
selenium.open "/"
selenium.type "q", "bowsersttack"
selenium.click "btnG"
selenium.wait_for_page_to_load "30000"
puts selenium.get_html_source
@prashanthrajagopal
prashanthrajagopal / default.vcl
Created October 22, 2014 06:54
Varnish VCL Config
# Adapted from https://gist.github.com/4651531.git with a few mods according to my needs
backend default {
.host = "127.0.0.1";
.port = "8888";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
.max_connections = 800;
}
@prashanthrajagopal
prashanthrajagopal / varnish
Created October 22, 2014 06:57
/etc/default/varnish
# Should we start varnishd at boot? Set to "no" to disable.
START=yes
# Maximum number of open files (for ulimit -n)
NFILES=131072
# Maximum locked memory size (for ulimit -l)
# Used for locking the shared memory log in memory. If you increase log size,
# you need to increase this number as well
MEMLOCK=82000