Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / selenium_curl.sh
Last active March 13, 2024 16:19
Run Selenium test via curl
s_id=`curl -X POST http://127.0.0.1:4444/wd/hub/session -d '{"desiredCapabilities":{"browserName":"firefox","platform":"MAC"}}'|awk -F'"' '{print $6}'`
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/url -d '{"url":"http://www.google.com"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element -d '{"using":"id","value":"gbqfq"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element/0/value -d {"value":["selenium"]}
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element -d '{"using":"id","value":"gbqfb"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element/1/click
curl -X DELETE http://127.0.0.1:4444/wd/hub/session/$s_id/window
@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 / 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 / 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 / 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 / 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 / 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;