Skip to content

Instantly share code, notes, and snippets.

View SamusAranX's full-sized avatar

SamusAranX

  • Germany
  • 06:27 (UTC +01:00)
View GitHub Profile
@insidegui
insidegui / lsremovearchives.sh
Created December 21, 2021 18:28
Remove Xcode app archives from macOS LaunchServices database
#!/bin/bash
# Recursivelly removes all apps from your Xcode archives from the LaunchServices database, preventing them from being used for widgets, launch at login, etc.
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -R -f -u $HOME/Library/Developer/Xcode/Archives
@kiding
kiding / HDRGainMap.swift
Last active October 29, 2024 14:26
Extracting HDR Gain Map from iOS 14.1+ (iPhone 12+) photos
import UIKit
import MobileCoreServices.UTCoreTypes
if #available(iOS 14.1, *) {
let input = Bundle.main.url(forResource: "IMG_0037", withExtension: "HEIC")!
let output = FileManager().temporaryDirectory.appendingPathComponent("IMG_0037.GAIN_MAP.BMP")
let source = CGImageSourceCreateWithURL(input as CFURL, nil)!
// urn:com:apple:photo:2020:aux:hdrgainmap
let dataInfo = CGImageSourceCopyAuxiliaryDataInfoAtIndex(source, 0, kCGImageAuxiliaryDataTypeHDRGainMap)! as Dictionary
@ollieatkinson
ollieatkinson / Dictionary+KeyPath.swift
Last active January 7, 2024 03:30
KeyPath to get/set from a Swift JSON object ([String: Any] or [Any])
import Foundation
extension Dictionary where Key == String, Value == Any {
public subscript(keyPath: JSON.Path.Index...) -> Value? {
get { self[keyPath: .init(path: keyPath)] }
set { self[keyPath: .init(path: keyPath)] = newValue }
}
public subscript(keyPath keyPath: JSON.Path) -> Value? {
import time
import psutil
import multiprocessing as mp
from multiprocessing import Process
def f(thread, duty, freq, q):
p = psutil.Process()
p.cpu_affinity([thread])
while True:
#include <cstdio>
#include <cstdint>
// bit layout:
// +-1-+
// 8 2
// +-4-+
bool matchHorizontal(uint8_t left, uint8_t right)
{
@marcoarment
marcoarment / apns_jwt_token.php
Last active October 14, 2024 13:36
Generate ES256 JWT tokens for Apple Push Notification Service (APNS) in PHP
<?php
function base64url_encode($binary_data) { return strtr(rtrim(base64_encode($binary_data), '='), '+/', '-_'); }
function apns_jwt_token($team_id, $key_id, $private_key_pem_str)
{
if (! function_exists('openssl_get_md_methods') || ! in_array('sha256', openssl_get_md_methods())) throw new Exception('Requires openssl with sha256 support');
$private_key = openssl_pkey_get_private($private_key_pem_str);
if (! $private_key) throw new Exception('Cannot decode private key');
@schovi
schovi / brightness.js
Last active September 24, 2024 11:33
Small scripts to boost twitch volume beyond 100% or change brightness of video
// To use this, open console (developer tools), change the brigtness you want, paste it there and run
// 1 = 100% ...
twitchBrightness(1.2)
function twitchBrightness(amount) {
const video = document.querySelector('video')
video.style.filter = `brightness(${amount * 100}%)`
}
@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.
Replace 104 bytes at $3204 with the following.
This stores the animated color palette for the letters, and the static color palette for the shimmer.
16 70 E0 01 1E 68 B0 01 1F 7C F0 01 0B 64 E0 01
1D 50 60 01 1F 7C F0 01 0B 64 E0 01 1D 50 60 01
1F 7C F0 01 0B 64 E0 01 1D 50 60 01 1F 7C F0 01
0B 64 E0 01 1D 50 60 01 1F 7C F0 01 0B 64 E0 01
1D 50 60 01 1F 7C F0 01 0B 64 E0 01 1D 50 60 01
1F 7C F0 01 1F 7C F0 01 1F 7C F0 01 1F 7C F0 01
1F 00 FF 7F F7 5E EF 3D
@uobikiemukot
uobikiemukot / emoji.go
Created December 11, 2018 07:58
emoji and text renderer
package main
import (
"bufio"
"bytes"
"fmt"
"image"
"image/jpeg"
_ "image/png"
"io"