Skip to content

Instantly share code, notes, and snippets.

@jceresearch
jceresearch / VBA Excel find external validation
Last active Aug 22, 2018
To detect the pesky links to external validation that trigger errors when opening the file
View VBA Excel find external validation
Public Sub FindExtValidation()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
ws.Activate
On Error Resume Next
Set v1 = ws.Cells.SpecialCells(xlCellTypeAllValidation)
If Err.Number > 0 Then
GoTo next_sheet
End If
@jceresearch
jceresearch / gist:061438407a53021efc0b
Last active Aug 29, 2015
Sed command to redact sh... p... file for safe extraction
View gist:061438407a53021efc0b
sed -r 's/^([^:]+):([^:])([^:]?)([^:]?)([^:]*):(.*)$/\1:\2\3\4:\6/w shadowredacted' < shadow
@jceresearch
jceresearch / NumpyGroupBy
Created Dec 29, 2014
Phython - Numpy loop to group an array by certain key, supposed to be the faster way
View NumpyGroupBy
import numpy as np
data = np.arange(1, 7)
groups = np.array([0,0,1,2,2,1])
unique_groups = np.unique(groups)
sums = []
for group in unique_groups:
sums.append(data[groups == group].sum())
@jceresearch
jceresearch / Clean github history
Created Jul 31, 2014
Steps to cleanup old version data from a github repository, brute force
View Clean github history
Here's the brute-force approach. It also removes the configuration of the repo.
You need to save first the gitignore
Step 1: remove all history
rm -rf .git
Step 2: reconstruct the Git repo with only the current content
@jceresearch
jceresearch / gist:5755030
Last active Jul 6, 2020
Google Apps Script to create a digest from a set of messages in Gmail. It does a bit more than that, filters by time, strips the html, trims legalese (or whatever) and tags messages so they are not processed again. Ideal to schedule it in gmail.
View gist:5755030
function GenerateDigest() {
//Function that goes through a search query based on time and optional label in gmail, strips html, collates into a single email, sends it to a desired address and then labels the emails as processed.
// Where the digest email is going
var to_emailAddress = "tomail@somedomain.com";
//We calculate the 24 hour range, I plan to run this every day at 9:00 to get last 24 hours of emails
var month = new Date().getMonth();