Skip to content

Instantly share code, notes, and snippets.

View alifhaikal88's full-sized avatar
💭
I may be slow to respond.

Alif Haikal Razak alifhaikal88

💭
I may be slow to respond.
  • Squickydoodle
  • Germany
View GitHub Profile
@jhades
jhades / 01.ts
Last active July 22, 2022 13:48
ng-template, ng-container and ngTemplateOutlet examples
@Component({
selector: 'app-root',
template: `
<ng-template>
<button class="tab-button"
(click)="login()">{{loginText}}</button>
<button class="tab-button"
(click)="signUp()">{{signUpText}}</button>
</ng-template>
@benjamincharity
benjamincharity / mockActivatedRoute.ts
Created April 12, 2017 16:23
Mock ActivatedRoute with params, data and snapshot.
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MdToolbarModule,
],
providers: [
{
provide: Router,
useClass: MockRouter,
},
@lukichev
lukichev / auth.guard.ts
Last active January 18, 2023 10:15
Role based router permissions
// auth.guard.ts
import {Injectable} from '@angular/core';
import {Router, CanActivate, RouterStateSnapshot, ActivatedRouteSnapshot} from '@angular/router';
import {AuthService} from './auth.service';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private router: Router,
private authService: AuthService) {
}
@rrrnld
rrrnld / build.gradle
Created February 3, 2017 13:40
Android build version with git commit hash
// merge this with your current build.gradle
// generates a version name from currently checked out git commit
def getCommitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
function one (x) {
console.log(x);
}
function two (x, cb) {
setTimeout(function () {
console.log(x);
cb(x);
}, 1000);
}
@odan
odan / php-pdo-mysql-crud.md
Last active December 8, 2020 23:24
Basic CRUD operations with PDO and MySQL
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="persistenceUnitName" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /> <!-- DB Driver -->
@quangnd
quangnd / reduceExamples.js
Last active November 24, 2023 19:57
Some examples about reduce() in Javascript
//Example 1 - Calculate average value of an array (transform array into a single number)
var scores = [89, 76, 47, 95]
var initialValue = 0
var reducer = function (accumulator, item) {
return accumulator + item
}
var total = scores.reduce(reducer, initialValue)
var average = total / scores.length
/*Explain about function
@jhades
jhades / 01.ts
Last active July 28, 2021 07:28
Angular Router Introduction: Child Routes, Auxiliary Routes, Master Detail - http://blog.angular-university.io/angular2-router
export const routeConfig:Routes = [
{
path: 'home',
component: Home
},
{
path: 'lessons',
component: AllLessons
}
];
@btroncone
btroncone / rxjs_operators_by_example.md
Last active March 30, 2025 21:26
RxJS 5 Operators By Example