Skip to content

Instantly share code, notes, and snippets.

View chyrta's full-sized avatar

Dzmitry Chyrta chyrta

View GitHub Profile
@codediodeio
codediodeio / config.js
Last active April 16, 2024 04:46
Snippets from the Firestore Data Modeling Course
import * as firebase from 'firebase/app';
import 'firebase/firestore';
var firebaseConfig = {
// your firebase credentials
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
@karntrehan
karntrehan / DataFragment.kt
Created March 4, 2019 11:03
NestedScrollView + Paginated Recyclerview Android
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.core.view.ViewCompat
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.fragment_data.nsvData
import kotlinx.android.synthetic.main.fragment_data.rvData
@kakajika
kakajika / flatMapCompletable.swift
Created February 16, 2018 10:02
Single::flatMapCompletable in RxSwift
extension PrimitiveSequenceType where Self: ObservableConvertibleType, Self.TraitType == SingleTrait {
func flatMapCompletable(_ selector: @escaping (E) -> Completable) -> Completable {
return self
.asObservable()
.flatMap { e -> Observable<Never> in
selector(e).asObservable()
}
.asCompletable()
}
@jochenschoellig
jochenschoellig / ChatCollectionViewFlowLayout.swift
Created January 19, 2017 15:49
A subclass of UICollectionViewFlowLayout to get chat behavior without turning collection view upside-down. This layout is written in Swift 3 and absolutely usable with RxSwift and RxDataSources because UI is completely separated from any logic or binding.
import UIKit
class ChatCollectionViewFlowLayout: UICollectionViewFlowLayout {
private var topMostVisibleItem = Int.max
private var bottomMostVisibleItem = -Int.max
private var offset: CGFloat = 0.0
private var visibleAttributes: [UICollectionViewLayoutAttributes]?
@mminer
mminer / SocketIO+Rx.swift
Created December 2, 2016 20:27
SocketIOClient extension to subscribe to events via RxSwift observable.
import RxSwift
import SocketIO
extension Reactive where Base: SocketIOClient {
public func on(_ event: String) -> Observable<[Any]> {
return Observable.create { observer in
let id = self.base.on(event) { items, _ in
observer.onNext(items)
}
@webserveis
webserveis / material text sizes.md
Last active September 20, 2023 10:10 — forked from passsy/material text sizes.md
Material font sizes

Material text sizes XML for Android

Simple helper file for standard text sizes in material design. The sizes are provided by the material design documentation https://www.google.com/design/spec/style/typography.html#typography-roboto

material typography

Standard Styles

Too many type sizes and styles at once can wreck any layout. A typographic scale is a limited set of type sizes that work well together, along with the layout grid. The basic set of styles are based on a typographic scale of 12, 14, 16, 20, and 34.

@tehcpu
tehcpu / prism.md
Last active September 24, 2016 22:16

UPD (24.07.16)

Выпущено официальное приложение: https://play.google.com/store/apps/details?id=com.neuralprisma P.S. Выглядит круто, как и обещали :)

TL;DR

Приложение Prisma AI (Unofficial) (бандл: me.tehcpu.prisma) с этого дня (05.07.2016) официально является закрытым.

Почему?

Видимо, из-за расхождения взглядов и интересов обеих сторон (нас и официальных разработчиков).

@statickidz
statickidz / nearby-coordinates.sql
Last active January 31, 2024 20:31
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
@vasanthk
vasanthk / System Design.md
Last active May 1, 2024 16:16
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?