Skip to content

Instantly share code, notes, and snippets.

View username0x0a's full-sized avatar
🐵
🙉 🙈 🙊

Michal Zelinka username0x0a

🐵
🙉 🙈 🙊
View GitHub Profile
@username0x0a
username0x0a / plisten.rb
Created October 27, 2023 23:49
Simple Ruby script listening to `~/Library/Preferences` & printing the changes as UserDefaults change
#!/usr/bin/env ruby
require 'diffy' # gem install diffy
require 'listen' # gem install listen
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
@username0x0a
username0x0a / twitter_de_x_ifier.css
Created July 24, 2023 20:28
Revert of Twitter's X logo
h1[role="heading"] {
padding-top: 2em;
}
h1[role="heading"] svg g {
opacity: 0;
}
h1[role="heading"] svg {
@username0x0a
username0x0a / system_settings_differ.rb
Created June 19, 2023 19:27
Simple Ruby script that allows you to watch Property list changes (f.e. in `~/Library/Preferences`) that you can catch, export to a dot file & synchronise between multiple machines. 👍
#!/usr/bin/env ruby
# Prerequisities:
# - brew install fswawtch
# - gem install diffy
# Usage:
# cd ~/Library/Preferences; ruby system_settings_differ.rb
require 'pp'
require 'pty'
@username0x0a
username0x0a / Safari15StableBackFwdButtons.m
Created October 2, 2021 18:01
Safari 15 Stable Back & Forward buttons in the single-line Unified tab bar
#import <Cocoa/Cocoa.h>
#import <objc/runtime.h>
@interface Injector: NSView @end
@implementation Injector
+ (void)load {
@username0x0a
username0x0a / UIScrollView+ScrollbarDraggingDetect.m
Last active November 22, 2020 18:13
UIScrollView category usable for scrollbar dragging detection.
@interface UIScrollView ()
- (BOOL)_isScrubbing;
@end
@implementation UIScrollView (ScrollbarDraggingDetect)
/// A bit complicated and sophisticated subview introspection to detect whether
/// the vertical scroll indicator is “expanded for direct manipulation” (= being
/// dragged) using private accessors reads and some clang diagnostics pushing.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
+ (void)initialize
{
[super initialize];
#if __IPHONE_13_0
// IOS-13-TODO: Work-around for Facebook SDK to force-use Safari auth session
// instead of AuthServices session as this requires specific
@username0x0a
username0x0a / exportColours.rb
Last active November 22, 2020 18:12
Asset Catalog HEX colours export
# Path: .../Colors.xcassets
# Usage: ruby exportColours.rb
require 'json'
def parseHex(inp)
return inp[2..-1] if inp.index('0x') == 0
ret = ((inp.to_f) * 255).to_i.to_s(16)
ret = '0'+ ret if ret.length == 1
return ret
@username0x0a
username0x0a / Swift5_String+Ex.swift
Last active November 22, 2020 17:57
Life-saving String extension for Swift >= 5.0 easing the split–filter–join flows.
import Foundation
#if swift(>=5.0)
extension StringProtocol where Index == String.Index {
func split(string str: String) -> [Substring] {
var si = self.startIndex
@username0x0a
username0x0a / FoundationMutabilityType.m
Last active November 22, 2020 18:12
Very useful macro to get around some mutable/immutable assignment issues for basic Foundation types.
#import <Foundation/Foundation.h>
@interface NSString (FoundationMutabilityType)
- (NSString *)copy;
- (NSMutableString *)mutableCopy;
@end
@username0x0a
username0x0a / enforcevpnhost.rb
Last active November 22, 2020 18:12
Simple macOS Ruby script allowing to enforce VPN use for specified IPs and hostnames in case you're not into sending all your traffic via the connected VPN
#!/usr/bin/env ruby
# Check for arguments
def check_ip_ip_range(inp)
return inp =~ /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\/[0-9]{1,2})?$/ ? true : false
end
if ARGV.count < 1 then
puts "Usage: enforcevpnhost [ip4|ip4net|hostname]"