Skip to content

Instantly share code, notes, and snippets.

View pjlamb12's full-sized avatar
🏠
Working from home

Preston Lamb pjlamb12

🏠
Working from home
View GitHub Profile
@pjlamb12
pjlamb12 / base_report.html
Created January 6, 2014 19:13
Django template for loop and if statement
{% for rank in ranks %}
{% if rank.person.id == person.id %}
<td>{{rank.get_rank_display}}</td>
<td>{{rank.start_date}}</td>
{% elif forloop.last %}
<td></td>
<td></td>
{% endif %}
{% endfor %}
@pjlamb12
pjlamb12 / page.html
Last active October 12, 2015 20:06
ng-class Issue
<ul class="search-results" ng-show="searchKeyword != '' && inputIsFocused">
<li ng-repeat="provider in providerList | searchFilter:searchFilterType:searchKeyword" ng-class="{'highlighted': provider == arrowSelectedItem}" ng-click="setSearchKeyword(provider)">{{provider.name}}</li>
</ul>
@pjlamb12
pjlamb12 / session.ts
Created April 26, 2016 15:40
NgZone After Auth0 Login
import {Injectable, NgZone} from 'angular2/core';
import {Http, Response, Headers} from 'angular2/http';
import {Router} from 'angular2/router';
import {tokenNotExpired} from 'angular2-jwt';
import 'rxjs/add/operator/map';
import {AppConfig} from '../services/config';
declare var Auth0Lock: any;
@pjlamb12
pjlamb12 / model.js
Created May 20, 2016 22:38
Sails.js Waterline Update Example
function update(args, done) {
Model.update([{id: args.id}, {id2: args.id2}], [{field1: args.field1}, {field2: args.field2}]).exec(function(err, updatedModel) {
console.log('error on update: ', err);
console.log('updated model: ', updatedModel);
return updatedModel;
});
}
@pjlamb12
pjlamb12 / child.component.ts
Last active July 18, 2016 06:19
The child component's output event is called if you call the component's onTestOutputButtonClick() function directly, but if you try and emit an event from inside the service's callback, no event is emitted.
//Component Declaration
export class ChildComponent {
@Output() onOutputEvt: EventEmitter<any> = new EventEmitter<any>();
onTestOutputButtonClick() {
this.onOutputEvt.emit({data: 'Emitted data'});
}
makeAnUpdate(form) {
this._service.makeDbCall(data).subscribe(result => {

Keybase proof

I hereby claim:

  • I am pjlamb12 on github.
  • I am pjlamb12 (https://keybase.io/pjlamb12) on keybase.
  • I have a public key ASDSwRAtv2HhIo1JyOuZe-QXS4G-9dxyH0bhwZANe0vhYwo

To claim this, I am signing this object:

@pjlamb12
pjlamb12 / angular-community-involvement.md
Last active December 14, 2020 05:56
A list of ways I've tried to be involved in the Angular community

Community Involvement — Preston Lamb

This page is no longer updated. You can view the latest information on my website. Thanks!

People Impacted: 51,428

1. Summary

  • Thinkster.io Courses: 3
  • ngWeber Events: 5
@pjlamb12
pjlamb12 / buildCE.sh
Created March 5, 2019 16:35
Angular Elements Build script
ng build --prod --output-hashing=none && cat dist/ng-elements/runtime.js dist/ng-elements/polyfills.js dist/ng-elements/scripts.js dist/ng-elements/main.js > ../demo/ngelements.js

The next Angular item we’ll test is a component. This is going to be very similar to the directive we just tested. But, even though it’ll look almost the exact same, I think it’ll be worth going through the exercise of testing the component.

This component’s purpose is to display a list of alerts that we want to show to our users. There is a related service that adds and removes the alerts and passes them along using a Subject. It is slightly complicated because we’re going to use a TemplateRef to pass in the template that the ngFor loop should use for the alerts. That way the implementing application can determine what the alerts should look like. Here’s the component:

@Component({
	selector: 'alerts-display',
	template: '<ng-template ngFor let-alert [ngForOf]="alerts$ | async" [ngForTemplate]="alertTemplate"></ng-template>',
	styleUrls: ['./alerts-display.component.scss'],
})
@pjlamb12
pjlamb12 / compodoc.js
Last active September 14, 2020 12:42
Generate Compodoc Documentation for each App and Library in an Nx workspace from a script
const angularJson = require('./angular.json');
const exec = require('child_process').exec;
const fs = require('fs');
const mainProjects = Object.keys(angularJson.projects).filter(proj => !proj.includes('e2e'));
const tsConfigPaths = parseTsconfigPaths();
function parseTsconfigPaths() {
const pathsArray = [];
for (const projectName of mainProjects) {