Skip to content

Instantly share code, notes, and snippets.

@mikaello
mikaello / jsChrome.scpt
Last active October 28, 2022 04:56
Pipe JS from a file in terminal to be executed in Chrome via AppleScript
(* Save this script as (e.g.) jsChrome.scpt and run it as follows
in a terminal:
osascript jsChrome.scpt someJSFile.js
The content of someJSFile.js will now be run in the active tab of
what is considered your "window 1" of a running Chrome instance.
If this is your first time running JavaScript in Google Chrome from
AppleScript, you will need to enable this in
@jldavid
jldavid / OutlookCommandReturnFix.sh
Last active September 10, 2021 15:17
FIX: Prevent Outlook for Mac from Auto-Sending Emails with Command+Return
defaults write com.microsoft.Outlook NSUserKeyEquivalents -dict-add "Send" "\U200B"
@helpermethod
helpermethod / pipe.groovy
Last active March 11, 2020 11:37
A pipe function in 7 lines of Groovy
def pipe(fn, ...fns) {
return {
fns.inject(fn(it)) { acc, value ->
value(acc)
}
}
}
@edenwaith
edenwaith / CountOpenChromeTabs.scpt
Last active February 1, 2025 03:39
AppleScript: Count the number of open tabs in Google Chrome
-- CountOpenChromeTabs.scpt
-- Author: Chad Armstrong
-- Date: 30 August 2019
-- Description: Count the number of open tabs in Google Chrome
-- To run from CLI: osascript CountOpenChromeTabs.scpt
-- To create an alias command:
-- In ~/.bash_profile, add the line: alias counttabs='osascript ~/Projects/Scripts/CountOpenChromeTabs.scpt'
-- Refresh the bash shell environment: source ~/.bash_profile
tell application "Google Chrome"
@sebsto
sebsto / code-stack.ts
Last active October 12, 2023 13:12
CDK Create EC2 instace in private subnet. Install Nginx.
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/core');
import { Fn, Tag, Resource } from '@aws-cdk/core';
import { AmazonLinuxImage, UserData, InstanceType } from '@aws-cdk/aws-ec2';
import { Role, ServicePrincipal, ManagedPolicy, CfnInstanceProfile } from '@aws-cdk/aws-iam'
/**
* Create my own Ec2 resource and Ec2 props as these are not yet defined in CDK
* These classes abstract low level details from CloudFormation
@abbottdev
abbottdev / app.ts
Created June 11, 2019 13:52
Typescript example for creating aws cdk resources using a swaggerfile
import * as cdk from '@aws-cdk/cdk';
import * as SwaggerParser from "swagger-parser";
import convertSwaggerToCdkRestApi from "./swaggerHelper";
SwaggerParser
.parse("./swagger.yaml")
.then(swagger => {
const app = new cdk.App();
let apiGateway = new apigateway.RestApi(this, "My Rest API", {
@23maverick23
23maverick23 / apps.lua
Created October 1, 2018 14:57
OSX: Hammerspoon scripts
apps = {}
apps.launchers = {
{
name="Home - Coding",
description="Launch apps for coding.",
apps={
"Sublime Text",
"iTerm",
"Dash"
@santiagobasulto
santiagobasulto / README.md
Last active February 17, 2025 16:05
Download HumbleBundle books in batch with a simple Python script.

Download HumbleBundle books

This is a quick Python script I wrote to download HumbleBundle books in batch. I bought the amazing Machine Learning by O'Reilly bundle. There were 15 books to download, with 3 different file formats per book. So I scratched a quick script to download all of them in batch.

(Final Result: books downloaded)

@ddacunha
ddacunha / OutlookSelectNext.scpt
Created June 20, 2018 01:25
[AppleScript] Select next message in Outlook 2016 (in Javascript)
var outlook = Application('Microsoft Outlook')
var selectedMessageList = outlook.currentMessages()
for ( m of selectedMessageList) {
console.log( "selectedMessageList: " + m.id())
}
var lastSelectedMessage = selectedMessageList[selectedMessageList.length-1] //set lastMessage to last item of msgList
console.log (lastSelectedMessage.subject())
@reacocard
reacocard / retry.sh
Last active September 18, 2023 15:32
Bash retry function with exponential backoff.
#!/usr/bin/env bash
# This software is freely available under the Apache 2.0 license.
# Full license available here: https://www.apache.org/licenses/LICENSE-2.0.txt
set -o errexit
set -o nounset
set -o pipefail
# Retry a command on a particular exit code, up to a max number of attempts,