Skip to content

Instantly share code, notes, and snippets.

@andantonyan
andantonyan / pagination.ts
Created August 31, 2022 11:13
Generate pagination `sort` field type from SortField and SortOrder
enum SortOrder {
ASC,
DESC,
}
enum UsersSortField {
ID,
NAME,
CREATION_DATE,
}
@andantonyan
andantonyan / permission-service.ts
Created August 30, 2022 22:12
PermissionService with auto generated methods based on Permission type using Proxy
class PermissionService extends (class {} as new () => Proxy) {
constructor() {
super();
return this.createProxy();
}
private static camelCaseToUpperCase(key: string): string {
return key
.replace(/([A-Z])/g, ' $1')
.split(' ')
@andantonyan
andantonyan / flutter_mixin_composition.dart
Created April 15, 2022 14:27
Flutter mixin composition example
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
@andantonyan
andantonyan / conditional_section.dart
Created February 11, 2022 17:19
Render conditional section using factory and COR patterns
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
@andantonyan
andantonyan / flutter_bloc_ioc.dart
Created September 14, 2021 15:32
Example using inversion of control with flutter bloc
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
abstract class AbstractBloc<Event, State> implements Bloc<Event, State> {}
@immutable
class TestState {
final int value;
const TestState(this.value);
@andantonyan
andantonyan / bloc_tree.dart
Last active April 17, 2020 21:06
Flutter BloC Tree basic concept
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:rxdart/rxdart.dart';
abstract class BlocNodeEvent extends Equatable {
@override
List<Object> get props => [];
@override
bool get stringify => true;

Keybase proof

I hereby claim:

  • I am andantonyan on github.
  • I am andantonyan (https://keybase.io/andantonyan) on keybase.
  • I have a public key ASAGJTgm0-QQEB-jsGjLdGKXWi-kXvV4bTwl2fIAFhDMsgo

To claim this, I am signing this object:

@andantonyan
andantonyan / scraping.js
Created October 20, 2015 11:58
scraping with node
'use strict;'
var Q = require('q');
var fs = require('fs');
var writeFileQ = Q.nfbind(fs.writeFile);
var rp = require('request-promise');
var cheerio = require('cheerio');
var SCRAPING_URI = 'https://www.google.com/?q=cats';