Skip to content

Instantly share code, notes, and snippets.

-- Create a new task based on the currently selected message in Airmail
-- When Script is run (I suggest FastScripts https://red-sweater.com/fastscripts/) A new line will be added to the taskpaper file of your choice.
-- Quite a lot modified to input text into a plain text file like used by taskpaper. Originally based somewhere back in time on Efficient Computing's AppleScript: http://efficientcomputing.commons.gc.cuny.edu/2012/03/17/copy-email-message-in-mail-app-to-evernote-applescript/
tell application "Airmail 2"
log "get selected messages"
set theSelection to selected messages
--loop through all selected messages
@sirtimbly
sirtimbly / accessibility.md
Created June 26, 2017 18:00
Accessibility Best Practices

Accessibility

Not all of our users will have the same abilities that we assume. There are several ways we can improve our product interface to make it accessible to more users. These are considered best practices and usually do not require a lot of time and effort.

The viewport on mobile

Do not prevent users from zooming a page in and out on a mobile device, this is an accessibility issue.

Color contrast

@sirtimbly
sirtimbly / sam-snippet-1.ts
Created November 29, 2017 16:06
sam-snippet-1.ts
TodoList: (props: TodoListProps) => {
return h("ul.all-todos", props.list.map((item: string) => {
return h("input.todo", {
type: "checkbox",
value: item.id,
checked: item.done,
classes: { 'strikethrough': item.done },
onchange: this.actions.changeTodoItem,
});
return $.div.border.h({
classes: {
"bg-aqua": isActive,
"blue": isActive,
"bg-gray": !isActive,
"red": !isValid,
}}, []);
return $.button.circle.h({
classes: new CC().when(model.viewing === view)
.bgAqua.blue
.otherwise().bgSilver.red
.toObj,
}, ["OK"]);
const configuration: AppConfiguration<CustomProps, ViewComponents> = {
action: (m: Model<CustomProps>): ViewActions<CustomProps> => new AppViewActions(m),
model: {
validate: (props: CustomProps): Error[] => {
return []; // TODO
},
},
state: {
calculate: (props: CustomProps): CustomProps => {
props.hasUserData = ((props.gender === "MALE" || props.gender === "FEMALE") && props.weight > 0);
const app = new App<CalculationProps, ViewComponents>(container, {
locationState: "CO",
viewing: Views.HOME,
weight: 150,
} as CalculationProps);
app.init([
{
comp: app.views.ViewLoader,
el: document.getElementById("mainapp"),
}]);
@sirtimbly
sirtimbly / getIPLocation.ts
Created March 26, 2018 02:38
async network call
public getIPLocation = () => {
const context = this;
const req = axios.get("//freegeoip.net/json/")
.then((res) => {
if (res.data.region_code && res.data.region_code.length === 2) {
context.data.locationState = res.data.region_code;
}
context.renderer(context.data);
})
.catch((x) => { context.renderer(context.data); });
import { FRETS } from "frets";