Skip to content

Instantly share code, notes, and snippets.

View danielpunkass's full-sized avatar

Daniel Jalkut danielpunkass

View GitHub Profile
@danielpunkass
danielpunkass / TestDate.command
Created May 26, 2015 17:02
Testing locale and date formatting
#!/usr/bin/python
from Foundation import *
form = NSDateFormatter.alloc().init()
form.setFormatterBehavior_(1040)
form.setDateFormat_("yyyyMMdd'T'HH:mm:ss'Z")
form.setTimeZone_(NSTimeZone.timeZoneForSecondsFromGMT_(0))
print "Implied locale is " + NSLocale.currentLocale().localeIdentifier()
print form.stringFromDate_(NSDate.date())
@danielpunkass
danielpunkass / TestDate.py
Last active August 29, 2015 14:21
Example of NSDateformatter behaving unexpectedly
#!/usr/bin/python
from Foundation import *
form = NSDateFormatter.alloc().init()
# Explicit 24 hour time format used to trump any user settings (I think?)
form.setDateFormat_("HH:mm:ss")
print "Current locale is " + NSLocale.currentLocale().localeIdentifier()
echo "from AppKit import NSPasteboard\nNSPasteboard.pasteboardWithName_(\"IDESourceControlCommitMessagePasteboard\").releaseGlobally()" | python
echo "from AppKit import NSPasteboard\nprint NSPasteboard.pasteboardWithName_(\"IDESourceControlCommitMessagePasteboard\").stringForType_(\"IDESourceControlCommitMessagePboardType\")" | /usr/bin/python
<table class="loginBox withShadow" style="width:95%"><tbody class="loginCredentials">
<tr><td class="sidePadded" style="font-weight:bold; padding-top: 5px;"><p align="left"><font face="verdana,geneva,arial,sans-serif" size="4" color="green"><b>Welcome to Business Online Banking!</b></font></p></td></tr>
<tr><td><hr></td></tr>
<tr><td class="sidePadded">Company ID</td></tr>
<tr><td class="sidePadded"><input type="text" class="loginCredentials required" style="width:90%" id="companyID" name="companyID" size="20" value="" onkeypress="submitOnEnter(event);">
<br><span id="err_companyID">
</span></td></tr>
@implementation NSImage (RSShading)
- (NSImage *) tintedImage
{
NSImage* newImage = [[[NSImage alloc] initWithSize:[self size]] autorelease];
NSRect imageRect = {NSZeroPoint, [self size]};
NSColor *color = [NSColor blackColor];
[newImage lockFocus];
[[color colorWithAlphaComponent: 0.25] set];
- (void) testSimpleHTTPRequest
{
RSHTTPRequest* testViaGoogleRequest = [[RSHTTPRequest alloc] initWithURL:[self serverURLForHTTPTestNamed:@"SimpleHTTPRequest"] notifyingDelegate:self];
STAssertNotNil(testViaGoogleRequest, @"Creation of HTTP Request should have succeeded.");
[testViaGoogleRequest download];
[self spinRunLoopUntilCompletionOrTimeout];
STAssertTrue([[testViaGoogleRequest responseData] isEqualTo:[@"<hello>" dataUsingEncoding:NSUTF8StringEncoding]], @"Expected <hello> result, got %@.", [testViaGoogleRequest responseData]);
[testViaGoogleRequest release];
tell application "System Events"
tell application process "BBEdit"
tell (pop up button 1 of window 1)
-- Click to make the menu appear in the hierarchy
click
-- Now select the "Go to" item...
set goToItem to menu item "Go to…" of menu 1
click goToItem
@implementation MSFilmStripPickerScrollView
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
return YES;
}
@end
@implementation JimPopUpButtonCell
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSRect rect = [self drawingRectForBounds: cellFrame];
rect.size.width -= 17; // chop off the popup indicator
NSSize imageSize = NSMakeSize(12, 12);
rect.origin.x += (rect.size.width - imageSize.width) / 2.0;