Skip to content

Instantly share code, notes, and snippets.

View danielpunkass's full-sized avatar

Daniel Jalkut danielpunkass

View GitHub Profile
@danielpunkass
danielpunkass / RSDimensionHuggingTextField.swift
Last active April 17, 2024 13:17
NSTextField subclasses that grow/shrink their width or height to fit text content
//
// RSDimensionHuggingTextField.swift
// RSUIKit
//
// Created by Daniel Jalkut on 6/13/18.
//
import Cocoa
// You probably want to use one of RSHeightHuggingTextField or RSWidthHuggingTextField, below
tell application "System Events"
set frontProcess to first process whose frontmost is true
-- When it's down to just Finder and the front process, we have to switch
-- to the Finder first to get the front process to hide itself. Furthermore,
-- the Finder will not be listed as among the visible processes unless it
-- has open windows, so treat a condition of 2 *or fewer* visible apps as
-- meaning the Finder should be activated before hiding the front process.
@danielpunkass
danielpunkass / XcodeBuildLogParser
Created January 16, 2015 14:29
Example configuration file for Jenkins's build log parser plugin, including some rules for Xcode quirks
# don't treat any of these as errors, warnings or info
ok /setenv /
# ignore TidyXML warnings
ok /line [0-9]+ column [0-9]+ - Error:/
ok /line [0-9]+ column [0-9]+ - Warning:/
ok /[0-9]+ warning.+ error.+ found!/
# ignore weird warnings about build variables in Info.plist:
# e.g. "warning: ignoring operator ':rfc1034Identifier' on 'RSWebClientCore' for macro 'PRODUCT_NAME'"
@danielpunkass
danielpunkass / gray.c
Created April 9, 2019 12:22
Standalone tool using private Apple framework to toggle display grayscale mode
#include <stdio.h>
// Compile with cc -o gray gray.c -framework UniversalAccess -F /System/Library/PrivateFrameworks
extern void UAGrayscaleSetEnabled(int isEnabled);
extern int UAGrayscaleIsEnabled();
int main() {
UAGrayscaleSetEnabled(!UAGrayscaleIsEnabled());
}
//
// UIView+RSKeyboardLayoutGuide.swift
// RSTouchUIKit
//
// Created by Daniel Jalkut on 12/23/18.
//
import UIKit
// Extends UIView to expose a keyboardLayoutGuide property that can be used to tie a view controller's content
@danielpunkass
danielpunkass / LMWindow.m
Created March 25, 2021 14:12 — forked from mittsh/LMWindow.m
How to debug your key view loop: highlights
/*
* Copyright (c) 2013 Micha Mazaheri
* Released under the MIT License: http://opensource.org/licenses/MIT
*/
#define LMWindowDEBUGResponders
#ifdef LMWindowDEBUGResponders
static BOOL _showFirstResponderOverlay = YES;
#endif
-- Line up a Python script for dynamically loading the private framework
-- and invoking the required private methods to get current grayscale mode
-- and set it to the opposite value.
set toggleGrayScript to "python -c 'from ctypes import cdll
lib = cdll.LoadLibrary(\"/System/Library/PrivateFrameworks/UniversalAccess.framework/UniversalAccess\")
lib.UAGrayscaleSetEnabled(lib.UAGrayscaleIsEnabled() == 0)
'"
do shell script toggleGrayScript
@danielpunkass
danielpunkass / spamhaus-check.py
Created December 14, 2012 18:18
Spamhaus periodically places some IP addresses back on their "PBL" which leads certain mail exchanges to treat mail originating from the IP address as suspicious. If you run a mail server that ends up on this PBL you'll probably just notice that certain mail stops making it all the way to recipients. This python script checks the block status fo…
#!/usr/bin/python
import os
import sys
import urllib
# Change this to match your mail server's REVERSE static IP address
staticIPAddress = "1.0.0.127"
# Change this to an email address you don't mind sending to and from for the notice alert delivery
@danielpunkass
danielpunkass / xcbuild-debugging-tricks.md
Created September 14, 2018 12:42 — forked from ddunbar/xcbuild-debugging-tricks.md
Xcode new build system debugging tricks

New Build System Tricks

Command Line

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
# THIS DOESNT WORK YET: xcbuild openIDEConsole  # … then switch to Xcode ➡️
xcbuild showSpecs
xcbuild build <foo.pif> [—target <target>]
@danielpunkass
danielpunkass / fsa.py
Last active July 22, 2018 02:50
A simple lldb module for adding an "fsa" command to inject F-Script anywhere into any process
"""
Automate loading of F-Script Anywhere into any app.
By Daniel Jalkut - @danielpunkass - http://indiestack.com/
To set up:
0. Make sure you have FScript.framework installed in /Library/Frameworks (http://www.fscript.org)
1. Copy this script to ~/.lldb/fsa.py
2. Add the following to your ~/.lldbinit file: