Skip to content

Instantly share code, notes, and snippets.

@amits97
amits97 / prerender-cloudfront.yml
Last active May 16, 2019 09:10
CloudFormation config for redirecting crawlers to Prerender.io
Parameters:
PrerenderToken:
Type: String
S3BucketName:
Type: String
Resources:
WebBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName:
@pyldin601
pyldin601 / AbstractRouterController.ts
Created September 25, 2018 08:00
inversify + koa + router
import * as Application from 'koa';
import * as KoaRouter from 'koa-router';
import { IRegistrableController } from './RegistrableController';
import { injectable } from 'inversify';
@injectable()
export abstract class AbstractRouterController implements IRegistrableController {
public abstract prefix: string;
public abstract setup(router: KoaRouter);
@bentedder
bentedder / calendar.component.html
Last active August 13, 2019 07:01
calendar component angular 4
<div class="calendar">
<div class="calendar-navs">
<div class="month-nav">
<button (click)="prevMonth()">&lt;</button>
<span class="p4">{{ currentDate.format('MMMM') }}</span>
<button (click)="nextMonth()">&gt;</button>
</div>
<div class="year-nav">
<button (click)="prevYear()">&lt;</button>
<span>{{ currentDate.format('YYYY') }}</span>
@iansinnott
iansinnott / rx-file-reader.js
Created June 5, 2017 19:36
A simple Rx abstraction over the FileReader API
/**
* Read the text contents of a File or Blob using the FileReader interface.
* This is an async interface so it makes sense to handle it with Rx.
* @param {blob} File | Blob
* @return Observable<string>
*/
const readFile = (blob) => Observable.create(obs => {
if (!(blob instanceof Blob)) {
obs.error(new Error('`blob` must be an instance of File or Blob.'));
return;
@arniebradfo
arniebradfo / any.component.html
Last active October 22, 2024 18:40
Angular *ngFor recursive list tree template
<h1>Angular 2 Recursive List</h1>
<ul>
<ng-template #recursiveList let-list>
<li *ngFor="let item of list">
{{item.title}}
<ul *ngIf="item.children.length > 0">
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container>
</ul>
</li>
</ng-template>
@TigorC
TigorC / hover-class.directive.ts
Created February 23, 2017 02:56
Angular 2 hover class directive
import { Directive, Input, HostListener, Renderer, ElementRef } from '@angular/core';
@Directive({ selector: '[hoverClass]' })
export class HoverClassDirective {
@Input()
hoverClass: string;
constructor(
public elementRef: ElementRef,
@Brooooooklyn
Brooooooklyn / ChunkUploader.ts
Created December 21, 2016 13:10
RxJS file uploader demo
import { Fetch, Utils } from 'teambition-sdk'
import { Observable } from 'rxjs/Observable'
import { Subject } from 'rxjs/Subject'
import { ReplaySubject } from 'rxjs/ReplaySubject'
import { AjaxResponse } from 'rxjs/observable/dom/AjaxObservable'
import { Subscriber } from 'rxjs/Subscriber'
import * as config from 'config'
export interface ChunkMeta {
fileType: string
@montanaflynn
montanaflynn / CONCURRENCY.md
Last active November 7, 2024 18:22
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.

@remarkablemark
remarkablemark / Dockerfile
Last active September 2, 2024 23:57
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@fer-ri
fer-ri / background-image.ts
Created May 24, 2016 06:33
Background Image Style Directive for Angular 2 and Ionic 2
import {Directive, ElementRef, Input} from '@angular/core';
@Directive({
selector: '[background-image]'
})
export class BackgroundImage {
private el: HTMLElement;
constructor(el: ElementRef) {
this.el = el.nativeElement;