This file contains 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
-(void)update:(ccTime)dt | |
{ | |
// Only run the update if we haven't already landed | |
if(!didLand) | |
{ | |
// We accelerate downward at 10 pixels per second per second. | |
// "dt" stands for "delta time" is how much time has passed since the last time this function | |
// was called, so it's around 0.05 seconds | |
// Using our number 10, and our number dt, how do we create the value that we're going to |
This file contains 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
#!/bin/bash | |
URL=`git config remote.origin.url` | |
# if its a git@, replace that with https:// | |
URL=`echo $URL | sed -e "s/git@/https:\/\//g"`; | |
URL=`echo $URL | sed -e "s/com:/com\//g"`; | |
# remove the .git at the end | |
URL=`echo $URL | sed -e "s/.git$//g"`; |
This file contains 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
-(ccBezierConfig)bezierForStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint curviness:(CGFloat)alpha | |
{ | |
CGPoint basis1 = ccpLerp(startPoint, endPoint, 0.3333); | |
CGPoint basis2 = ccpLerp(startPoint, endPoint, 0.6666); | |
// Get a point on the perpendicular line of each of the control points | |
CGPoint vector = ccpSub(endPoint, startPoint); | |
// First point is to the right, second is to the left, of the line between the start point and end point | |
CGPoint v1 = ccpRPerp(vector); |
This file contains 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
-(IBAction)cancelPressed:(id)sender | |
{ | |
void (^onComplete)(void) = ^{ | |
IMP superCancelPressed = class_getMethodImplementation([MCDialogView class], @selector(cancelPressed:)); | |
superCancelPressed(<what goes here?>, @selector(cancelPressed:), nil); | |
//[super cancelPressed:sender]; | |
}; | |
//... |
This file contains 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
#!/bin/sh | |
TRASH="$HOME/.Trash/"; | |
args=("$@"); | |
for f in $args; do | |
base=$(basename $f); | |
if [ -e "$TRASH$base" ] ; then | |
TS=`date`; |
This file contains 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
#!/bin/bash | |
if [ "$#" -ne 1 ]; then | |
echo "usage: timey <number of minutes> &"; | |
exit; | |
fi | |
SECONDS=$(($1 * 60)) | |
echo "Timey set for $1 minutes, which is $SECONDS seconds" | |
sleep $SECONDS | |
open -a "Google Chrome.app" https://media.giphy.com/media/yWh7b6fWA5rJm/giphy.gif |
This file contains 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
- (void)runRecursiveBlock | |
{ | |
void(^ completionBlock) (); | |
void(^ __block __weak weakCompletionBlock) (); | |
weakCompletionBlock = completionBlock = ^{ | |
NSLog(@"%@", NSStringFromSelector(_cmd)); | |
void(^ strongCompletionBlock)() = weakCompletionBlock; | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | |
strongCompletionBlock(); | |
}); |
This file contains 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
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString | |
{ | |
// Normalize strings | |
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
originalString = [originalString lowercaseString]; | |
comparisonString = [comparisonString lowercaseString]; | |
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm) |
This file contains 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
--- | |
Language: Cpp | |
# BasedOnStyle: LLVM | |
AccessModifierOffset: -2 | |
AlignAfterOpenBracket: Align | |
AlignConsecutiveAssignments: false | |
AlignConsecutiveDeclarations: false | |
AlignEscapedNewlinesLeft: false | |
AlignOperands: true | |
AlignTrailingComments: true |
This file contains 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
def value_generator(data): | |
if isinstance(data, dict): | |
for key, value in data.iteritems(): | |
for element in value_generator(value): | |
yield element | |
elif isinstance(data, list): | |
for sublist in data: | |
for element in value_generator(sublist): | |
yield element | |
else: |
OlderNewer