Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am jault3 on github.
  • I am jault (https://keybase.io/jault) on keybase.
  • I have a public key ASAZmQI0Zv6Q2DZn4d9Hyemb0A0Q37BSy7CyJGD46a2Sfgo

To claim this, I am signing this object:

@jault3
jault3 / golang_17206_linux.patch
Last active Sep 26, 2017
patch for fixing golang issue 17206 from the go1.7.3 tag
View golang_17206_linux.patch
diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go
index 7a4b571..0355eca 100644
--- a/src/syscall/exec_linux_test.go
+++ b/src/syscall/exec_linux_test.go
@@ -169,9 +169,9 @@ func TestUnshare(t *testing.T) {
origLines := strings.Split(strings.TrimSpace(string(orig)), "\n")
cmd := exec.Command("cat", path)
- cmd.SysProcAttr = &syscall.SysProcAttr{
+ /*cmd.SysProcAttr = &syscall.SysProcAttr{
@jault3
jault3 / RequestDataAccess.m
Created Oct 23, 2014
RequestDataAccess.m
View RequestDataAccess.m
[_healthStore requestAuthorizationToShareTypes:writeTypes readTypes:readTypes completion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"You didn't allow HealthKit to access these read/write data types. In your app, try to handle this error gracefully when a user decides not to provide access. The error was: %@.", error);
}
}];
View DataTypesToWrite.m
- (NSSet *)dataTypesToWrite {
HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
HKQuantityType *heartRate = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate];
HKQuantityType *walkingRunningDistance = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
return [NSSet setWithObjects:heightType, weightType, heartRate, walkingRunningDistance, nil];
}
View DataTypesToRead.m
- (NSSet *)dataTypesToRead {
HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
HKQuantityType *heartRate = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate];
HKQuantityType *walkingRunningDistance = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
HKCharacteristicType *biologicalSex = [HKCharacteristicType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierBiologicalSex];
HKCharacteristicType *birthday = [HKCharacteristicType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierDateOfBirth];
return [NSSet setWithObjects:heightType, weightType, heartRate, walkingRunningDistance, biologicalSex, birthday, nil];
@jault3
jault3 / QueryRecentLogs.m
Created Oct 23, 2014
QueryRecentLogs.m
View QueryRecentLogs.m
HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:[HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning]
predicate:[HKSampleQuery predicateForObjectsWithNoCorrelation]
limit:20
sortDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:HKSampleSortIdentifierEndDate ascending:NO]]
resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
_runLogs = [NSMutableArray arrayWithArray:results];
[_tblRunLog reloadData];
});
}];
@jault3
jault3 / SaveNewLog.m
Last active Aug 29, 2015
SaveNewLog.m
View SaveNewLog.m
HKUnit *bpmUnit = [[HKUnit countUnit] unitDividedByUnit:[HKUnit minuteUnit]];
NSDate *startDate = (NSDate *)[_data objectForKey:kStartDate];
NSDate *endDate = [NSDate date];
NSMutableDictionary *metadata = [NSMutableDictionary dictionary];
[metadata setValue:[NSNumber numberWithDouble:_txtBeginningHeartRate.text.doubleValue] forKey:kBeginningHeartRate];
[metadata setValue:[NSNumber numberWithDouble:_txtEndingHeartRate.text.doubleValue] forKey:kEndingHeartRate];
// send the heart beat off to Catalyze and HealthKit
@jault3
jault3 / SaveWeight.m
Created Sep 17, 2014
Save Weight to HealthKit
View SaveWeight.m
double weight = _txtWeight.text.doubleValue;
HKUnit *poundUnit = [HKUnit poundUnit];
HKQuantity *weightQuantity = [HKQuantity quantityWithUnit:poundUnit doubleValue:weight];
HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
NSDate *now = [NSDate date];
HKQuantitySample *weightSample = [HKQuantitySample quantitySampleWithType:weightType quantity:weightQuantity startDate:now endDate:now];
[self.healthStore saveObject:weightSample withCompletion:^(BOOL success, NSError *error) {
@jault3
jault3 / SaveHeight.m
Created Sep 17, 2014
Save Height to HealthKit
View SaveHeight.m
double height = _txtHeight.text.doubleValue;
HKUnit *inchUnit = [HKUnit inchUnit];
HKQuantity *heightQuantity = [HKQuantity quantityWithUnit:inchUnit doubleValue:height];
HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
NSDate *now = [NSDate date];
HKQuantitySample *heightSample = [HKQuantitySample quantitySampleWithType:heightType quantity:heightQuantity startDate:now endDate:now];
[self.healthStore saveObject:heightSample withCompletion:^(BOOL success, NSError *error) {
@jault3
jault3 / PopulateWeight.m
Last active Aug 29, 2015
Populate Weight from HealthKit
View PopulateWeight.m
HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
// Since we are interested in retrieving the user's latest sample
// we sort the samples in descending order by end date
// and set the limit to 1
// We are not filtering the data, and so the predicate is set to nil.
NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO];
// construct the query & since we are not filtering the data the predicate is set to nil
HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:weightType predicate:nil limit:1 sortDescriptors:@[timeSortDescriptor] resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {