Skip to content

Instantly share code, notes, and snippets.

View xaelkaz's full-sized avatar
🎯
Focusing

xaelkaz

🎯
Focusing
View GitHub Profile
@xaelkaz
xaelkaz / user_repository.dart
Created February 21, 2020 20:42 — forked from funwithflutter/user_repository.dart
Flutter Web Firebase Auth
import 'package:firebase/firebase.dart';
import 'package:meta/meta.dart';
@immutable
class UserRepository {
UserRepository({Auth firebaseAuth, GoogleAuthProvider googleSignin})
: _firebaseAuth = firebaseAuth ?? auth(),
_googleSignIn = googleSignin ?? GoogleAuthProvider();
final Auth _firebaseAuth;
import android.content.Context
import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.support.annotation.AnyRes
import android.support.v4.app.Fragment
import android.support.v4.content.res.ResourcesCompat.*
import android.view.View
val Context.animations
get() = ResourceMapper { resources.getAnimation(it) }
@xaelkaz
xaelkaz / AboutEnumsWithCompanionObj.kt
Created December 11, 2019 22:30 — forked from automationhacks/AboutEnumsWithCompanionObj.kt
Reverse lookup an enum constant by using a dedicated member method
package experiments
enum class MousesV1(
val brand: String
) {
LOGITECH("logi"),
DELL("dell");
companion object {
@xaelkaz
xaelkaz / curl.md
Created September 19, 2019 18:34 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@ExperimentalCoroutinesApi
fun initMap(
map: CustomMapFragment,
addresses: ArrayList<String>,
callback: (points: ArrayList<LatLng>) -> Unit
) {
CoroutineScope(Dispatchers.Default).launch {
//функции, вызванные через GlobalScope.async будут исполняться параллельно
val googleMap = GlobalScope.async { getGoogleMap(map) }
val points = GlobalScope.async {getPoints(map, addresses)}
//Использование во fragment
MapUtils.initGoogleMap(map) { googleMap ->
MapUtils.setupMap(context, googleMap, handlePointsCallback)
}
class MapUtils {
companion object {
//Получаем карту. Callback вызывается в UI потоке
fun initGoogleMap(
map: CustomMapFragment,
@xaelkaz
xaelkaz / rails-vagrant-provision.sh
Created May 17, 2018 23:15 — forked from johanneswuerbach/rails-vagrant-provision.sh
Provision a vagrant box with ruby stable (using rvm), postgres, redis and node (using nvm)
#!/usr/bin/env bash
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8
sudo apt-get update
sudo apt-get install -y build-essential git curl libxslt1-dev libxml2-dev libssl-dev
# postgres