Skip to content

Instantly share code, notes, and snippets.

View tailorvj's full-sized avatar
💭
Playing around with Next.js

Tailor VJ tailorvj

💭
Playing around with Next.js
View GitHub Profile
@tailorvj
tailorvj / dart_operations_between_sets.dart
Created March 25, 2020 22:00
Dart operations between 2 Sets
main() {
var dividesBy2 = <int>{2,4,6,8,10,12,14,16,18,20};
var dividesBy3 = <int>{3,6,9,12,15,18,21};
var dividesBy6 = dividesBy2.intersection(dividesBy3);
print('dividesBy6: $dividesBy6\n');
var doesntDivideBy6 = dividesBy2.difference(dividesBy3);
print('doesntDivideBy6: $doesntDivideBy6\n');
@tailorvj
tailorvj / dart_Set_toList_List_toSet_example.dart
Created March 25, 2020 21:24
Dart: Convert Set to List and back again using Set.toList() and List.toSet() methods
main() {
Set<String> nameSet = {'Rita', 'Alex', 'Sam', 'Eva'};
print('nameSet: $nameSet\n'); //{Rita, Alex, Sam, Eva}
List<String> nameList = nameSet.toList();
print('nameList: $nameList\n'); //[Rita, Alex, Sam, Eva]
Set<String> nameSet2 = nameList.toSet();
print('nameSet2: $nameSet2\n'); //{Rita, Alex, Sam, Eva}
}
@tailorvj
tailorvj / dart_set_methods_example_a.dart
Created March 25, 2020 21:10
Dart Set .contains() .forEach() and .clear() methods
main() {
Set<String> nameSet = {'Rita', 'Alex', 'Sam', 'Eva'};
print('nameSet.contains(\'Sam\'): ${nameSet.contains('Sam')}\n');
nameSet.forEach((element){
print('element: $element');
});
nameSet.clear();
@tailorvj
tailorvj / dart_set_example.dart
Created March 25, 2020 19:22
Dart Set type example
main() {
Set<String> names = {'Rita', 'Alex', 'Sam', 'Eva'};
var persons = <String>{}; //inferred type Set
print('persons: $persons');
print('persons.length is ${persons.length}');
print('persons Type is ${persons.runtimeType}\n');
print('names: $names');
print('names.length is ${names.length}');
@tailorvj
tailorvj / dart_map_example.dart
Created March 25, 2020 12:37
Dart Map key value pair collection example
main() {
Map map = {
'key1': 'value1',
'key2': 'value2',
'key3': 'value3'
};
print('map.length is ${map.length}');
print('map: $map');
print('map[\'key1\'] is ${map['key1']}');
@tailorvj
tailorvj / dart_list_variable_type_example.dart
Last active March 26, 2020 19:24
Dart list variable type example
main() {
List list = [1,'two',3,'four'];
print('list.length is ${list.length}');
print('list: $list');
print('list index 1 value: ${list[1]}');
print('list index 0 value: ${list[0]}\n');
print('Adding 10 to the end of the list');
@tailorvj
tailorvj / dart_inferred_var_runtimeType.dart
Created March 25, 2020 11:26
Dart runtimeType inferred from value assigned to variable
main() {
var theNumber = 42;
const PI = 3.14159;
var theText = 'Hello World!';
var learningDart = true;
print('theNumber is type ${theNumber.runtimeType}');
print('PI is type ${PI.runtimeType}');
print('theText is type ${theText.runtimeType}');
print('learningDart is type ${learningDart.runtimeType}');
@tailorvj
tailorvj / dart_StringBuffer_example.dart
Last active April 7, 2020 06:25
Dart StringBuffer example
main() {
StringBuffer sb = new StringBuffer('initial_content');
print('sb.length is ${sb.length}');
print('${sb.toString()}\n');
sb.write("_Hello");
sb.writeAll(['_space', '_and', '_more']);
print('sb.length is ${sb.length}');
@tailorvj
tailorvj / the-most-basic-void-main.dart
Last active April 15, 2020 10:08
The most basic Dart app in the world
void main(){
print("App started");
App(); //no need to use the new keyword in Dart
print("App finished");
}
class App{
App(){
print("Constructing a class.");
}
import firebase from 'firebase/app';
import 'firebase/firestore';
const firebaseConfig = firebase.initializeApp({
//create a Firestore database in your Firebase project and
//replace only the internal part of this object from your Firebase web settings
apiKey: "",
authDomain: "your.firebaseapp.com",
databaseURL: "https://your.firebaseio.com",
projectId: "yourprojectid",