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
{ | |
"id": 302228, | |
"content": "Philadelphia reported 126 new COVID-19 cases and 17 deaths Friday.", | |
"bert_tags": [ | |
"Philadelphia" | |
], | |
"identifier": "default", | |
"article_id": 5097 | |
} |
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
import spacy | |
nlp = spacy.load("en_core_web_sm") | |
article = "I have lived in Philadelphia for most of my life. I went to school in New York City." | |
doc = nlp(article) | |
[sent for sent in doc.ents] | |
# Output: [Philadelphia, New York City] |
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
import spacy | |
nlp = spacy.load("en_core_web_sm") | |
article = "This is the content of the article. It consists of many sentences." | |
doc = nlp(article) | |
[sent.text for sent in doc.sents] | |
# Output: [‘This is the content of the article.’, ‘It consists of many sentences.’] |
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
// Define the content of the notification | |
let content = UNMutableNotificationContent() | |
content.title = place.title | |
content.body = place.blurb | |
content.sound = UNNotificationSound.default() | |
// Define the region | |
let region = CLCircularRegion(center: place.coordinate(), radius: place.radius ?? 100, identifier: place.identifier) | |
region.notifyOnEntry = true | |
region.notifyOnExit = false |
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
// MARK - Motion Tracking Logic | |
func startTrackingMotionActivity(handler: @escaping (CMMotionActivity) -> Void) { | |
manager.startActivityUpdates(to: .main) { (activity) in | |
guard let activity = activity else { return } | |
if let lastActivity = self.currentActivity, lastActivity.automotive { | |
self.stoppedDrivingAt = Date() // now | |
} | |
self.currentActivity = activity | |
handler(activity) |
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
// MARK: - Significant location change montioring logic | |
// Called at launch of application if permission is already granted | |
func startMonitoringSignificantLocationChanges() { | |
locationManager.startMonitoringSignificantLocationChanges() | |
} | |
// Called by location manager if there is a significant location change | |
func locationManager(_ manager: CLLocationManager, | |
didUpdateLocations locations: [CLLocation]) { |
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
-(NSArray<NSString> *)permutationsOfString:(NSString *)s { | |
NSMutableArray<NSString> *res = [NSMutableArray array]; | |
if (s.length == 1) { | |
[res addObject:s]; | |
} else if (s.length > 1) { | |
int lastIndex = s.length - 1; | |
String last = s.substring(lastIndex); | |
String rest = s.substring(0, lastIndex); | |
res = merge(permutation(rest), last); | |
} |
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
#import <Foundation/Foundation.h> | |
#import <stdio.h> | |
@interface MyClass : NSObject | |
@end | |
@implementation MyClass | |
// 1. returns the number of non-zero elements (4) | |
+ (int)numberOfZeroElementsInArray:(NSArray *)array { |
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
case 4: { // Login and logout | |
if ([FBSDKAccessToken currentAccessToken]) { | |
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; | |
[login logOut]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
// Clear up all the user defaults here. | |
NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; | |
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; | |
[defaults synchronize]; |
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
@interface UICollectionViewFlowLayout (InvalidateOnBoundsChange) | |
@end | |
@implementation UICollectionViewFlowLayout (InvalidateOnBoundsChange) | |
- (UICollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChange:(CGRect)newBounds { | |
UICollectionViewLayoutInvalidationContext *context = [super invalidationContextForBoundsChange:newBounds]; | |
CGRect oldBounds = self.collectionView.bounds; | |
CGFloat widthAdjustment = newBounds.size.width - oldBounds.size.width; |
NewerOlder