Skip to content

Instantly share code, notes, and snippets.

// we are now also importing SweetAlertOptions in our decorator
import Swal, {SweetAlertOptions} from 'sweetalert2';
// Confirmable is now a factory function, with an optional parameter object
export function Confirmable(options?: SweetAlertOptions) {
// our factory function will return our actual decorator function, but now we have
// an actual options object to configure our alert box :)
return (target: Object, propertyKey: string, descriptor: PropertyDescriptor) => {
// the usual, caching the original implementation
<button (click)=”deleteItem()”>Delete item</button>
@zimejin
zimejin / songs.json
Created March 3, 2021 22:08
A sample collection of songs in valid JSON (RFC 8259) format. The rank matches the Rolling Stone's list of the 500 greatest songs of all time.
{
"songs":[
{
"title":"Like a Rolling Stone",
"artist":"Bob Dylan",
"album":"Highway 61 Revisited",
"year":1965,
"rank":1
},
{
@zimejin
zimejin / test.2.js
Created March 16, 2020 19:35
Zalando - Coding Test
'use strict';
/* global CustomError, getLikedBrands, getTopBrandsForGender */
function solution(U, N) {
return new Promise((resolve, reject) => {
// Uniq function
const uniq = list => Array.from( new Set(list) )
@zimejin
zimejin / multiple-push-urls.md
Last active July 1, 2020 12:13 — forked from bjmiller121/multiple-push-urls.md
Add multiple push URLs to a single git remote

Sometimes you need to keep two upstreams in sync with eachother. For example, you might need to both push to your testing environment and your GitHub repo at the same time. In order to do this simultaneously in one git command, here's a little trick to add multiple push URLs to a single remote.

Once you have a remote set up for one of your upstreams, run these commands with:

git remote set-url --add --push [remote] [original repo URL]
git remote set-url --add --push [remote] [second repo URL]

Once set up, git remote -v should show two (push) URLs and one (fetch) URL. Something like this:

@zimejin
zimejin / invoice.js
Created September 30, 2019 14:19 — forked from tusharf5/invoice.js
Invoice Template pdfMake
// try here http://pdfmake.org/playground.html
var dd = {
content: [
{
columns: [
{
image:
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABjCAYAAADeg0+zAAAACXBIWXMAABYlAAAWJQFJUiTwAAAQbUlEQVR42u1dh3tUVRbnf9hvv5WuJBAkhZKEJEAoZkICBKWpVAUERClSFQgl9CZIjYAiuAvLoq4FdEURRQQVFUGa9A5SpUsJ4ez9nXn35c3kvZk3aQQ49/t+32TevHLL+d1T7rkvZWrEPkECgcAeZaQTBAIhiEAgBBEIhCACgRBEIBCCCARCEIFACCIQCEEEAiGIQCAQgggEQhCBQAgiEAhBBAIhiEAgBBEIhCACgRBEIBCCCARCEOkIgUAIIhAIQQQCIYhAIAQRCIQgAoEQRCAQgggEQhCBQAgiEAiEIAKBEEQgEIIIBEIQgUAIIhAIQQQPOh6v08TVMSFIATuzuO7t9Cy35xXmOQVtZyjXBTq3IL/heEGeHxmXQlHxHh/g2P1IlDL3khi6s6rXbkzVajaiiFqNqJofIiyfOF93Pj7dDnoEX9/YdtDz6tCE6xCqYOrz8Il6oi3+z7F+Rvi1y7+t+notWG7r4v8M/34LRlzb61z2hXVc8D0sqgFVikigitXqMvA3jul2RcbdP0QpFRqkTr1mlNj4SYpLbmGLeAWcg/MfrZFEFVSnV41pyJ0daJbTv9Vt1JJiGzQPeF7NhKZch2ACFUhAcH2tpDRTyO0EEe1JUPWxayfqGF03lcKiG1DFCK9wgdhuiaJ/r9swgxJUXYD45AzXGqRuw5aW61pQjTrurkP9MB4YFxxLb9WFuvceQv0Gj2J06z2Y0p7qzP2Cc6rVbBgS+R9agkTFp1Dlx5NowdvL6Pr1v+jSpct09dp1W1y5cpX+vHiJtmzbQVN
import { Component, OnInit } from '@angular/core';
import { UserAsyncService } from './user-async.service';
import { Observable } from 'rxjs';
@Component({
selector: 'app-user-async',
templateUrl: './user-async.component.html',
styleUrls: ['./user-async.component.scss'],
providers: [UserAsyncService]
})
export interface GoogleData {
id: number;
country: string;
zipCode: string;
}
import { async, TestBed } from '@angular/core/testing';
import { UserComponent } from './user.component';
import { UserService } from './user.service';
describe('UserComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [UserComponent]
import { Observable, Observer } from 'rxjs';
export class UserAsyncService {
user = { name: 'Mannie' };
getUserDetails() {
// Create an observables.
const userObservables = Observable.create(
(observer: Observer<{ name: string }>) => {
setTimeout(() => {
observer.next(this.user);