Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block Kozlov-V

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
set -e
## Utils
print_msg() {
echo "Frappe password: $FRAPPE_USER_PASS"
echo "MariaDB root password: $MSQ_PASS"
Kozlov-V / site.conf
Created Oct 4, 2015 — forked from paskal/site.conf
Nginx configuration for best security and modest performance. Full info on
View site.conf
#
# latest version on
# security test score:
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat & wget -O - | tee -a /etc/nginx/ssl/domain.pem > /dev/null
View StringValueBytes.m
- (NSString *)readableValueWithBytes:(id)bytes{
NSString *readable;
//round bytes to one kilobyte, if less than 1024 bytes
if (([bytes longLongValue] < 1024)){
readable = [NSString stringWithFormat:@"1 KB"];
Kozlov-V / canceltask.m
Created Aug 28, 2015
Cancel NSURLSessionTask
View canceltask.m
- (void)cancel
for(NSURLSessionTask *task in _tasks) {
[task cancel];
Kozlov-V / gist:7f15066c0c7188146fae
Last active Aug 26, 2015 — forked from DenTelezhkin/gist:beab675d853fcd2fd464
Multipart-form PUT request for image upload. NSURLSession, iOS 7
View gist:7f15066c0c7188146fae
+(void)uploadUserPhoto:(UIImage *)image
success:(void (^)(void))success
GTSessionManager * manager = [GTSessionManager manager];
NSString* tmpFilename = [NSString stringWithFormat:@"%f", [NSDate timeIntervalSinceReferenceDate]];
NSURL* tmpFileUrl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:tmpFilename]];
NSString * query = [NSString stringWithFormat:@"%@user?auth_token=%@",[manager.baseURL absoluteString],[[UserManager shared] authToken]];
Kozlov-V /
Created Aug 24, 2015
File size to string
public static String getStringSizeLengthFile(long size) {
DecimalFormat df = new DecimalFormat("0.00");
float sizeKb = 1024.0f;
float sizeMo = sizeKb * sizeKb;
float sizeGo = sizeMo * sizeKb;
float sizeTerra = sizeGo * sizeKb;
import java.util.Arrays;
import java.util.List;
import android.text.TextUtils;
import android.accounts.AccountManager;
import android.content.Intent;
Kozlov-V / org.chameleon.Boot.plist
Last active Aug 29, 2015
View org.chameleon.Boot.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<key>Default Partition</key>
<key>Graphics Mode</key>
Kozlov-V / uploadtask.m
Last active Jun 24, 2016
View uploadtask.m
Upload Task sends data/file and it supports background uploads when the app is not running.
2.3.1) Create Upload task with system provided delegate methods.
/* Creates an upload task with the given request. The body of the request will be created from the file referenced by fileURL */
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL;
/* Creates an upload task with the given request. The body of the request is provided from the bodyData. */
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromData:(NSData *)bodyData;
Kozlov-V /
Created Feb 24, 2015
get Status Bar Heigh
public int getStatusBarHeight() {
int statusBarHeight = 0;
if (!hasOnScreenSystemBar()) {
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
You can’t perform that action at this time.