Skip to content

Instantly share code, notes, and snippets.

@wizard04wsu
wizard04wsu / ts.bat
Created October 4, 2022 16:30
Tree-sitter build script for Atom
@echo off
:: Required version of tree-sitter-cli (TODO: update manually as needed)
set "treesitter=0.15.14"
::=======================================
:: Constants
@wizard04wsu
wizard04wsu / regex.regex
Last active May 22, 2020 19:11
Regular expressions
Phone numbers:
https://gist.github.com/wizard04wsu/11458504
Email validation (complex):
^((?:[!#$%&'*+\-/0-9=?A-Z^_`a-z{|}~]+(?:\.[!#$%&'*+\-/0-9=?A-Z^_`a-z{|}~]+)*)|(?:"(?:(?:(?:(?:[\t ]*\r?\n)?[\t ]+)?(?:[!#$%&'()*+,\-./0-9:;<=>?@A-Z[\]^_`a-z{|}~]|\\[\t !-~])+)+(?:(?:[\t ]*\r?\n)?[\t ]+)?|(?:(?:[\t ]*\r?\n)?[\t ]+))"))@(\d+(?:\.\d+){3}|\[(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){5}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|\d+(?:\.\d+){3})|(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\]|(?:[0-9A-Za-z](?:[0-9A-Za-z-]{0,61}[0-9A-Za-z])?)(?:\.[0-9A-Za-z](?:[0-9A-Za-z-]{0,61}[0-9A-Za-z])?)*)$
Email validation (simpler):
^((?:[!#$%&'*+\-/0-9=?A-Z^_`a-z{|}~]+(?:\.[!#$%&'*+\-/0-9=?A-Z^_`a-z{|}~]+)*)|(?:"(?:[!#$%&'()*+,\-./0-9:;<=>?@A-Z[\]^_`a-z{|}~\t ]|\\[\t !-~])+"))@([A-Za-z-][0-9A-Za-z-]*(?:\.[A-Za-z-][0-9A-Za-z-]*)*|\d+(?:\.\d+){3}|\[[0-9A-Fa-f:.]+\])$
function bind(targetFunction, thisArg){
"use strict";
var boundArgs = Array.prototype.slice.call(arguments, 2);
try{
return Function.prototype.bind.apply(targetFunction, [thisArg].concat(boundArgs));
}catch(e){
function boundFunction(){
return targetFunction.apply(thisArg, boundArgs.concat(arguments));
}
boundFunction.toString = function toString(){ return targetFunction.toString(); };
@wizard04wsu
wizard04wsu / tableToExcel.js
Created June 28, 2018 16:33
Convert an HTML table element to an Excel spreadsheet
function createExcelDownloadLink(xml, filename){
var a = document.createElement('a');
a.href = 'data:application/vnd.ms-excel, '+encodeURIComponent(xml);
a.download = filename;
return a;
}
//note: this doesn't work with complicated tables (e.g., merged cells)
function tableToExcel(tableElem, title, sheetname){
@wizard04wsu
wizard04wsu / Excel_copyPaste.vbs
Last active March 27, 2017 00:24
Three ways to copy & paste in Excel VBA. Be aware that `Range.Copy` and `Range.PasteSpecial` use the clipboard, so avoid copying anything elsewhere (i.e., the desktop, file explorer, or any other application) while a macro is running that uses those methods.
'Be aware that `Range.Copy` and `Range.PasteSpecial` use the clipboard.
'copy everything (values, formats, comments, et al.)
Private Sub CopyPasteAll(fromRange As Range, toRange As Range)
fromRange.Copy toRange
End Sub
'copy values only (without using the clipboard)
@wizard04wsu
wizard04wsu / Excel_stripHTML.vbs
Last active March 22, 2017 19:35
Strip HTML tags from selected cells
'requires reference to Microsoft VBScript Regular Expressions 5.5
Sub stripHTML()
Dim cell As Object
For Each cell In Selection
If Not (IsEmpty(cell) Or IsNumeric(cell) Or cell.HasFormula) Then
On Error Resume Next
cell.Value = doStripHTML(cell.Formula)
@wizard04wsu
wizard04wsu / Excel_shortcuts.vbs
Last active March 22, 2017 19:34
Excel macros for simple stuff I do often, including changing text casing and number formatting.
Sub ToLowerCase()
Dim cell As Object
For Each cell In Selection
cell.Value = LCase(cell.Value)
Next
End Sub
@wizard04wsu
wizard04wsu / VBA_filesAndFolders.vbs
Last active April 1, 2017 17:25
VBA functions for traversing files and folders and prompting the user to select a file/folder. Includes an example.
'requires reference to Microsoft Office 14.0 Object Library
'prompts the user for a folder
'see http://www.vbaexpress.com/kb/getarticle.php?kb_id=896
Private Function GetFolderName(Optional OpenAt As String) As String
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = OpenAt
.Show
If .SelectedItems.Count = 0 Then Exit Function
GetFolderName = .SelectedItems(1)
@wizard04wsu
wizard04wsu / fuzzySpoiler.htm
Last active June 20, 2023 01:41
CSS to obfuscate text until you hover over it. I got this idea from https://www.reddit.com/r/MumboJumboFanServer/ where similar CSS is used to hide spoilers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS to obfuscate text</title>
<style>
@wizard04wsu
wizard04wsu / genLink.htm
Created January 4, 2017 20:32
Form to generate a link. Useful when you need to right-click and "Save Target As" or for making JavaScript bookmarklets.