Skip to content

Instantly share code, notes, and snippets.

#!/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 October 4, 2015 19:12 — forked from paskal/site.conf
Nginx configuration for best security and modest performance. Full info on https://terrty.net/2014/ssl-tls-in-nginx/
# 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
@Kozlov-V
Kozlov-V / StringValueBytes.m
Created September 1, 2015 21:32
StringValueBytes
- (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 August 28, 2015 18:53
Cancel NSURLSessionTask
- (void)cancel
{
for(NSURLSessionTask *task in _tasks) {
[task cancel];
}
}
@Kozlov-V
Kozlov-V / gist:7f15066c0c7188146fae
Last active August 26, 2015 19:26 — forked from DenTelezhkin/gist:beab675d853fcd2fd464
Multipart-form PUT request for image upload. NSURLSession, iOS 7
+(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 August 24, 2015 10:47
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;
@Kozlov-V
Kozlov-V / crossclient.java
Last active August 29, 2015 14:21
CrossClient
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 August 29, 2015 14:20
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 June 24, 2016 09:09
NSURLSessionUploadTask
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 February 24, 2015 20:29
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);
}
}