Skip to content

Instantly share code, notes, and snippets.

View drewchapin's full-sized avatar

Drew Chapin drewchapin

View GitHub Profile
@drewchapin
drewchapin / Template.nsi
Created February 20, 2018 19:09
Template for modern NSIS installation script
;-------------------------------------------------------------------------------
; Includes
!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "WinVer.nsh"
!include "x64.nsh"
;-------------------------------------------------------------------------------
; Constants
!define PRODUCT_NAME "My Application"
@drewchapin
drewchapin / HTML Application.hta
Last active August 29, 2024 12:54
Template for an HTML Application file (.hta), add to C:\Windows\ShellNew, and add ShellNew\Filename="HTML Application.hta" to .hta HKCR key.
<html>
<head>
<!--
@tag hta:application
@attribute ApplicationName Sets the name of the HTA.
@attribute Border [Thick]|Thin|None
@attribute BorderStyle [Normal]|Raised|Sunken|Complex|Static
@attribute Caption [Yes]|No
@drewchapin
drewchapin / update-google-dyndns.sh
Last active April 13, 2024 04:06
A shell script to update the public IP address of a Google DynDNS hostname. Intended to be used on DD-WRT routers.
#!/bin/sh
HOSTNAME="host.yourdomain.com"
USERNAME="username"
PASSWORD="password"
LOG_FILE="/tmp/ddns/ddns.log"
while true; do
@drewchapin
drewchapin / bash_coproc_example.sh
Last active January 3, 2024 11:13
Example of how to use the COPROC feature of Bash by showing a progress bar with zenity and updating it.
#!/bin/bash
on_exit() {
echo "#The script has quit unexpectidly on line $1" >&$z
echo "The script has quit unexpectidly on line $1" >&2
exit
}
on_error() {
echo "Error on line $1"
/**
* @author Drew Chapin <drew@drewchapin.com>
* @date 2017/06/27
* @copyright Public Domain
*/
using System.Collections.Generic;
namespace System.Data
@drewchapin
drewchapin / DataSetCompressionExtensions.cs
Last active December 16, 2022 17:56
Wrappers for WriteXml() and ReadXml() methods of DataSet and DataTable objects that first compresses the XML using Gzip.
/**
* \author Drew Chapin <drew@drewchapin.com>
* \copyright Public Domain
* \date 2017/12/08
* \details Wrappers for WriteXml() and ReadXml() methods of DataSet and DataTable objects that first compresses the XML using Gzip.
*
* https://gist.github.com/drewchapin/57b3ae7d5c4ba257aa4e02db88388f9e
*
*/
using System;
@drewchapin
drewchapin / dcFTP.cls
Created July 26, 2016 17:47
VB6 Class Module for FTP access.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' dcftp - Visual BASIC FTP class module based on WinInet API
''
'' Author: Drew Chapin
'' Date: 2012-10-29
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' WinInet API - Constants
REM Change to DHCP setting
NETSH int ip set address name = "Local Area Connection" source = dhcp
REM Renew IP address
IPCONFIG /renew
REM Set proxy settings
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /V ProxyEnable /T REG_DWORD /D 0 /F
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /f /v DefaultConnectionSettings /t REG_BINARY /d 46000000a1010000090000001200000031302e35392e3132352e3232353a383038301d00000031302e35382e32312e2a3b31302e35382e33392e2a3b3c6c6f63616c3e000000000100000000000000f0c1fb7723ccca0100000000000000000000000002000000020000000a3a273c000000000000000001008020010000000000000050b226000e0100000000000014001f6880531c87a0426910a2ea08002b30309df80061800000000068007400740070003a002f002f007700770077002e0067006f006f0067006c0065002e0063006f006d002f0000000000c00000001400efbe13ce2fdf17000000000000000000000000000000000000000000000100000000000000000000000000000000050000000b0000002e00000068007400740070003a002f002f007700770077002e0067006f00
@ECHO OFF
REM Get IP Address from user
SET IPADDR=
SET /P IPADDR=Enter IP Address (Default 10.58.39.242):
IF /I '%IPADDR%'=='' SET IPADDR="10.58.39.242"
ECHO Applying IP Address, Subnet Mask, and Default Gateway...
NETSH interface ip set address "Local Area Connection" static %IPADDR% 255.255.255.0 10.58.21.254 > nul
@drewchapin
drewchapin / FixPivotTableSources.bas
Created September 28, 2016 13:19
Replace pivot table source paths with current path.
Attribute VB_Name = "Module1"
Public Sub Update_Pivot_Tables()
On Error GoTo Exception
Dim sheet As Worksheet, table As PivotTable
For Each sheet In ThisWorkbook.Sheets
For Each table In sheet.PivotTables
Dim newSource As String, sourceType As XlPivotTableSourceType, version As Variant, i As Long
i = InStr(1, StrReverse(table.SourceData), "\", vbTextCompare)