Skip to content

Instantly share code, notes, and snippets.

@damc-dev
damc-dev / get-todays-calendar-events.applescript
Created November 30, 2022 16:11
Partially working applescript to retrieve todays calendar entries and add to clipboard (Note doesn't capture reoccurring entries)
-- NOTE Problem with this is that because of the way reocurring events are handled they aren't captured by this script
-- See this thread for some workarounds to project reocurring events: https://macscripter.net/viewtopic.php?id=29516
on format24h(provided_date)
try
set oldDelims to AppleScript's text item delimiters
set the_time to time string of provided_date -- something like "4:20:56 PM"
set am_pm to characters -2 thru -1 of the_time as string -- is it AM or PM
set AppleScript's text item delimiters to ":"
set the_hour to text item 1 of the_time as string -- in this example, "4"
@damc-dev
damc-dev / loopjson-simple.sh
Last active October 20, 2022 14:18
Loop over JSON list of objects with jq in bash
MY_JSON='[{"name": "Banana", "type": "Fruit"},{"name": "Carrot", "type": "Vegetable"},{"name": "Intentionally Blank Type", "type": ""},{"name": "Bread", "type": "Grain"}]'
for row in $(jq -r '.[] | @base64' <<< "${MY_JSON}"); do
_jq() {
base64 --decode <<< "${row}" | jq -r ${1}
}
NAME=$(_jq '.name')
TYPE=$(_jq '.type')
echo "${NAME} is a ${TYPE}"
@damc-dev
damc-dev / GetZoomParticipants.scpt
Last active March 8, 2024 15:13
Applescript to Retrieve Participants From Zoom MacOS App
#!/usr/bin/osascript
on convertListToString(theList, theDelimiter)
set AppleScript's text item delimiters to theDelimiter
set theString to theList as string
set AppleScript's text item delimiters to ""
return theString
end convertListToString
on get_participants()
@damc-dev
damc-dev / outlookMoveMessages.scpt
Created May 14, 2021 18:25
Easy way to move outlook messages to my most used folders
tell application "Microsoft Outlook"
activate
set selectedMessages to selected objects
if selectedMessages is {} then
display notification "Please select a message in Outlook before running the script!"
else
set folderChoices to {"Inbox", "2 - Action", "3 - Waiting For", "4 - Reference", "5 - Archive"}
set selectedFolders to choose from list folderChoices with prompt "Select folder to move to:" default items "5 - Archive"
set selectedFolder to item 1 of selectedFolders
set destFolder to mail folder selectedFolder
@damc-dev
damc-dev / zillow_address_scraper.py
Created August 14, 2020 19:43
Script to scrape addresses from Zillow and write them to CSV's
from lxml import html
import requests
import unicodecsv as csv
import argparse
def parse(zipcode,page=0,filter=None):
if filter=="newest":
url = "https://www.zillow.com/homes/for_sale/{0}/{1}_p/0_singlestory/days_sort".format(zipcode, page)
elif filter == "cheapest":
# The following will split a CSV (file.csv) into multiple parts of 1 million lines each
# with each part having its own header.
#
# PREFIX denotes the filename to use for the parts. A number will be added to the end.
tail -n +2 file.csv |
split -d -l 1000000 - --filter='sh -c "{ head -n1 file.csv; cat; } > $FILE"' PREFIX
@damc-dev
damc-dev / _service.md
Created February 17, 2019 19:29 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@damc-dev
damc-dev / RequestAndResponseLoggingFilter.java
Created January 23, 2019 01:24 — forked from int128/RequestAndResponseLoggingFilter.java
Spring Web filter for logging request and response
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.ContentCachingResponseWrapper;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
@damc-dev
damc-dev / Notes_SpringBatch_CursorVsPagedReaders.md
Created August 14, 2018 17:29
[Note] Spring Batch - Cursor based vs page based item readers for retrieving records from a database

So from what I can tell from the docs [https://docs.spring.io/spring-batch/trunk/reference/html/readersAndWriters.html#database]

Cursor based item readers use a DB single connection load the entire ResultSet into app memory by default then the application iterates over the ResultSet with a cursor (So not a DB cursor) mapping one row and writing it out at a time so previous rows can be garbage collected.

Although you can set the maxRows to limit the amount of rows in the ResultSet at one time, then when the ResultSet needs more rows it will (using the same connection) fetch more (amount depends on the value of fetchSize). This continues until all rows from the query are loaded into the ResultSet and read.

Page based item readers make multiple queries each returning a different "page" of the results (size configurable with setPageSize method)

I assume cursor based item readers probably use more memory (unless configured appropriately) and be faster, where as the page based would typically consume less memo

@damc-dev
damc-dev / giphy_download_links.js
Created September 22, 2017 14:40
Giphy Download Links to All Gifs