Skip to content

Instantly share code, notes, and snippets.

Avatar

Francisco Ryan Tolmasky I tolmasky

View GitHub Profile
View gist:11732
[importButton setBordered:NO];
[importButton setImagePosition:CPImageLeft];
[importButton setTitle:@"blah"];
[importButton setTextColor:[CPColor blackColor]];
[importButton setFont:[CPFont systemFontOfSize:16.0]];
[importButton setImage:[[CPImage alloc] initWithContentsOfFile:path1 size:CGSizeMake(32.0, 32.0)]];
[importButton setAlternateImage:[[CPImage alloc] initWithContentsOfFile:path2 size:CGSizeMake(32.0, 32.0)]];
[importButton setAlignment:CPLeftTextAlignment];
[importButton setDelegate:self];
View gist:13552
@implementation TheCell : CPView
{
id myRepresentedObject
}
- (void)mouseDragged:(CPEvent)anEvent
{
var dragView = [[TheCell alloc] initWithFrame:[self bounds]];
[dragView setRepresentedObject:myRepresentedObject];
View gist:23136
- (CPString)stringByDeletingLastPathComponent
{
var path = self,
start = length - 1;
while (path.charAt(start) === '/')
start--;
path = path.substr(0, path.lastIndexOf('/', start));
View gist:24699
for(; index < count; ++index)
{
var lhs = self[index],
rhs = anArray[index];
if (lhs !== rhs && (!lhs.isa || !rhs.isa || ![lhs isEqual:rhs]))
return NO;
}
View gist:24700
for(; index < count; ++index)
{
var lhs = self[index],
rhs = anArray[index];
if (lhs === rhs || lhs.isa && rhs.isa && [lhs isEqual:rhs])
continue;
return NO;
}
View gist:28722
--- a/Foundation/CPTimer.j
+++ b/Foundation/CPTimer.j
@@ -243,13 +243,13 @@ var _CPTimerBridgeTimer = function(codeOrFunction, aDelay, shouldRepeat, functio
theFunction = nil;
if (typeof codeOrFunction === "string")
- theFunction = function() { new Function(codeOrFunction)(); CPTimersForTimeoutIDs[timeoutID] = nil; }
+ theFunction = function() { new Function(codeOrFunction)(); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
else
{
View gist:37659
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Name</key>
<string>YouKit</string>
<key>Targets</key>
<array>
<dict>
<key>Name</key>
View gist:37660
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPBundleIdentifier</key>
<string>com.You.YouKit</string>
<key>CPBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CPBundleName</key>
<string>YouKit</string>
View gist:56841
<script>
window.setTimeout(function() { alert(); window.setTimeout(alert(), 100); }, 100);
window.setTimeout(function() { alert(); window.setTimeout(alert(), 100); }, 100);
alert();
</script>
View gist:82369
@implementation Shape : CPObject
{
CGRect mRect;
CPColor mColor;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeRect:mRect forKey:"rect"];
[aCoder encodeObject:mColor forKey:"color"];
You can’t perform that action at this time.