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 / 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)
{
@sajanp
sajanp / email-signature
Last active December 11, 2015 21:49
My email signature for Thunderbird. Hate having to log into Amazon S3 and get the URL of the logo image and retype everything. Although, as I'm typing this description, I just realized I could copy and paste this signature from any email in my sent folder. Doh!
Sajan Parikh<br />
<i>Owner, Noppix LLC</i><br /><br />
e: sajan@noppix.com<br />
o: (563) 726-0371<br />
c: (563) 447-0822<br /><br />
<img alt="Noppix LLC Logo" src="https://s3.amazonaws.com/Noppix_Media/Email_Signatures/NewNoppixEmailLogo.png" />