Skip to content

Instantly share code, notes, and snippets.

View IlyaGulya's full-sized avatar

Ilya Gulya IlyaGulya

View GitHub Profile
@IlyaGulya
IlyaGulya / site.conf
Last active August 29, 2015 14:18 — forked from paskal/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
@IlyaGulya
IlyaGulya / SIT_KOLOB
Created November 2, 2015 15:54 — forked from bilinin/SIT_KOLOB
1 Отличия локальных и глобальных сетей передачи данных (кроме очевидного отличим в
размерах)?
Основными отличительными признаками локальных сетей от глобальных выступают следующие:
 степень оперативности обработки запросов;
 скорость обмена и транспортировки данных;
 масштабируемость;
 уровень сложности схемы передачи данных;
 механизмы прокладки связных линий и их протяженность;
 разнообразность услуг.
@IlyaGulya
IlyaGulya / script.js
Last active November 12, 2016 04:43
Userscript for easy copying the item URL on http://www.xarakiri.ru/
// ==UserScript==
// @name Harakiri URL button
// @namespace http://ccrowd.in/
// @version 0.0.1
// @description Userscript for easy copying the item URL on http://www.xarakiri.ru/
// @author [email protected]
// @match http://www.xarakiri.ru/catalog/*
// @grant none
// ==/UserScript==
/* jshint esnext: true */
@IlyaGulya
IlyaGulya / RealmUtil.java
Created December 13, 2016 14:42
Simple utils for Realm.io database
package in.ccrowd.base.database;
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
import io.realm.Realm;
import io.realm.RealmModel;
import io.realm.RealmObject;
import rx.functions.Func0;
@IlyaGulya
IlyaGulya / DelegatedViewController.kt
Created May 21, 2018 12:04
Delegated View Controller for Paginator
abstract class DelegatedViewController<T> : ViewController<T> {
fun invokeAction(action: DelegatingViewController.DelegatedAction<T>) {
action.invoke(this)
}
}
private abstract class RequestFactoryAdapter<T> {
lateinit var paginator: Paginator<T>
abstract fun loadPage(page: Int)
protected fun onSuccess(data: List<T>) {
paginator.currentState.newData(data)
}
@JvmStatic
fun <T : RealmObject> filterAccess(query: RealmQuery<T>): RealmQuery<T> {
val roles = DCUserManager.getRoles().toTypedArray()
fun RealmQuery<T>.operationTypeIs(operationType: String) {
equalTo(RealmUtil.getField(ModelWithType.FIELD_ACCESS, AccessModel.FIELD_OPERATION), operationType)
}
fun RealmQuery<T>.hasAnyOfRoles(roles: Array<Int>) {
oneOf(RealmUtil.getField(ModelWithType.FIELD_ACCESS, AccessModel.FIELD_ROLES, IntObject.FIELD_VALUE), roles)
}
@IlyaGulya
IlyaGulya / Example.kt
Created August 24, 2018 08:25
Simple Realm Kotlin query builder
val query: RealmQuery<Model> = ...
query.build {
group {
equalTo(linkedField(Column.PARAMS, Column.FIELD_TYPE), DCParamModel.FieldType.BOOLEAN)
and
equalTo(linkedField(Column.PARAMS, Column.KEY), DCParamObject.FAVORITE)
and
equalTo(linkedField(Column.PARAMS, Column.F_BOOL), true)
}
}
@IlyaGulya
IlyaGulya / PhoneAuth.kt
Created September 2, 2018 06:25
Phone auth test example
interface PhoneAuth {
fun sendSms(phone: String): Completable
fun login(code: String): Completable
fun changePhone()
fun getPhoneAuthState(): Observable<PhoneAuthState>
fun getProgressState(): Observable<ProgressState>
fun getErrorState(): Observable<ErrorState>
companion object {
const val DEFAULT_TIMER = 60L
@IlyaGulya
IlyaGulya / EditProfileComponent.kt
Created December 29, 2018 04:18
Android code sample
package com.app.feature.editprofile.di
import com.app.feature.editprofile.presenter.EditProfilePresenter
import com.app.feature.editprofile.di.EditProfileScope
@EditProfileScope
interface EditProfileComponent {
val editProfilePresenter: EditProfilePresenter
}