Skip to content

Instantly share code, notes, and snippets.

private int[,] grid;
public static int DEAD_CELL = 0;
public static int LIVING_CELL = 1;
private int rowCount;
private int columnCount;
public GameOfLife(int rowCount, int columnCount)
{
grid = new int[rowCount, columnCount];
this.rowCount = grid.GetLength(0);
@dpedro
dpedro / a2-lazy-loading
Created March 2, 2017 22:06
Lazy-loading content with angular-cli
https://keathmilligan.net/lazy-loading-content-with-angular-cli/
@dpedro
dpedro / GIT
Created March 2, 2017 22:05
GIT basic commands
# Create Branch
git checkout feature_branch
# Merge Master into my feature branch
git merge master
# Add all files and commit them
git add -A
git commit
@dpedro
dpedro / a2-forms-select-custom-selection
Created March 2, 2017 21:48
Set selected item via ngModel
You don't need to use [attr.selected].
[(ngModel)]="user.role" is two-way data-binding,
it will select the matched option from your list if value is equal to user.role. And you can also use basic [value]
<select name="role" [(ngModel)]="user.role">
<option *ngFor="let role of roles" [value]="role">{{role.name}}</option>
</select>
@dpedro
dpedro / a2-forms-select-value
Created March 2, 2017 21:37
Get selected value from select
If you don't need two-way data-binding:
<select (change)="onChange($event.target.value)">
<option *ngFor="let i of devices">{{i}}</option>
</select>
onChange(deviceValue) {
console.log(deviceValue);
}
For two-way data-binding, separate the event and property bindings:
@dpedro
dpedro / a2-forms-singleControl
Last active October 20, 2023 11:45
Single form control (without FormGroup)
<!--
Sometimes, we don’t need a FormGroup, as our form might only consist of a single form control. Think of a search field that let’s you search for products in an e-commerce application. Technically, we don’t even need a <form> element for that.
Angular comes with a directive formControl which doesn’t have to be inside a formGroup. We can simply add it to a single form control and are ready to go:
-->
<!-- no surrounding form -->
<input type="search" [formControl]="seachControl">
<!--
The cool thing about form controls in Angular is,
/*
JavaScript classes are introduced in ECMAScript 6 and are syntactical sugar over JavaScript's existing prototype-based inheritance.
The class syntax is not introducing a new object-oriented inheritance model to JavaScript. JavaScript classes provide a much simpler and clearer
syntax to create objects and deal with inheritance.
*/
var Users = class {
constructor(fullName, description) {
this.fullName = fullName;
this.description = description;
@dpedro
dpedro / array-key-value
Last active August 10, 2016 15:30
Array by key, value
var users = [];
users['john'] = { id: 'john01', role: 'admin' };
users['bob'] = { id: 'bob01', role: 'reader' };
console.log(users);
console.log(users['bob']);
console.log(Object.keys(users).length)
/*
@dpedro
dpedro / object-key-value
Last active August 10, 2016 15:07
Object by key, value
var users = {}
users = {
"john": { id: 'john01', role: 'admin' },
"bob": { id: 'bob01', role: 'reader' },
}
users["steeve"] = { id: 'steeve01', role: 'admin' };
console.log(users);
console.log(users['bob']);
@dpedro
dpedro / introrx.md
Created July 15, 2016 19:53 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing