Skip to content

Instantly share code, notes, and snippets.

View angularx-breadcrumb.component.ts
import { Component } from '@angular/core';
import { ActivatedRouteSnapshot, NavigationEnd, Params, PRIMARY_OUTLET, Router } from '@angular/router';
import { filter } from 'rxjs/operators';
interface BreadcrumbItem {
label: string;
params?: Params;
url: string;
}
View rxjs-btn-show-more-hide-btn.js
private initSuggestionsMoreBtn(): void {
Observable.fromEvent(this.moreSuggestionsBtn.nativeElement, 'click')
.mapTo(this.stepSuggestions)
.scan((acc, cur) => {
return acc < this.suggestions.length ? acc + cur : this.initialLimitSuggestions;
}, this.initialLimitSuggestions)
.takeUntil(this.onDestroy$)
.subscribe(
res => {
this.limitSuggestions = res;
@jrmlstf
jrmlstf / 0_reuse_code.js
Created Mar 4, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View geoloc-delay.js
console.log('geoloc start');
var geolocStart = +new Date();
navigator.geolocation.getCurrentPosition(
function (position) {
console.log('geoloc end');
var min = 5000,
start = geolocStart,
end = position.timestamp,
elapsed = end - start;
View gist:7115874
[
{ "keys": ["super+shift+r"], "command": "reindent", "args": {"single_line": false} },
{ "keys": ["super+shift+e"], "command": "abacus" },
{ "keys": ["super+alt+k"], "command": "fold_by_level", "args": {"level": 1} },
{ "keys": ["super+alt+,"], "command": "fold_by_level", "args": {"level": 2} },
{ "keys": ["super+alt+i"], "command": "fold" },
{ "keys": ["super+alt+j"], "command": "unfold" }
]
View WrapRenderFunction.js
(function () {
var TestView = Backbone.View.extend({
el: '#container',
initialize: function () {
console.log('Inside Init');
@jrmlstf
jrmlstf / pginit.js
Last active Dec 17, 2015
Init app ondeviceready or load if it's a phonegap app or not. From https://github.com/triceam/PhoneGap-Legends/blob/master/js/index.js
View pginit.js
//detect if web or phonegap ( via http://stackoverflow.com/questions/8068052/phonegap-detect-if-running-on-desktop-browser)
function isPhoneGap() {
return ((cordova || PhoneGap || phonegap)
&& /^file:\/{3}[^\/]/i.test(window.location.href)
&& /ios|iphone|ipod|ipad|android/i.test(navigator.userAgent)) ||
window.tinyHippos; //this is to cover phonegap emulator
}
function init(event) {
console.log("init app");