Skip to content

Instantly share code, notes, and snippets.

View tillawy's full-sized avatar

Mohammed O. Tillawy tillawy

View GitHub Profile

Keybase proof

I hereby claim:

  • I am tillawy on github.
  • I am tillawy (https://keybase.io/tillawy) on keybase.
  • I have a public key ASAHuijT3y5nW4_2HgYSQbBYVObGlliFCXsRJTEEEF8rJAo

To claim this, I am signing this object:

@tillawy
tillawy / spark_average.py
Created March 9, 2016 15:46
Calculate the average of a dataset.
def average(self,dataset):
output = dataset.map(lambda x:(x[1],x[2] ))
output = output.groupByKey()
output = output.map(lambda x:(x[0], len(x[1]),x[1]))
output = output.map(lambda b:(b[0], sum(b[2])/b[1]))
return output
@tillawy
tillawy / filter ELB AWS Logs
Last active February 26, 2016 14:11
filter AWS ELB logs by mac IP Address
cat ${FILENAME}.log \
| awk '{print $3}' \
| cut -f 1 -d ":" \
| sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 \
| uniq -c \
| sort -n -r \
| head -n 100
@tillawy
tillawy / fbsdk.swift
Last active February 12, 2016 08:44
use fbsdk swift to get fb user email
let login = FBSDKLoginManager()
login.logInWithReadPermissions([ "email" ], fromViewController: self) { (result: FBSDKLoginManagerLoginResult!,error: NSError!) -> Void in
if (error != nil){
SVProgressHUD.showErrorWithStatus(error.localizedDescription)
} else if (result.isCancelled) {
SVProgressHUD.showWithStatus("Canceled")
} else {
self.logger.info("fb token: \(result.token.tokenString)")
let params = ["fields" : "email,name"]
@tillawy
tillawy / gist:7918b5140613d684ba9c
Created September 3, 2014 09:06
tell if current iOS target is test (XCTest)
-(BOOL)isTesting{
__block BOOL output = NO;
[[[NSProcessInfo processInfo] arguments] each:^(NSString * arg) {
NSLog(@"arg:%@",arg);
if ([arg containsString:@"-XCTest"]) {
output = YES;
}
}];
return output;
}