Skip to content

Instantly share code, notes, and snippets.

@danie7k
danie7k / user-command.sh
Created November 22, 2016 16:51
Run console command as another user
sudo -H -u www-data git status
@danie7k
danie7k / snapshot.m
Last active January 15, 2022 02:18
iOS Objective-C screenshot
- (UIImage *)snapshot:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
@danie7k
danie7k / switch-string.m
Last active February 9, 2017 09:16
iOS Objective-C switch with string
NSString *testedString;
__block NSString *selected;
((void (^)())@{
@"A" : ^{
selected = @"A selected";
},