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 / 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 / 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 / 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 / utils.js
Last active August 17, 2020 13:47
array utilities
// Using slice() to Remove value from beginning and end of string.
sliceString = function (value) {
let result = value.slice(1, -1);
return result;
}
// Using splice() method to changes the contents of an array by removing
// or replacing existing elements and/or adding new elements
var months = ['Jan', 'March', 'April', 'June'];
@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 / 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 / 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 / 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 () {