Skip to content

Instantly share code, notes, and snippets.

Aleksey Danilevsky alexd1971

Block or report user

Report or block alexd1971

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View numeric_to_words.dart
import 'dart:math';
/// Преобразует число в строку прописью
class NumericToWords {
// TODO: когда исправят баг в дарте, использовать данное регулярное выражение
//final _triadesRegExp = RegExp(r'(?<=\d)(?=(\d{3})+(?!\d))');
final _digitWords = {
0: {'male': 'ноль'},
1: {'male': 'один', 'female': 'одна'},
2: {'male': 'два', 'female': 'две'},
View say_number.hs
-- Грамматический род числительных
data Gender = Male | Female | Neuter deriving (Eq, Show)
-- Называет одну цифру (числа перого десятка)
sayDigits :: Gender -> Int -> String
sayDigits g x
| x == 1 && g == Male = "один"
| x == 1 && g == Female = "одна"
| x == 1 && g == Neuter = "одно"
| x == 2 && g == Female = "две"
View say_number.dart
import 'package:dartz/dartz.dart' show Tuple3;
/// Грамматический род
enum Gender { male, female, neuter }
/// Называет одну цифру (числа перого десятка)
///
/// [digit] - число первого десятка: 1 - 9.
/// [gender] - род числительного
String sayDigits(int digit, {Gender gender = Gender.male}) {
View main.dart
/// Выполняет сравнение нарядов по критерию связанности
int compareDetachments (Detachment a, Detachment b) {
final finishAtComparison = a.finishAt.compareTo(b.finishAt);
if(finishAtComparison != 0) return finishAtComparison;
return a.order.id.compareTo(b.order.id);
}
typedef bool TestRelated(Detachment detachment);
/// Возвращает функцию типа [TestRelated], которая проверяет,
@alexd1971
alexd1971 / app_component.dart
Created Mar 22, 2019
Working example of component testing with mock-service provider
View app_component.dart
import 'package:angular/angular.dart';
import 'package:component_testing/src/components/my_component.dart';
@Component(
selector: 'app',
template: '''
<h1>Component Testing</h1>
<my-component></my-component>
''',
directives: const [MyComponent],
@alexd1971
alexd1971 / app_component.dart
Last active Mar 20, 2019
Sample Angular Dart project for component testing question
View app_component.dart
import 'package:angular/angular.dart';
import 'package:component_testing/src/components/my_component.dart';
import 'package:component_testing/src/services/my_component_service.dart';
@Component(
selector: 'app',
template: '''
<h1>Component Testing</h1>
<test></test>
''',
@alexd1971
alexd1971 / app_component.dart
Last active Jul 25, 2018
Angular Dart Material Datepicker theming is not working
View app_component.dart
import 'package:angular/angular.dart';
import 'package:angular_components/utils/browser/window/module.dart';
import 'package:angular_components/material_datepicker/module.dart';
import 'package:angular_components/material_datepicker/material_date_time_picker.dart';
@Component(
selector: 'my-app',
styleUrls: ['app_component.css'],
templateUrl: 'app_component.html',
@alexd1971
alexd1971 / main.dart
Created Jun 14, 2018
Flutter TabView problem example
View main.dart
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
@alexd1971
alexd1971 / main.dart
Created May 21, 2018
Socks5 communication in dart
View main.dart
import 'dart:async';
import 'dart:io';
/// Фазы установки соединения с socks5-сервером
enum Socks5 {init, auth, connect}
Future main() async {
String targetHost = 'delidela.com';
int targetPort = 443;
View main.dart
class UserId {
String _id;
UserId(this._id);
@override
bool operator == (other) {
return _id == other._id;
}
int get hashCode => _id.hashCode;
}
You can’t perform that action at this time.