Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Mckay iann0036

View GitHub Profile
View DOM Template
<?php
$page_max = 123;
$leadurl = '';
$results = array();
for ($page=1; $page<$page_max; $page++) {
$doc = new DOMDocument();
$doc->loadHTML(file_get_contents($leadurl.$page));
$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;
$newdate2+=DB_TIME_OFFSET;
if ($newdate2>172799 || $dateonly)
return date("F j, Y",$newdate);
else if ($newdate2>86399)
View vshieldExport
import java.io.*;
import java.net.*;
import javax.net.ssl.*;
import java.security.cert.*;
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");
System.out.println(output);
View Python Alarms
import smtplib
import os
import syslog
import requests
import subprocess
from email.mime.text import MIMEText
def alarmLocalHTTPPing():
millis = requests.get("http://127.0.0.1").elapsed.microseconds # /1000 ?
if millis > 100:
@iann0036
iann0036 / main.py
Created Nov 15, 2014
Simon Says Bot
View main.py
"""
Python Bot Player
iann0036 2014
http://www.miniclip.com/games/simon-says/en/#t-c-f-C
"""
import ImageGrab
import os
import time
import win32api, win32con
@iann0036
iann0036 / MY_Cart.php
Created Mar 23, 2015
CodeIgniter Cart Extend for insert to add
View MY_Cart.php
class MY_Cart extends CI_Cart {
private function _is_identical($a, $b) {
sort($a);
sort($b);
return $a == $b;
}
public function insert($data) {
foreach ($this->contents() as $item) {
@iann0036
iann0036 / auto.py
Last active Sep 22, 2021
Python Input Record and Play
View auto.py
import pyautogui, time, sys, os, win32api, win32gui, win32con, datetime, pyHook, pythoncom
from optparse import OptionParser
'''
Python Automated Actions Script by Ian Mckay
Version 0.1 - 20151217
'''
pyautogui.PAUSE = 0
pyautogui.FAILSAFE = True
@iann0036
iann0036 / migration.sh
Last active Mar 13, 2016
VPS Migration Script (personalized)
View migration.sh
#!/bin/bash
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 download_cloudfronted_bucket.py
import requests
import xml.etree.ElementTree
import pprint
import re
import os
import threading
base_address = "https://xxxxxxxxxxxxxxxx.cloudfront.net/"
def createAndOpen(filename):
@iann0036
iann0036 / deeplens_leds.py
Created Dec 21, 2017
Play with the front LED lights on the DeepLens device
View deeplens_leds.py
import os
from time import sleep
gpio_path = "/sys/class/gpio/"
with open(gpio_path + "gpio437/direction", 'w') as direction:
direction.write('out')
with open(gpio_path + "gpio443/direction", 'w') as direction:
direction.write('out')