Skip to content

Instantly share code, notes, and snippets.

@zimejin
zimejin / simpleNotetaker.html
Created July 28, 2019 09:25
Vannila JS Note taker challenge
<!DOCTYPE html>
<html lang="en">
<body>
<html>
<head>
<title>Note Taker</title>
</head>
@zimejin
zimejin / AngularDom.ts
Last active September 19, 2019 10:32
Two kinds of ViewChild and Their returns
@ViewChild('bioRef', {read: ElementRef}) private bioRef: ElementRef;
@ViewChild('passwordRef', {read: ElementRef}) private passwordRef: ElementRef;
// returns
ElementRef {nativeElement: ion-radio.md.in-item.interactive.hydrated}
// native element
<ion-radio _ngcontent-ibt-c6="" slot="start" value="fingerprint" ng-reflect-value="fingerprint" role="radio"
aria-checked="false" aria-labelledby="ion-rb-1-lbl" class="md in-item interactive hydrated"></ion-radio>
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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
},
{