Skip to content

Instantly share code, notes, and snippets.

View Chaz6's full-sized avatar

Chris Hills Chaz6

View GitHub Profile
@Chaz6
Chaz6 / unzip-recurse.py
Created December 28, 2014 15:57
Extract files recursively using python
#!/usr/bin/env python
import errno
import os
import sys
import subprocess
#-----------------------------------------------------------------------------
def main():
fileNames = sys.argv[1:]
@Chaz6
Chaz6 / GetNewADSObjects.vbs
Created October 31, 2012 17:39
List newly created objects in an Active Directory domain
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Dim strTimestamp
strTimestamp = "20120901000000.0Z"
set objRootDSE = GetObject("LDAP://RootDSE")
RootDN = objRootDSE.Get("defaultNamingContext"))
Set objConnection = CreateObject("ADODB.Connection")
@Chaz6
Chaz6 / tumblr-get.py
Created August 27, 2016 12:37
Download images from a tumblr blog
#!/usr/bin/python
import os, sys
import urlparse
from shutil import copyfileobj
from urllib import urlopen, unquote
from xml.etree import ElementTree as ET
from socket import error as socket_error
import socket
@Chaz6
Chaz6 / gallery.bash
Created August 27, 2016 12:40
Create a simple image gallery using bash
@Chaz6
Chaz6 / error.txt
Created November 3, 2016 21:00
php error on www.wileyfox.com
Notice: Undefined index: access_token in /var/www/production/public/app/code/local/Wcm/Iqcloud/Helper/Api.php on line 72
#0 /var/www/production/public/app/code/local/Wcm/Iqcloud/Helper/Api.php(72): mageCoreErrorHandler(8, 'Undefined index...', '/var/www/produc...', 72, Array)
#1 /var/www/production/public/app/code/local/Wcm/Iqcloud/Helper/Api.php(353): Wcm_Iqcloud_Helper_Api->getAccessToken()
#2 /var/www/production/public/app/code/local/Wcm/Iqcloud/Model/Observer.php(182): Wcm_Iqcloud_Helper_Api->api_update_customer(Object(Varien_Object))
#3 /var/www/production/public/app/code/core/Mage/Core/Model/App.php(1358): Wcm_Iqcloud_Model_Observer->afterCustomerSave(Object(Varien_Event_Observer))
#4 /var/www/production/public/app/code/core/Mage/Core/Model/App.php(1337): Mage_Core_Model_App->_callObserverMethod(Object(Wcm_Iqcloud_Model_Observer), 'afterCustomerSa...', Object(Varien_Event_Observer))
#5 /var/www/production/public/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('customer_save_a...', Array)
#6 /var
#!/bin/bash
/usr/bin/certbot renew
if test $(find /etc/letsencrypt/live/unifi.example.com/cert.pem -mmin -60)
then
/bin/systemctl stop unifi.service
/usr/bin/openssl pkcs12 -export -inkey /etc/letsencrypt/live/unifi.example.com/privkey.pem -in /etc/letsencrypt/live/unifi.example.com/fullchain.pem -out /tmp/unifi.example.com.p12 -name ubnt -password pass:temppass
/bin/keytool -importkeystore -deststorepass aircontrolenterprise -destkeypass aircontrolenterprise -destkeystore /opt/UniFi/data/keystore -srckeystore /tmp/unifi.example.com.p12 -srcstoretype PKCS12 -srcstorepass temppass -alias ubnt -noprompt
/bin/rm -f /tmp/unifi.example.com.p12
@Chaz6
Chaz6 / bash-path-vars
Created March 16, 2017 17:48 — forked from caruccio/bash-path-vars
Path manipulation with bash vars
$ FILE=/some/path/to/file.txt
###################################
### Remove matching suffix pattern
###################################
$ echo ${FILE%.*} # remove ext
/some/path/to/file
$ FILE=/some/path/to/file.txt.jpg.gpg # note various file exts
@Chaz6
Chaz6 / tumblr-get.py
Created December 3, 2018 18:56
Threaded tumblr image/video downloader
#!/usr/bin/env python
import os, sys, re, time
from shutil import copyfileobj
from urllib.request import urlopen, unquote
from xml.etree import ElementTree as ET
from socket import error as socket_error
import socket
import requests
@Chaz6
Chaz6 / thumbnail-videos-as-webpage.bash
Last active January 25, 2019 19:57
Generate a thumbnail web page for a folder of videos
#!/bin/bash
SIZE=400
cat >index.html<<EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Thumbnail gallery</title>
@Chaz6
Chaz6 / sort-folders-by-largest-file.py
Last active February 5, 2019 18:59
sort-folders-by-largest-file.py
#!/bin/python3.6
import pathlib
import shutil
import os
def filesize(path):
return path.stat().st_size
def biggest(folder):