Skip to content

Instantly share code, notes, and snippets.

View iann0036's full-sized avatar

Ian Mckay iann0036

View GitHub Profile
View DOM Template
$page_max = 123;
$leadurl = '';
$results = array();
for ($page=1; $page<$page_max; $page++) {
$doc = new DOMDocument();
$elems = $doc->getElementsByTagName('div');
View DateTime String
function convert_datetime($datetime, $dateonly = false) {
$values = explode(" ", $datetime);
$dates = explode("-", $values[0]);
$times = explode(":", $values[1]);
$newdate = mktime($times[0], $times[1], $times[2], $dates[1], $dates[2], $dates[0]);
$newdate2 = $_SERVER['REQUEST_TIME']-$newdate;
if ($newdate2>172799 || $dateonly)
return date("F j, Y",$newdate);
else if ($newdate2>86399)
View vshieldExport
class vshieldExportImport {
public static void main(String[] args) {
try {
String output = httpGet("https://10.x.x.x/api/2.0/app/firewall/datacenter-2/config?list=config");
iann0036 / MY_Cart.php
Created March 23, 2015 14:27
CodeIgniter Cart Extend for insert to add
View MY_Cart.php
class MY_Cart extends CI_Cart {
private function _is_identical($a, $b) {
return $a == $b;
public function insert($data) {
foreach ($this->contents() as $item) {
iann0036 /
Last active March 13, 2016 07:46
VPS Migration Script (personalized)
echo -n "Enter your MySQL root password, followed by [ENTER]: "
read mysqlrootpwd
echo -n "Enter your remote hosts root password, followed by [ENTER]: "
read remoterootpwd
apt-get -y update;
apt-get -y upgrade;
apt-get -y install sshpass;
View Python Alarms
import smtplib
import os
import syslog
import requests
import subprocess
from email.mime.text import MIMEText
def alarmLocalHTTPPing():
millis = requests.get("").elapsed.microseconds # /1000 ?
if millis > 100:
iann0036 /
Created December 7, 2017 04:55
Download Cloudfronted Bucket
import requests
import xml.etree.ElementTree
import pprint
import re
import os
import threading
base_address = ""
def createAndOpen(filename):
iann0036 /
Created December 21, 2017 06:43
Play with the front LED lights on the DeepLens device
import os
from time import sleep
gpio_path = "/sys/class/gpio/"
with open(gpio_path + "gpio437/direction", 'w') as direction:
with open(gpio_path + "gpio443/direction", 'w') as direction:
iann0036 /
Last active March 5, 2018 12:08
Darken screen around area
import wx
import time
from multiprocessing import Process, Lock
def darkenScreenAroundArea(lock, x, y, width, height):
app = wx.App(False)
screensize = wx.GetDisplaySize()
frm = DarkFrame(lock, 0, 0, screensize[0], y) # top
frm = DarkFrame(lock, 0, y, x, height) # left
frm = DarkFrame(lock, (x + width), y, (screensize[0] - x + width), height) # right
iann0036 /
Created March 6, 2018 23:29
CloudWatch Log Lambda Subscription to ElasticSearch
from __future__ import print_function
import json
import base64
import zlib
from elasticsearch import Elasticsearch
from elasticsearch.connection import create_ssl_context
from datetime import datetime
def handler(event, context):