Skip to content

Instantly share code, notes, and snippets.

@samuelbalogh
samuelbalogh / README.md
Created May 30, 2021 18:28 — forked from ascendbruce/README.md
Use mac style keyboard shortcuts on Windows with AutoHotkey (ahk) script

Use (most) macOS style keyboard shortcuts on Windows

Make Windows PC's shortcut act like macOS (Mac OS X)

With this AutoHotKey script, you can use most macOS style shortcuts (eg, cmd+c, cmd+v, ...) on Windows with a standard PC keyboard.

Note that:

  1. you shouldn't change the modifier keys mapping with keyboard DIP. This script assumes you use a standard PC keyboard layout, and wish to use shortcuts as if it was a mac keyboard layout.
  2. To use cmd + shift + ↑ / ↓ / ← / → (select text between cursor and top / bottom / beginning of line / end of line), You should disable the Between input languages shotcut from Control Panel\Clock, Language, and Region\Language\Advanced settings > Change lanugage bar hot keys due to conflicting.
WITH
invoices_for_cancelled_projects AS
(SELECT * FROM invoices, projects
WHERE projects.status = 'cancelled'
AND invoices.project_id = projects.id),
approved_invoices_in_usd AS
(SELECT * FROM invoices
WHERE currency ='USD'
AND status = 'approved')
WITH invoices_for_cancelled_projects AS
(SELECT * FROM invoices, projects
WHERE projects.status = 'cancelled'
AND invoices.project_id = projects.id)
UPDATE invoices_for_cancelled_projects
SET invoices.status = 'cancelled'
FROM invoices_for_cancelled_projects
@samuelbalogh
samuelbalogh / invoice_project
Last active June 19, 2018 11:51
migration with common table expressions
WITH
migrated_invoices AS (
UPDATE invoices
SET invoice_type='cutting_edge',
WHERE invoice_type='oldie'
RETURNING id, status, amount, project_id
),
invoice_amounts_by_status AS (SELECT
project_id AS invoice_project_id,
sum((CASE WHEN (migrated_invoices.status = 'paid')
@samuelbalogh
samuelbalogh / invoice_migration.py
Last active June 19, 2018 12:00
pseudocode for how not to perform datamigrations with SQLAclhemy
import sqlalchemy as sa
invoices_table = sa.Table('invoices', sa.Metadata())
invoices = select([invoices_table]).where(invoice_type='oldie')
for invoice in old_invoices:
invoices_table.update(
).where(id=invoice.id).values(invoice_type='cutting_edge')
@samuelbalogh
samuelbalogh / isPal.py
Last active October 31, 2016 14:06
Returns true if argument is a palindrome.
def isPal(s):
reverse = s[::-1]
return s == reverse
@samuelbalogh
samuelbalogh / reverse.py
Last active September 12, 2016 10:07
Return palindrome of string using recursion
from test import testEqual
def reverse(s):
if len(s) <= 1:
return s
else:
return s[-1] + reverse(s[:-1])
testEqual(reverse("hello"),"olleh")
testEqual(reverse("l"),"l")
testEqual(reverse("follow"),"wollof")