Skip to content

Instantly share code, notes, and snippets.

import { Directive, ElementRef } from '@angular/core';
@Directive({ selector: 'img' })
export class LazyImgDirective {
constructor({ nativeElement }: ElementRef<HTMLImageElement>) {
const supports = 'loading' in HTMLImageElement.prototype;
if (supports) {
nativeElement.setAttribute('loading', 'lazy');
} else {
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
@mikermcneil
mikermcneil / query-multiple-models-in-sails-controller-action.js
Created September 16, 2015 19:05
Querying multiple models from a controller action in Sails
//...
showSchoolDetailPage: function (req, res) {
if (!req.param('id')) {
return res.badRequest('The id of the school (`id`) is a required parameter!');
}
// Look up the school, it's associated image, and the associated list of students.
School.findOne({
id: req.param('id')
@mschierberl
mschierberl / railo_cloudformation.json
Created September 19, 2012 04:07
Railo CloudFormation example with nginx
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation template to deploy railo4/tomcat7/nginx.",
"Parameters" : {
"KeyName" : {
"Default" : "bacfug",
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
@mschierberl
mschierberl / web.xml
Created September 18, 2012 20:32
Railo Web
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>