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 / gist:69d0e95adf787222c164e1b03f06dda3
Created June 18, 2020 19:52
How to remove all the spec files from existing Angular cli project
https://stackoverflow.com/questions/55399059/how-to-remove-all-the-spec-files-from-existing-angular-cli-project
find . -type f -name '*.spec.ts' -delete
@zimejin
zimejin / gist:4e0c61911aaab9540d8a795f8f3ddadc
Last active July 3, 2020 07:32
Inline Templates Creation using the CLI
ng generate component <component-name> --inlineTemplate=true --inlineStyle=true
"@schematics/angular:component": {
"style": "scss",
"inlineTemplate": true,
"inlineStyle": true
}
@zimejin
zimejin / example.text
Last active September 15, 2020 00:53
Exit ionic 4 app on pressing back button.
import { fromEvent } from "rxjs"; // import fromEvent from rxjs
import { Router } from "@angular/router"; // import angular router as well
import { Location } from "@angular/common"; // import location from angular common,
// Inject Router and Location
constructor(private router: Router, private location: Location,) {
// Call the funtion when the app initializes at app.component.ts. it will watch for backbutton events globally in
// the application
this.backButtonEvent();
}
@zimejin
zimejin / fetch.js
Created March 20, 2020 08:19
fetch() with async and await - errors
var handleError = function (err) {
console.warn(err);
return new Response(JSON.stringify({
code: 400,
message: 'Stupid network Error'
}));
};
var getPost = async function () {
@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