Skip to content

Instantly share code, notes, and snippets.

@basilhayek
basilhayek / jsonpath.vbs
Created September 26, 2019 06:09
Simplified VBA version of JSONPath; built for parsing JSON in XLS; only returns discrete items (no support for slices, wildcards, filters, or deep scans)
Option Explicit
' https://github.com/json-path/JsonPath
Public Function GetElement(rngJSON As Range, jsonpath As String) As String
Dim JSON As Object
Set JSON = ParseJson(rngJSON)
GetElement = GetNext(JSON, jsonpath)
@basilhayek
basilhayek / setlistfm_to_playlist_converter.js
Last active August 2, 2018 01:15
A simple bookmarklet to make it easy to convert playlists posted on setlist.fm to a service of your choice using www.playlist-converter.net (two great sites!)
var t = document.title;
var b0 = "";
var s = "";
if (window.location.hostname === "www.setlist.fm") {
if (t.includes("Average Setlists")) {
b0 = t.substring(0, t.indexOf(" Average Setlists"));
} else if (t.includes("Concert Setlist")) {
b0 = t.substring(0, t.indexOf(" Concert Setlist"));
}
// Make sure we're on a supported page by checking if we have the band name
@basilhayek
basilhayek / highlight_weekends.js
Last active August 2, 2018 01:08
JavaScript to highlight in red dates that fall on weekends; you must first select a date so the script can find similar elements by class (only looks at the selected and parent nodes)
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
@basilhayek
basilhayek / siteping.py
Last active May 30, 2023 04:16
A simple python script to check URLs and send email alerts if there are any exceptions. Originally created as a keepalive to ping web apps on PythonAnywhere to keep them from sleeping. Thanks to ogrigas for the inspiration.
import requests
urls = [
"http://www.google.com",
"http://www.yahoo.com",
]
def send_mail(sender, recipient, subject, message, password, smtpserver):
from smtplib import SMTP
from email.mime.text import MIMEText
Private Function CountSyllables(TxtIn As String) As Long
Dim X As Long
For X = 1 To Len(TxtIn)
' Vowels
CountSyllables = CountSyllables - (Mid(TxtIn, X, 1) Like "[AaEeIiOoUuYy]")
' Dipthongs
CountSyllables = CountSyllables + (Mid(TxtIn, X, 2) Like "[AaEeIiOoUuYy][AaEeIiOoUuYy]")
Next
' Silent "e"
CountSyllables = CountSyllables + (Right(TxtIn, 3) Like "[AaEeIiOoUuYy][!AaEeIiOoUuYy]e")
<div id="visualization" style="margin: 1em"> </div>
@basilhayek
basilhayek / outlook-create-appt.vbs
Created December 2, 2016 15:11
Create an Outlook Appointment via VBA
Sub CreateAppt()
Dim myItem As Outlook.AppointmentItem
Set myItem = Application.CreateItem(olAppointmentItem)
myItem.MeetingStatus = olNonMeeting
myItem.Subject = "Strategy Meeting"
myItem.Location = "Conf Rm All Stars"
myItem.Start = #12/1/2016 5:30:00 PM#
myItem.Duration = 90
myItem.Display
Sub CleanStyles()
Dim sty As Style, wbTemp As Workbook
' First, remove all styles other than Excel's own.
' they may have arrived from pasting from other workbooks
For Each sty In ThisWorkbook.Styles
If Not sty.BuiltIn Then sty.Delete
Next
'Second, revert the remaining styles to Excel's default for a new workbook
Sub TrimStyles()
Dim s As Variant
Dim g As Style
On Error Resume Next
With ActiveWorkbook
For Each g In .Styles
If g.BuiltIn = False Then
s = g.Value