Skip to content

Instantly share code, notes, and snippets.

@dodikk
dodikk / shared.rs
Created June 25, 2018 14:51 — forked from stevedonovan/shared.rs
An ergonomic way of saying Rc<RefCell>
use std::rc::Rc;
use std::cell::{RefCell,Ref, RefMut};
use std::ops::Deref;
use std::fmt;
#[derive(Clone)]
struct Shared<T> {
v: Rc<RefCell<T>>
}
@dodikk
dodikk / EmailValidationRegex.swift
Created March 6, 2018 15:06
Email validation regex from bootstrap
private static func validateEmailByBootstrapRegex(_ userInput: String) -> Bool
{
var emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegex)
return emailTest.evaluate(with: userInput)
}
// TODO: is NSPredicate any better
@dodikk
dodikk / debounce-throttle.swift
Created February 21, 2018 11:37 — forked from simme/debounce-throttle.swift
Swift 3 debounce & throttle
//
// debounce-throttle.swift
//
// Created by Simon Ljungberg on 19/12/16.
// License: MIT
//
import Foundation
extension TimeInterval {
@dodikk
dodikk / NSObject+Debounce.h
Created February 21, 2018 11:31 — forked from berzniz/NSObject+Debounce.h
Debounce method for Objective C
@interface NSObject (Debounce)
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay;
@end
@dodikk
dodikk / estimating_joke_ru.md
Last active February 21, 2018 09:32
A joke about estimating (in russian)

— Слушай, ты разработчик. Ответь, почему разработчики всегда неправильно оценивают время на создание программ?

— Представь что тебе надо разгрузить машину, сколько времени это займет?
— Пару часов
— Это камаз
— 8 часов
@dodikk
dodikk / ChatDetailsRepoRealm.swift
Created February 15, 2018 15:22
Realm Queries on Background Queue
public func storeChatDetailsAsync(
_ item: ChatDetailsInfoType,
callback: @escaping GroupChatDetailsFetchCompletion)
{
self._queue.async
{
[weak weakSelf = self] in
guard let strongSelf = weakSelf
else
import FutureKit
extension Promise {
func getCallbackForService() -> ( (Result<T>) -> Swift.Void )
{
return self.completeWithResult
}
func completeWithResult(result: Result<T>) {
@dodikk
dodikk / NumbersPadKeyValuePairView.xaml
Created February 2, 2018 10:34
[Xamarin.Forms] Control example - numbers panel
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SampleFormsProject.Views.NumbersPadKeyValuePairView"
xmlns:ns_sample_control="clr-namespace:SampleFormsProject.Views;assembly=SampleFormsProject"
>
<ContentView.Content>
@dodikk
dodikk / HorizontalStackControl.xaml
Last active February 1, 2018 11:32
[question] Nested stack layouts in Xamarin.Forms
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PracticeDashboard.Views.SalesPipeline.SelectedMonthNumbersPanel">
<ContentView.Content>
<StackLayout Orientation="Horizontal" BackgroundColor="Blue">
<BoxView Color="Red" HeightRequest="60"/>
@dodikk
dodikk / SalesPipelineNormalizedPlotBuilder.cs
Created January 29, 2018 11:46
[solved] OxyPlot columns and line series together Raw
namespace PracticeDashboard.PlotBuilders.SalesPipeline
{
using System;
using System.Collections.Generic;
using System.Linq;
using Helpers;
using global::OxyPlot;
using global::OxyPlot.Axes;
using global::OxyPlot.Series;
using PracticeDashboard.DAL.Models.SalesPipeline;