Skip to content

Instantly share code, notes, and snippets.

View davidmarquis's full-sized avatar

David Marquis davidmarquis

View GitHub Profile
@davidmarquis
davidmarquis / angular2-if-media-query-directive.ts
Last active March 26, 2021 05:08
Angular 2: Conditional output from media query using a structural directive
import { Directive, TemplateRef, ViewContainerRef } from "@angular/core";
import { isBlank } from "@angular/core/src/facade/lang";
/**
* How to use this directive?
*
* ```
* <div *ngIfMediaQuery="'(min-width: 500px)'">
* Div element will exist only when media query matches, and created/destroyed when the viewport size changes.

Keybase proof

I hereby claim:

  • I am davidmarquis on github.
  • I am davidmarquis (https://keybase.io/davidmarquis) on keybase.
  • I have a public key ASC4fsgvckvQCU3bPBpBYwAZQkOdhlfg_qZodcxAEais3go

To claim this, I am signing this object:

@davidmarquis
davidmarquis / angular2-lazy-load-images-with-blazy.ts
Last active April 11, 2017 13:22
Angular 2: Lazy-loading images using bLazy.js
import { Directive, ElementRef, Input, AfterViewChecked, OnDestroy } from "@angular/core";
import * as Blazy from "blazy";
/**
* Directive to setup lazy image loading using bLazy.
* Apply the directive on a container element that is a parent of `img` elements configured for bLazy.
* The container element must have an ID and be scrollable (overflow: scroll).
*
* Sample usage:
*
@davidmarquis
davidmarquis / django_cms_disable_toolbar.py
Created August 7, 2015 17:51
Django CMS disable toolbar for specific URLs
"""
Hi-jacked version of Django CMS's toolbar middleware that
excludes the toolbar from specific URLs (as defined in settings).
To use it, replace 'cms.middleware.ToolbarMiddleware' with a
reference to this class.
Then set `CMS_TOOLBAR_EXCLUDED_URLS` in your Django settings:
```
CMS_TOOLBAR_EXCLUDED_URLS = [