Skip to content

Instantly share code, notes, and snippets.

View babyking's full-sized avatar

Baby King babyking

View GitHub Profile
@hrldcpr
hrldcpr / tree.md
Last active May 1, 2024 00:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@ABridoux
ABridoux / WindowPosition.swift
Last active April 14, 2024 12:01
Logic to easily set a NSWindow's origin horizontally and vertically in a screen (AppKit and SwiftUI)
// Free to use
// Written by Alexis Bridoux - https://github.com/ABridoux
import AppKit
#if canImport(SwiftUI)
import SwiftUI
#endif
// MARK: Model
@nrk
nrk / command.txt
Created April 2, 2012 19:19
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
@n8henrie
n8henrie / txt_to_reminders.applescript
Last active March 11, 2024 17:04
Demonstration of using AppleScript with Reminders.app
--taken from http://benguild.com/2012/04/11/how-to-import-tasks-to-do-items-into-ios-reminders/#comment-1346894559
--set theFileContents to (read file "Users:n8henrie:Desktop:Reminders.txt") -- Change this to the path to your downloaded text file with your tasks in it! (Note the : instead of a / between folders) Or, just name them Reminders.txt and put them in your downloads folder
--set theLines to paragraphs of theFileContents
set theLines to {"task name 1", "task name 2"}
repeat with eachLine in theLines
tell application "Reminders"
set mylist to list "Your List Name"
tell mylist
make new reminder at end with properties {name:eachLine, due date:date "7/10/2014 3:00 PM"}
@csharpforevermore
csharpforevermore / AuthoHotKeyList.txt
Created April 27, 2014 15:50
AutoHotKey Key List
Key Name Resulting Keystroke
{F1} - {F24} Function keys. For example: {F12} is the F12 key.
{!} !
{#} #
{+} +
{^} ^
{{} {
{}} }
{Enter} ENTER key on the main keyboard
{Escape} or {Esc} ESCAPE
@ttscoff
ttscoff / init.lua
Last active January 9, 2024 23:44
Hammerspoon config examples for hyper key
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
-- Trigger existing hyper key shortcuts
k:bind({}, 'm', nil, function() hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"}, 'm') end)
-- OR build your own
launch = function(appname)
@andyfowler
andyfowler / .vimrc
Created September 5, 2011 18:08
Swap iTerm2 cursors in vim insert mode when using tmux
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
@haozes
haozes / update_whatsnew.py
Last active October 29, 2023 09:10
Update App Connect whats new info
# need install asconnect: pip install asconnect, and openai: pip install openai
import asconnect
import os
import openai
#api key: https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api
APPCONN_APIKEY_ID = "xxxxx"
APPCONN_ISSUER_ID = "xxxxxxx"
APPCONN_KEY_FILE = "xxxxx.p8"
@quietcricket
quietcricket / Global keyboard hook for OSX
Created January 8, 2014 07:42
OSX global keyboard hook. Requires root privileges.
// alterkeys.c
// http://osxbook.com
//
// Complile using the following command line:
// gcc -Wall -o alterkeys alterkeys.c -framework ApplicationServices
//
// You need superuser privileges to create the event tap, unless accessibility
// is enabled. To do so, select the "Enable access for assistive devices"
// checkbox in the Universal Access system preference pane.
@wisaruthk
wisaruthk / FVRInAppPurchaseVC.swift
Last active July 15, 2023 16:35
iOS In App Purchase Example with appusername
//
// FVRInAppPurchaseVC.swift
// favroutes
//
// Created by wisaruthk on 10/8/2558 BE.
// Copyright © 2558 kojo. All rights reserved.
//
import UIKit
import StoreKit