Skip to content

Instantly share code, notes, and snippets.

@jwilling
jwilling / JNWThrottledBlock.h
Last active October 26, 2020 17:02
Simple throttling of blocks using dispatch sources.
#import <Foundation/Foundation.h>
@interface JNWThrottledBlock : NSObject
// Runs the block after the buffer time _only_ if another call with the same identifier is not received
// within the buffer time. If a new call is received within that time period the buffer will be reset.
// The block will be run on the main queue.
//
// Identifier and block must not be nil.
+ (void)runBlock:(void (^)())block withIdentifier:(NSString *)identifier throttle:(CFTimeInterval)bufferTime;
@eahrold
eahrold / closeapp.py
Created January 14, 2014 18:00
close a running application with python and NSWorkspace
#!/usr/bin/python
from AppKit import NSWorkspace
def closeRunningApplication(bundle_id):
ws = NSWorkspace.sharedWorkspace()
runningApps = ws.runningApplications()
for i in runningApps:
if i.bundleIdentifier() == bundle_id:
i.terminate()
@stephenlb
stephenlb / animated-gif.md
Last active October 31, 2020 22:57
DIY How to make your own HD Animated GIF Generator

HD Animated GIF Generator

You can make your own HD animated GIF generator.
Follow along with these commands to get started.

HD Animated GIF Generator

git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
@damuellen
damuellen / MiniApp.swift
Last active July 3, 2022 17:43
Minimal Swift App
#!/usr/bin/swift
import AppKit
let application = NSApplication.shared
let fileOpenPanel = NSOpenPanel(), fileSavePanel = NSSavePanel()
let window: NSWindow = { window in
window.setContentSize(NSSize(width:800, height:600))
window.styleMask = [.titled, .closable, .miniaturizable]
@swillits
swillits / Keycodes.swift
Last active June 27, 2024 04:18
Swift Keyboard Keycodes
struct Keycode {
// Layout-independent Keys
// eg.These key codes are always the same key on all layouts.
static let returnKey : UInt16 = 0x24
static let enter : UInt16 = 0x4C
static let tab : UInt16 = 0x30
static let space : UInt16 = 0x31
static let delete : UInt16 = 0x33
static let escape : UInt16 = 0x35
@stek29
stek29 / Google Earth WP.md
Last active April 18, 2021 20:13
Google Earth View wallpapers

Downloads all wallpapers from https://g.co/ev and annotates them with nice and clean link (like g.co/ev/1207)

imageIds.json were taken from imageIds.js from Google Chrome Extension json_to_img.py takes path to imageIds.json as first argument and downloads all images in it annotate.sh annotates $1

also see launcher.sh for example

@plroebuck
plroebuck / svg2icns.bash
Last active January 23, 2024 07:03
Create ICNS file from SVG file (with ImageMagick)
#! /bin/bash
###
### svg2icns.bash
### Create ICNS file from SVG
###
### See also:
### <https://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil#39678276>
### <https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html>
###
@serg0x
serg0x / material-design-shadows.css
Last active July 7, 2023 13:33
Google material design elevation system shadows as css. Based on https://material.io/design/environment/elevation.html#default-elevations Exported with Sketchapp from the Google material design theme editor plugin "Baseline" theme.
/* Shadow 0dp */
box-shadow: none;
/* Shadow 1dp */
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.14), 0 2px 1px -1px rgba(0,0,0,0.12), 0 1px 3px 0 rgba(0,0,0,0.20);
/* Shadow 2dp */
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.20);
/* Shadow 3dp */
@NoahCardoza
NoahCardoza / getOpenTabs.sh
Last active March 21, 2024 10:16
[OSX] Lists the URLs of all the open tabs in a specified browser.
#!/bin/bash
# args: browser
# example: ./getOpenTabs.sh "Brave Browser"
# credits:
# https://gist.github.com/samyk/65c12468686707b388ec43710430a421
# TODO:
# validate args
# don't open app if not already open