Skip to content

Instantly share code, notes, and snippets.

@AlexVegner
AlexVegner / package.json
Created November 3, 2018 09:57
TypeScript
{
"name": "todo",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"babel-plugin-module-resolver": "^3.1.1",
@AlexVegner
AlexVegner / Kill all containers
Last active December 26, 2018 14:06
Docker notes
docker kill $(docker ps -q) && \
docker rm $(docker ps -a -q)
@AlexVegner
AlexVegner / smart_event_sample.dart
Last active January 19, 2020 05:06
Smart Event for bloc
abstract class BaseEvent<State, Bloc> {
Stream<State> call(Bloc bloc);
}
class AuthBloc extends Bloc<AuthEvent, AuthState> {
@override
AccountsState get initialState => InitialAuthState();
@override
Stream<AccountsState> mapEventToState(AuthEvent event) async* {
@AlexVegner
AlexVegner / dart_comments.dart
Last active January 22, 2020 11:50
dart_comments
// Single-line comments
/*
* Multi-line comments
*/
///
/// Documentation comments
///
@AlexVegner
AlexVegner / dart_main.dart
Last active January 23, 2020 15:56
dart_main.dart
/// Every app must have a top-level main() function, which serves as the entrypoint to the app.
void main() {
print('Hello, World!');
}
@AlexVegner
AlexVegner / dart_built_in_types.dart
Last active January 22, 2020 15:00
dart_built_in_types.dart
void main() {
// dynamic can take any type
dynamic dy1 = 'Text';
dy1 = 2;
// String type
String s1 = 'Hello';
String s2 = "World";
String s3 = '''
@AlexVegner
AlexVegner / dart_generics.dart
Created January 22, 2020 12:05
dart_generics.dart
void main() {}
@AlexVegner
AlexVegner / dart_list_set_map.dart
Last active January 22, 2020 15:39
dart_list_set_map.dart
void main() {
// List
List<int> list1 = [1, 2, 3]; // List<int>
List<int> list3 = []; // Empty list
List<String> list2 = ['', 'sdf', ''];
int item0List1 = list1[0]; // read value
list1[0] = 5; // set value for index = 0
list3 = [
@AlexVegner
AlexVegner / dart_default_value.dart
Created January 22, 2020 15:50
dart_default_value.dart
void main() {
/// Uninitialized variables have an initial value of null. Even variables with numeric types are initially null, because numbers—like everything else in Dart—are objects.
int lineCount;
assert(lineCount == null); // woesn't work in dartpad
print(lineCount);
// Note: Production code ignores the assert() call. During development, on the other hand, assert(condition) throws an exception if condition is false. For details, see Assert.
}
@AlexVegner
AlexVegner / dart_var_final_const.dart
Created January 22, 2020 16:07
dart_var_final_const.dart
void main() {
// var
var variable = 1; // equivalent to int a1 = 1, type calculated from right part
variable = 2; // var can be mutated
// final
final imutableVariable = 'object 1'; // final is imutable
final imutableVariable2 = 'object 1'; // will create additional instance of string 'object 1'