Skip to content

Instantly share code, notes, and snippets.

@zkkmin
zkkmin / auth.service.ts
Created Oct 10, 2018
Auth service with JWT token
View auth.service.ts
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
import * as moment from 'moment';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json'})
}
@zkkmin
zkkmin / dashboard.component.html
Created Oct 8, 2018
Fabulous dashboard content
View dashboard.component.html
<h1 class="has-text-centered is-size-1">This is your dashboard, sugar!</h1>
<div class="level">
<div class="level-item">
<img src="http://1.bp.blogspot.com/-bTzYQL5GMGU/UTxKjVrQPQI/AAAAAAAAATI/AB6fJEWU-Qk/s1600/exterface_unicorn_03.jpg">
</div>
</div>
@zkkmin
zkkmin / app.component.ts
Created Jun 30, 2018
Calling child component's function from parent view
View app.component.ts
import { Component, ViewChild } from '@angular/core';
import { RandomQuoteComponent } from './random-quote/random-quote.component'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
@ViewChild(RandomQuoteComponent)
View random-quote.component.ts
import { Component, OnInit } from '@angular/core';
import { QuoteService } from '../quote.service';
@Component({
selector: 'app-random-quote',
templateUrl: './random-quote.component.html',
styleUrls: ['./random-quote.component.css']
})
export class RandomQuoteComponent implements OnInit {
View quote.service.ts
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class QuoteService {
private quoteUrl = "https://talaikis.com/api/quotes/random/";
View app.component.html
<!--The content below is only a placeholder and can be replaced.-->
<section class="hero is-info is-fullheight is-bold ">
<div class="hero-head">
<app-header></app-header>
</div>
<div class="hero-body">
<div class="container has-text-centered">
<h1 class="title">
View footer.component.html
View header.component.html
<nav class="navbar">
<div class="navbar-brand">
<a class="navbar-item">
<img src="https://bulma.io/images/bulma-logo.png">
</a>
</div>
</nav>
View call_api_thread.py
from threading import Thread
class APIThread(Thread)
def __init__(self, data):
self.data = data
Thread.__init__(self)
def run(self)
# call external api
@zkkmin
zkkmin / routes.kml
Created Jun 22, 2017
Sample KML file for barrier-free routes with source and destination postal codes pairs as route identification.
View routes.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http:www.opengis.net/kml/2.2">
<Document>
<Style id="redLinePoly">
<LineStyle>
<color>ff0000ff</color>
<width>4</width>
</LineStyle>
</Style>
<Placemark>