Skip to content

Instantly share code, notes, and snippets.

View kern-me's full-sized avatar

Nico Killips kern-me

View GitHub Profile
@kern-me
kern-me / file_read_write.scpt
Last active October 1, 2018 12:31
Applescript : Reading and Writing Files
-- ACCESS
on writeTextToFile(theText, theFile, overwriteExistingContent)
try
set theFile to theFile as string
set theOpenedFile to open for access file theFile with write permission
if overwriteExistingContent is true then set eof of theOpenedFile to 0
write theText to theOpenedFile starting at eof
close access theOpenedFile
return true
@kern-me
kern-me / file_get_path.scpt
Last active January 17, 2020 15:29
Applescript : Get the Current File Path
on setFilePath(fileName)
set a to POSIX path of ((path to me as text) & "::")
set b to a & fileName
return b as string
end setFilePath
#setFilePath("test.txt")
@kern-me
kern-me / load_script.scpt
Last active October 1, 2018 12:50
Applescript : Load Script
on load_script(_scriptName)
tell application "Finder"
set _myPath to container of (path to me) as string
set _loadPath to (_myPath & _scriptName) as string
load script (alias _loadPath)
end tell
end load_script
@kern-me
kern-me / list_average.scpt
Last active October 8, 2018 10:04
Applescript - Find the average of numbers in a list
-- Sum of numbers in a list
on listAvg(theList)
set the_list to theList
set a to 0
repeat with this_item in the_list
set a to a + this_item
end repeat
set avg to a / (count the_list)
return avg
@kern-me
kern-me / list_largest_number.scpt
Created October 8, 2018 10:24
Applescript : Find the Largest Number in a List
on highest_number(values_list)
set the high_amount to ""
repeat with i from 1 to the count of the values_list
set this_item to item i of the values_list
set the item_class to the class of this_item
if the item_class is in {integer, real} then
if the high_amount is "" then
set the high_amount to this_item
else if this_item is greater than the high_amount then
@kern-me
kern-me / list_remove_dupes.scpt
Created October 8, 2018 10:39
Applescript: Remove Duplicates from a List
on list_remove_dupes(theList)
set newList to {}
repeat with x from 1 to count of items of theList
set n to item x of theList
if n is not in newList then set end of newList to n
end repeat
return newList
end list_remove_dupes
@kern-me
kern-me / etsy_tags_to_title.js
Created October 17, 2018 13:14
Javascript : Populate Etsy tags to the Title Input
function makeArray() {
var arr = [];
arr[0] = document.querySelectorAll(".tag.tag-left")[0].innerText.trim();
arr[1] = document.querySelectorAll(".tag.tag-left")[1].innerText.trim();
arr[2] = document.querySelectorAll(".tag.tag-left")[2].innerText.trim();
arr[3] = document.querySelectorAll(".tag.tag-left")[3].innerText.trim();
arr[4] = document.querySelectorAll(".tag.tag-left")[4].innerText.trim();
arr[5] = document.querySelectorAll(".tag.tag-left")[5].innerText.trim();
arr[6] = document.querySelectorAll(".tag.tag-left")[6].innerText.trim();
arr[7] = document.querySelectorAll(".tag.tag-left")[7].innerText.trim();
@kern-me
kern-me / apple_numbers_syntax.scpt
Last active November 9, 2018 18:07
Apple Numbers : Common Syntax
##########################
# DATA REFERENCING
##########################
# Is this word duplicated anywhere in a column of this sheet?
IF(COUNTIF(A,A1)>1,"Yes","no")
# Grab values from the another sheet
SheetName::Table 1::$A1
# Is this word duplicated somewhere in another sheet?
@kern-me
kern-me / google-sheets-filter-multiple-conditions.js
Last active January 17, 2020 15:24
Google Sheets - Filtering Multiple Conditions
// regexmatch(columnRange, "(?i)x|y|z")
regexmatch(A:A, "(?i)term1|term2|term3|term4|term5")
@kern-me
kern-me / outlook-table-rules.html
Created March 8, 2020 00:39
Outlook Table Border Collapsing
<!--[if (gte mso 9)|(IE)]>
<style type="text/css">
table {
border-collapse: collapse;
border-spacing: 0;
mso-line-height-rule: exactly;
mso-margin-bottom-alt: 0;
mso-margin-top-alt: 0;
mso-table-lspace: 0pt; mso-table-rspace: 0pt;}
</style>