Skip to content

Instantly share code, notes, and snippets.

View Chaz6's full-sized avatar

Chris Hills Chaz6

View GitHub Profile
@Chaz6
Chaz6 / GetOrgChartFromActiveDirectory.pl
Created October 19, 2012 10:19
Create organizational chart from Active Directory
#!/usr/bin/perl -w
########################################################################################
# This script connects to a domain controller and produces an organizational chart.
#
# It is based on the script at the following page:-
# http://thelowedown.wordpress.com/2008/05/27/generate-calltree-from-active-directory/
#
# Chris Hills (chaz@chaz6.com)
# 2012/10/19
@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 / 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 / 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
#!/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 / update-weechat-ssl-letsencrypt.bash
Last active August 22, 2022 11:35
Script to update weechat relay ssl certificate using LetsEncrypt
#!/bin/bash
/usr/bin/certbot renew
if /usr/bin/test $(find /etc/letsencrypt/live/weechat.example.com/cert.pem -mmin -60)
then
/bin/cat /etc/letsencrypt/live/weechat.example.com/cert.pem /etc/letsencrypt/live/weechat.example.com/privkey.pem > /home/user/.weechat/ssl/weechat.example.com_ssl.pem
/bin/cat /etc/letsencrypt/live/weechat.example.com/fullchain.pem > /home/user/.weechat/ssl/weechat.example.com_fullchain.pem
/usr/bin/su -c 'echo "*/relay sslcertkey" > /home/user/.weechat/weechat_fifo_*' user
fi
@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
@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 / update-ssl-certs.bash
Last active April 25, 2020 17:57
Script to update ssl certificates for nginx, unifi and weechat using certbot and systemd
#!/bin/bash
UNIFI_DOMAIN="unifi.example.com"
WEECHAT_DOMAIN="weechat.example.com"
WEECHAT_USER="username"
DOMAIN_LIST="$UNIFI_DOMAIN $WEECHAT_DOMAIN www.example.com"
########################################################################
#
# Program header