Skip to content

Instantly share code, notes, and snippets.

View sajanp's full-sized avatar

Sajan Parikh sajanp

  • COS Systems
  • Pittsburgh, PA
View GitHub Profile
# vzdump default settings
#tmpdir: DIR
#dumpdir: DIR
#storage: STORAGE_ID
#mode: snapshot|suspend|stop
#bwlimit: KBPS
#ionice: PRI
#lockwait: MINUTES
#stopwait: MINUTES
#!/bin/bash
date=$(date +"%m-%d-%Y")
if [ "$1" == "job-end" ]; then
rclone move /var/lib/vz/dump/ b2:my-proxmox-server/vzdumps/$date/
fi
@sajanp
sajanp / sajan.pub
Created February 22, 2014 16:35
Personal Public SSH Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO3lPvkj3Mr0U8pQxo8svnw+dlDw7fNCnhaaSY4+YNz3AF0bRbGJplSA0iIWuaaw+8VgaHDfB1cLN1I3QORB5li242Gikf5l/FHz4PjGW7g7Q7C0rKYgYPdG823+JfpyWCyfx1Md4Ic1+APjqhMQG4nx7dUXaahX8xDyte5qg2uTV/UbDoX2fEOJuJLwKLF0G+rZgqwWbyPVJltTR/xVuyvwzdAjAxrhS4N7M1z5Wvx24tC4Zg8tii+ZJK34vMmqhhnw9khdem6ot6Y3jnJ24uk7T2fXjo/i2lqQDCeKTRT4cBJrCt71Dt/jj/6XDjeT8Io4s5wPBCDVlnUXk7XSut sajan@vor
@sajanp
sajanp / backup
Last active December 21, 2015 15:19
#!/bin/bash
DATE=$(date +"%m-%d-%Y")
DATABASES=`mysql -e "SHOW DATABASES" | tr -d "| " | grep -Ev 'Database|information_schema|performance_schema|mysql'`
echo "Dumping Databases"
for db in $DATABASES
do
echo "========================"
@sajanp
sajanp / status.php
Created June 29, 2013 19:16
A basic status page for Nodeping. You create check groups by putting (Group Name) in the check name at nodeping.
<?php
$apiToken = ''; // Your API Key from NodePing.
// Ask NodePing if any checks are down.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.nodeping.com/api/1/checks?current=1&token=" . $apiToken);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$checks = json_decode(curl_exec($ch));
<?php
/**
* Basic WHOIS query script for exipry date
*/
// feed domain via script, or GET request
$domain = (PHP_SAPI == 'cli') ? $argv[1] : $_GET['domain'];
// exit if no domain is provided
if (!$domain) {
@sajanp
sajanp / SublimeText2.desktop
Last active December 15, 2015 08:39
Sublime Text 2 desktop launcher for Ubuntu/Unity.
[Desktop Entry]
Version=2.0.1
Name=Sublime Text 2
Encoding=UTF-8
Comment=Advanced Code and Text Editor
Exec=/opt/sublime2/sublime_text
Icon=/opt/sublime2/Icon/256x256/sublime_text.png
Terminal=false
Type=Application
Categories=Developer;
<?php
$numbers = array(
mt_rand(1, 200),
mt_rand(1, 200)
);
echo $json_encode($numbers);
?>
@sajanp
sajanp / twilio.php
Last active December 12, 2015 10:09
Quick two files to have Zendesk post to zendesk.php on a trigger, which will then ask Twilio to go to twilio.php and do stuff. Like call you and text you. You will need to load the Twilio PHP helper.
<?php
include 'Twilio.class.php';
$subject = urldecode($_GET['subject']);
$response = new Services_Twilio_Twiml();
$response->say('Hello. New Zen desk ticket.');
$response->pause("");
$response->say($subject);
$response->sms(
'New support ticket: ' . $subject,
@sajanp
sajanp / alpha_num_spaces.php
Last active December 12, 2015 02:18
CodeIgnitor form validation class to allow only alphanum and spaces. My regex is ABSOLUTELY terrible (whose isn't?), so...this may not work and needs to be tested. If you find that the regex pattern needs to be tweaked, please come back and edit this gist.
<?php
function alpha_num_spaces($subject)
{
$pattern = "#^[A-Z0-9 ]+$#i";
$res = preg_match($pattern, $subject);
if ($res == 1)
{