Skip to content

Instantly share code, notes, and snippets.

View neblish's full-sized avatar

Benjamin Lai neblish

View GitHub Profile
@neblish
neblish / RegexExtract.vba
Created September 20, 2017 10:18
MS Excel - VBA function to extract text using Regex
' Shamelessly leeched from StackOverflow: https://stackoverflow.com/questions/7086270/how-to-extract-text-within-a-string-of-text
Function RegexExtract(ByVal text As String, _
ByVal extract_what As String, _
Optional separator As String = ", ") As String
Dim allMatches As Object
Dim RE As Object
Set RE = CreateObject("vbscript.regexp")
Dim i As Long, j As Long
Dim result As String
@neblish
neblish / .vimrc
Created May 23, 2017 11:03
Good vim configurations
syntax enable
set tabstop=2
set softtabstop=2
set expandtab
set autoindent
@neblish
neblish / create-user.sh
Last active July 24, 2017 04:49
Create users with group and password assignment
# Create user with primary group name and encrypted password
sudo useradd -g GROUPNAME -p $(openssl passwd -1 changeme) USERNAME
#Expire the password to force the user to change it upon first login.
sudo passwd -e USERNAME
# Locks the password (so user cannot login directly - but can still su from another account login session)
sudo usermod -L USERNAME
@neblish
neblish / aem-query-sql2.md
Last active July 4, 2017 16:47
Useful AEM content queries in SQL2 syntax

To find content under a specific node that were replicated between a time period

SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/path]) AND s.[cq:lastReplicated]>=CAST('2016-03-16T18:30:00.000+08:00' AS DATE)
AND s.[cq:lastReplicated]<=CAST('2016-03-17T12:30:00.000+08:00' AS DATE)

To find nodes that ends with ']', e.g. /path/to/node[2] (Useful if your nodes are hit with the error "Repository error during node import: Cannot create a new node using a name including an index" during replication)

SELECT [jcr:path] FROM [nt:base] WHERE ISDESCENDANTNODE('/etc/designs/') AND [jcr:path] like '%\]'
@neblish
neblish / gist:ac051bfac000b30320ed
Created March 17, 2016 03:08
CQ5 curl commands
Note 1: The following CQ curl commands assumes a admin:admin username and password.
Note 2: For Windows/Powershell users: use two "" when doing a -F cURL command.
Example: -F"":operation=delete""
Note 3: Quotes around name of package (or name of zip file, or jar) should be included.
Uninstall a bundle (use http://localhost:4505/system/console/bundles to access the Apache Felix web console)
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/"name of bundle"
Install a bundle
curl -u admin:admin -F action=install -F bundlestartlevel=20 -F
@neblish
neblish / aem-561-scaffolds-design-link-fix.md
Last active March 4, 2016 02:23
AEM 5.6.1 Scaffolds Design Link Fix