Skip to content

Instantly share code, notes, and snippets.

@faisalmuhammad
faisalmuhammad / development-only.directive.ts
Last active July 13, 2018 18:29
Angular | Development Only Directive
/**
* @author Muhammad FAISAL
* @description Controls the display of html contents only during development mode.
* @example <button development-only>Some Button</button>
*/
// Angular Imports
import { Directive, OnInit, ElementRef, isDevMode } from '@angular/core';
// Define class for the Directive

Visual Studio Code shortcuts I use often

Navigation

Sidebar:

  • Cmd-Shift-F: search
  • Cmd-Shift-E: files

Navigating in current editor:

@gsans
gsans / router-transitions-util.md
Last active April 21, 2018 15:04
Refactoring router transitions

yummy

Refactoring multiple router transitions - Angular (v5+)

We can apply this refactor when we identify a group of transitions running the same animation following the same pattern.

Code:

// BEFORE
ngOnInit() {
this.filteredRoutes$ = from(this.routes).pipe(
concatMap((route) => {
// handle if nothing is in canActivate
if (!route.canActivate || !route.canActivate.length) {
// create an object that has the route and result for filtering
return of({ route, result: true });
}
return from(route.canActivate).pipe(
@steven2358
steven2358 / ffmpeg.md
Last active April 30, 2026 20:08
FFmpeg cheat sheet
public muteFirst = <T,R>(first$: Observable<T>, second$: Observable<R>) => Observable.combineLatest(
first$,
second$,
(a,b) => b
).distinctUntilChanged();
@faisalmuhammad
faisalmuhammad / local-storage.ts
Last active October 15, 2020 13:12
Generic Local Storage Class
/**
* Customized HTML5 local storage class with additional functionality.
*/
export class LocalStorage {
/**
* Checks if the browser supports local storage.
* @returns true if the local storage is supported; false otherwise.
*/
public static isSupported(): boolean {
try {
@manio
manio / waga.sh
Created March 8, 2017 07:48
a simple bash script for weight logging automation to myfitnesspal and influxdb
#!/bin/bash
# a simple bash script for weight logging automation
# more info: https://skyboo.net/2017/03/automate-my-weekly-weight-logging/
if [[ $# -eq 0 ]]; then
echo "[*] ERROR: missing weight argument"
exit
fi
echo "[*] **** MyFitnessPal ****"
@squallstar
squallstar / viewer.html
Created January 26, 2017 21:20
Pinch gestures for pdf.js
<script type="text/javascript">
var gesturesSetUp = false;
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1;
document.addEventListener('textlayerrendered', function (e) {
if (gesturesSetUp || e.detail.pageNumber !== PDFViewerApplication.page) {
return;
}