Skip to content

Instantly share code, notes, and snippets.

Kozlov-V

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
View setup-frappe.sh
#!/bin/bash
set -e
## Utils
print_msg() {
echo "Frappe password: $FRAPPE_USER_PASS"
echo "MariaDB root password: $MSQ_PASS"
@Kozlov-V
Kozlov-V / site.conf
Created Oct 4, 2015 — forked from paskal/site.conf
Nginx configuration for best security and modest performance. Full info on https://terrty.net/2014/ssl-tls-in-nginx/
View site.conf
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# 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 example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | 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
Kozlov-V / canceltask.m
Created Aug 28, 2015
Cancel NSURLSessionTask
View canceltask.m
- (void)cancel
{
for(NSURLSessionTask *task in _tasks) {
[task cancel];
}
}
@Kozlov-V
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
failure:(FailureBlock)failure
{
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
Kozlov-V / filesize.java
Created Aug 24, 2015
File size to string
View filesize.java
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;
View crossclient.java
import java.util.Arrays;
import java.util.List;
import com.google.android.gms.auth.GoogleAuthUtil;
import com.google.android.gms.auth.UserRecoverableAuthException;
import com.google.android.gms.common.AccountPicker;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
import android.accounts.AccountManager;
import android.content.Intent;
@Kozlov-V
Kozlov-V / org.chameleon.Boot.plist
Last active Aug 29, 2015
org.chameleon.Boot.plist
View org.chameleon.Boot.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Default Partition</key>
<string>hd(0,2)</string>
<key>EthernetBuiltIn</key>
<string>Yes</string>
<key>Graphics Mode</key>
<string>1024x768x32</string>
@Kozlov-V
Kozlov-V / uploadtask.m
Last active Jun 24, 2016
NSURLSessionUploadTask
View uploadtask.m
2.3).NSURLSessionUploadTask
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
Kozlov-V / statsbarhght.java
Created Feb 24, 2015
get Status Bar Heigh
View statsbarhght.java
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.