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
var methodCount: UInt32 = 0 | |
let methods = class_copyMethodList(anInstance.dynamicType, &methodCount) // replace anInstace | |
for i in 0..<Int(methodCount) { | |
NSLog("method: \(NSStringFromSelector(method_getName(methods[i])))") | |
} |
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
- (void)drawDashedLineOnMapBetweenOrigin:(CLLocation *)originLocation destination:(CLLocation *)destinationLocation { | |
[self.mapView clear]; | |
CGFloat distance = [originLocation distanceFromLocation:destinationLocation]; | |
if (distance < kMinimalDistance) return; | |
// works for segmentLength 22 at zoom level 16; to have different length, | |
// calculate the new lengthFactor as 1/(24^2 * newLength) | |
CGFloat lengthFactor = 2.7093020352450285e-09; | |
CGFloat zoomFactor = pow(2, self.mapView.camera.zoom + 8); |
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
@interface LoginViewController () | |
@property (strong, nonatomic) RACSubject *textFieldReturnPressed; | |
@property (strong, nonatomic) UITextField *usernameTextField; | |
@property (strong, nonatomic) UITextField *passwordTextField; | |
@end | |
@implementation LoginViewController |
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
HTTP/1.1 402 Payment Required | |
Content-Type: application/json | |
{ | |
"title": "End of trial", | |
"description": "Unfortunately, your trial period has ended. To continue using the application, you need to purchase a subscription.", | |
"explanation_url": "https://example.com/troubleshooting/payment-required", | |
"trace_url": "https://apilog.example.com/f26a3e1dc" | |
} |
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
curl -L https://get.rvm.io | bash -s stable | |
source ~/.rvm/scripts/rvm | |
rvm install 1.9.2 --reconfigure --debug -C --enable-pthread --with-gcc=clang | |
# ruby --version | |
# ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin12.2.0] |
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
javascript:(function(){var%20H=["cut","copy","paste","contextmenu","mousedown"],%20Z=[],%20s="",%20j;%20function%20R(N,a){%20while%20(N[a])%20{%20Z[a]=Z[a]?Z[a]+1:1;%20N[a]=null;%20}%20}%20function%20zapEH(N)%20{%20var%20a,i,C;%20for%20(j%20in%20H)%20R(N,"on"+H[j]);%20C=N.childNodes;%20for%20(i=0;i<C.length;++i)%20zapEH(C[i]);%20}%20zapEH(document);%20for%20(j%20in%20Z)%20s%20+=%20j%20+%20"%20("%20+%20Z[j]%20+%20")\n";%20if(s)%20alert("Zapped%20event%20handlers:\n\n"+s);%20else%20alert("No%20event%20handlers%20found.");})(); |
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
#!/bin/sh | |
# make sure requirements.txt is up to date with every commit | |
# by comparing the output of pip freeze | |
pip freeze | diff requirements.txt - > /dev/null | |
if [ $? != 0 ] | |
then | |
echo "Missing python module dependencies in requirements.txt. Run 'pip freeze > requirements.txt' to update." | |
exit 1 | |
fi |
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
import datetime | |
import httplib2 | |
# to see in detail what's going on, uncomment | |
# httplib2.debuglevel = 4 | |
from apiclient.discovery import build | |
from oauth2client.client import OAuth2Credentials, OAuth2WebServerFlow | |
if __name__ == "__main__": |
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
import datetime | |
import httplib2 | |
from oauth2client.client import OAuth2Credentials | |
credentials = OAuth2Credentials("irrelevant access token", | |
"some-random-hash.apps.googleusercontent.com", # Client ID | |
"your-client-secret", | |
"refresh-token", | |
datetime.datetime.now(), # token expiry | |
"https://accounts.google.com/o/oauth2/token") |
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
credentials = flow.step2_exchange(code) # code from the localhost redirect |