Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cxa's full-sized avatar
🦥

realazy cxa

🦥
View GitHub Profile
@stephancasas
stephancasas / core-ax.jxa.js
Last active February 15, 2024 01:13
JXA Core AX Framework Bindings
#!/usr/bin/env osascript -l JavaScript
function run() {
const VSCode = axApp('com.microsoft.VSCode');
const window = axGet(VSCode, 'AXWindows')[0];
return axWindowSetBounds(window, 200, 200, 1200, 1400);
}
/**
@douglashill
douglashill / explore-localisation-glossaries.swift
Last active August 24, 2022 05:39
Prints out translations from Apple’s glossary files matching text in a supplied English .strings file. Read more: https://douglashill.co/localisation-using-apples-glossaries/
#! /usr/bin/swift
// Douglas Hill, March 2020
// Prints out translations from Apple’s glossary files matching text in a supplied English .strings file.
// More detail in the article at https://douglashill.co/localisation-using-apples-glossaries/
import Foundation
let stringsSource = URL(fileURLWithPath: "PUT THE PATH TO YOUR ENGLISH .strings FILE HERE")
@alanthird
alanthird / noto-fonts.el
Last active November 2, 2023 14:22
Set up Noto fonts in Emacs
;; Provided by Sebastian Urban
;; More information at https://idiocy.org/emacs-fonts-and-fontsets.html
(set-fontset-font "fontset-default" 'adlam "Noto Sans Adlam")
(set-fontset-font "fontset-default" 'anatolian "Noto Sans Anatolian Hieroglyphs")
(set-fontset-font "fontset-default" 'arabic "Noto Sans Arabic")
(set-fontset-font "fontset-default" 'aramaic "Noto Sans Imperial Aramaic Regular")
(set-fontset-font "fontset-default" 'armenian "Noto Sans Armenian")
(set-fontset-font "fontset-default" 'avestan "Noto Sans Avestan")
(set-fontset-font "fontset-default" 'balinese "Noto Sans Balinese")
@mbuhot
mbuhot / FSharpConverters.fs
Last active November 5, 2023 20:16
System.Text.Json converters for F# Option, List and Map types
namespace System.Text.Json
open System
open System.Collections.Generic
open System.Text.Json.Serialization
// Converts Option<T> to/from JSON by projecting to null or T
type OptionValueConverter<'T>() =
inherit JsonConverter<'T option>()
@jdh30
jdh30 / JsonParser.fs
Last active January 30, 2024 14:06
Simple JSON parser written in F# using active patterns
type Json =
| Null
| Bool of bool
| Number of float
| String of string
| Array of Json list
| Object of (string * Json) list
type Bracket = Open | Close
@douglashill
douglashill / KeyboardTableView.swift
Last active March 30, 2023 22:01
A UITableView that allows navigation and selection using a hardware keyboard.
// Douglas Hill, December 2018
// Made for https://douglashill.co/reading-app/
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit
import UIKit
/// A table view that allows navigation and selection using a hardware keyboard.
/// Only supports a single section.
class KeyboardTableView: UITableView {
// These properties may be set or overridden to provide discoverability titles for key commands.
@steipete
steipete / PSPDFEnvironment.m
Last active March 26, 2019 09:39
PSPDFApplicationIsTerminating - detect application termination on iOS and macOS. License: MIT. Taken out of the commercial PSPDFKit PDF SDK. http://pspdfkit.com
static _Atomic(BOOL) _applicationWillTerminate = NO;
__attribute__((constructor)) static void PSPDFInstallAppWillTerminateHandler(void) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[NSNotificationCenter.defaultCenter addObserverForName:UIApplicationWillTerminateNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
_applicationWillTerminate = YES;
PSPDFLogWarning(@"Application shutdown event detected.");
}];
});
}
@pepasflo
pepasflo / .gitignore
Last active October 22, 2023 12:06
Scripts for encrypting / decrypting secrets (to prevent them from being accidentally checked into git)
secrets/
func zalgo(_ string: String, intensity: Int = 5) -> String {
let combiningDiacriticMarks = 0x0300...0x036f
let latinAlphabetUppercase = 0x0041...0x005a
let latinAlphabetLowercase = 0x0061...0x007a
var output: [UnicodeScalar] = []
for scalar in string.unicodeScalars {
output.append(scalar)
guard (latinAlphabetUppercase).contains(numericCast(scalar.value)) ||
(latinAlphabetLowercase).contains(numericCast(scalar.value))
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 16, 2024 01:02
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse