Skip to content

Instantly share code, notes, and snippets.

@damc-dev
damc-dev / ps-notify-example.go
Created July 18, 2017 13:51
Example using ps notify
package main
import (
"bytes"
"log"
"os"
"os/exec"
"syscall"
"github.com/cloudfoundry/gosigar/psnotify"
@damc-dev
damc-dev / reload_explorer.bat
Created August 7, 2017 14:27
Reload explorer.exe to pick up changes such as environment variables
taskkill /f /im explorer.exe
explorer.exe
@damc-dev
damc-dev / giphy_download_links.js
Created September 22, 2017 14:40
Giphy Download Links to All Gifs
@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 / 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 / _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)
# 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 / 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":
@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