This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RSVerticallyCenteredTextFieldCell: NSTextFieldCell { | |
var mIsEditingOrSelecting:Bool = false | |
override func drawingRect(forBounds theRect: NSRect) -> NSRect { | |
//Get the parent's idea of where we should draw | |
var newRect:NSRect = super.drawingRect(forBounds: theRect) | |
// When the text field is being edited or selected, we have to turn off the magic because it screws up | |
// the configuration of the field editor. We sneak around this by intercepting selectWithFrame and editWithFrame and sneaking a | |
// reduced, centered rect in at the last minute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tuple(tuple): | |
def __getattr__(self, name): | |
def _int(val): | |
try: | |
return int(val) | |
except ValueError: | |
return False | |
if not name.startswith('_') or not _int(name[1:]): | |
raise AttributeError("'tuple' object has no attribute '%s'" % name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first install pygmentize to the mac OS X or macOS system with the built-in python | |
sudo easy_install Pygments | |
# then add alias to your ~/.bash_profile or ~/.bashrc or ~/.zshrc etc. | |
alias pcat='pygmentize -f terminal256 -O style=native -g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Put this file to /etc/pf.conf | |
# 2. Install init boot scripts using IceFloor then - http://www.hanynet.com/icefloor/ | |
# I tried to use IceFloor to configure everything but it didn't work very well. | |
# 3. Once done, you can confirm the rules were loaded with 'sudo pfctl -sr' | |
# 4. At System Preferences -> Security -> Firewall -> Firewall Options, | |
# check 'Block all incoming connections' to prevent annoying per-app dialogs. | |
set skip on lo0 | |
set block-policy drop |
[ Update 2025-03-24: Commenting is disabled permanently. Previous comments are archived at web.archive.org. ]
Most of the terminal emulators auto-detect when a URL appears onscreen and allow to conveniently open them (e.g. via Ctrl+click or Cmd+click, or the right click menu).
It was, however, not possible until now for arbitrary text to point to URLs, just as on webpages.
- Install XQuartz: https://www.xquartz.org/
- Launch XQuartz. Under the XQuartz menu, select Preferences
- Go to the security tab and ensure "Allow connections from network clients" is checked.
- Run
xhost + ${hostname}
to allow connections to the macOS host * - Setup a HOSTNAME env var
export HOSTNAME=`hostname`
* - Add the following to your docker-compose:
environment:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: HashMap data structure | |
public struct HashMap<Key: Hashable, Value> { | |
typealias Element = (key: Key, value: Value) | |
var arraySize: Int | |
var numberInserted = 0 | |
var array: [Element?] | |
var loadFactor: Double { | |
return Double(numberInserted) / Double(arraySize) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Logging(object): | |
__name__ = 'logger.info(1)' | |
plist = '/System/Library/Preferences/Logging/Subsystems/' | |
def __init__(__name__, plist, *args, **kwargs): | |
super(getLogger/, self).__init__() | |
logger.info('Input parameters:\n' | |
'accessibility: "{com.apple.Accessibility.plist}"\n' |