Skip to content

Instantly share code, notes, and snippets.

@lexeek
lexeek / index.html
Created June 1, 2022 22:22 — forked from archetana/index.html
Pan and Zoom in jsPlumb Community Edition with Dagre and jQueryUI Draggable
<div class="container">
<div class="panzoom">
<div class="diagram">
<div id="i0" class="item">Root!</div>
<div id="i1" class="item">Child 1</div>
<div id="i11" class="item">Child 1.1</div>
<div id="i12" class="item">Child 1.2</div>
<div id="i2" class="item">Child 2</div>
<div id="i21" class="item">Child 2.1</div>
<div id="i3" class="item">Child 3</div>
@lexeek
lexeek / index.html
Created February 7, 2019 16:42 — forked from mike-douglas/index.html
Most simple d3.js stack bar chart from matrix
<!DOCTYPE html>
<html>
<head>
<title>Simple Stack</title>
<script src="http://d3js.org/d3.v2.js"></script>
<style>
svg {
border: solid 1px #ccc;
font: 10px sans-serif;
shape-rendering: crispEdges;
@christianlacerda
christianlacerda / firestore-field-filter.ts
Last active April 28, 2023 05:18
Filters Firestore events based on field name and event type
import * as admin from 'firebase-admin';
import { Change, EventContext } from 'firebase-functions';
import { isEqual } from 'lodash';
import DocumentSnapshot = admin.firestore.DocumentSnapshot;
import FieldPath = admin.firestore.FieldPath;
const isEquivalent = (before: any, after: any) => {
return before && typeof before.isEqual === 'function'
? before.isEqual(after)
@nothingismagick
nothingismagick / caret.js
Last active December 15, 2024 18:17
Small script to detect caret pixel position in contenteditable div
/**
* Get the caret position in all cases
*
* @returns {object} left, top distance in pixels
*/
getCaretTopPoint () {
const sel = document.getSelection()
const r = sel.getRangeAt(0)
let rect
let r2
@archetana
archetana / index.html
Created July 6, 2018 12:52
Pan and Zoom in jsPlumb Community Edition with Dagre and jQueryUI Draggable
<div class="container">
<div class="panzoom">
<div class="diagram">
<div id="i0" class="item">Root!</div>
<div id="i1" class="item">Child 1</div>
<div id="i11" class="item">Child 1.1</div>
<div id="i12" class="item">Child 1.2</div>
<div id="i2" class="item">Child 2</div>
<div id="i21" class="item">Child 2.1</div>
<div id="i3" class="item">Child 3</div>
@praveenpuglia
praveenpuglia / same-effect-multiple-actions.ts
Created April 25, 2018 19:04
Same effect for multiple actions - ngrx effects
@Effect({dispatch: false})
entityCreationSuccess$: Observable<Action> = this.actions$.pipe(
ofType(UserActions.CREATE_USER_SUCCESS, PostActions.CREATE_POST_SUCCESS),
tap(action => {
this.router.navigate(['../'], {relativeTo: this.route})
})
);
@peterbsmyth
peterbsmyth / recipe.example.md
Last active May 21, 2020 13:39
Making chained API Calls using @ngrx/Effects

Making chained API Calls using @ngrx/Effects

Purpose

This recipe is useful for cooking up chained API calls as a result of a single action.

Description

In the below example, a single action called POST_REPO is dispatched and it's intention is to create a new repostiory on GitHub then update the README with new data after it is created.
For this to happen there are 4 API calls necessary to the GitHub API:

  1. POST a new repostiry
  2. GET the master branch of the new repository
  3. GET the files on the master branch
@caroso1222
caroso1222 / dom.service.ts
Last active August 18, 2023 13:34
Service to dynamically append Angular components to the body
import {
Injectable,
Injector,
ComponentFactoryResolver,
EmbeddedViewRef,
ApplicationRef
} from '@angular/core';
@Injectable()
export class DomService {
@Tuizi
Tuizi / test-helper.spec.ts
Last active March 19, 2021 19:47
MockStore for Angular ngrx/store unit tests
import { Action, ActionReducer, Store } from '@ngrx/store';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable';
import { map } from 'rxjs/operator/map';
import { Observer } from 'rxjs/Observer';
// TODO: How to initialize those variables?
const dispatcherMock: Observer<Action>,
reducerMock: Observer<ActionReducer<any>>,
stateMock: Observable<any>;
# Shorthand Git CLI syntax + better git log
# Better git log
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
function gs {
git status
}
function gd {