Skip to content

Instantly share code, notes, and snippets.

@prashanthrajagopal
prashanthrajagopal / mirror_sync_cron.sh
Last active December 8, 2019 01:38
Sync Ubuntu Mirror v1
### Admin email address
admin_email=admin@domain.com
### Setup the server to mirror
mirror=rsync://archive.ubuntu.com/ubuntu
### Log file path
log=/var/log/ubuntu
### Setup the local directory
@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 / screenshot.cpp
Last active December 31, 2023 17:26
Take a screenshot and save as jpeg in c++
#include <stdio.h>
#include <windows.h>
#include <gdiplus.h>
#include <time.h>
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid) {
using namespace Gdiplus;
UINT num = 0;
UINT size = 0;
@prashanthrajagopal
prashanthrajagopal / desktop_restrictions.reg
Last active November 23, 2023 17:50
Desktop restrictions for windows - very minimal access to users
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop]
"NoChangingWallPaper"=dword:00000001
"NoAddingComponents"=dword:00000001
"NoClosingComponents"=dword:00000001
"NoDeletingComponents"=dword:00000001
"NoEditingComponents"=dword:00000001
@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 / get_url.scpt
Last active January 13, 2024 11:58
AppleScript to get url from Safari, Firefox and Chrome
display dialog "Name of the browser?" default answer "Safari"
set inp to text returned of result
tell application "System Events"
if inp is "Google Chrome" then
tell application "Google Chrome" to return URL of active tab of front window
else if inp is "Safari" then
tell application "Safari" to return URL of front document
else if inp is "Firefox" then
tell application "Firefox" to activate
@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."