Skip to content

Instantly share code, notes, and snippets.

Andrew Lewis andlewis

Block or report user

Report or block andlewis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andlewis
andlewis / Use Ping Tracker
Created May 29, 2019
Angular - add a ping attribute to every a tag on the page
View Use Ping Tracker
ngAfterViewChecked() {
let count = 0;
Array.from(document.getElementsByTagName('a')).filter((x: any) => !x.ping).forEach((x: any) => { x.ping = this.metricsUrl; count++ });
if (count > 0) {
console.log(`ngAfterViewChecked. ${count} linked updated`);
}
}
@andlewis
andlewis / index.js
Created Dec 30, 2018
Return a random image from a folder
View index.js
const express = require('express');
const recursive = require('recursive-readdir');
const app = express();
const port = 3000;
var images = [];
app.get('/', (req, res) => {
var image = images[Math.floor(Math.random() * images.length)];
res.sendFile(image);
@andlewis
andlewis / AuthorService.cs
Created Feb 10, 2012 — forked from mythz/AuthorService.cs
1 class in ServiceStack
View AuthorService.cs
/*
With no other C# or config other than OrmLite DB config in AppHost below - this web service provides all the screenshots attached, out-of-the-box, for free.
Code-first Simplicity at Great Speed - http://www.servicestack.net/benchmarks/
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(ConfigUtils.GetConnectionString("AppDb"), //ConnectionString in Web.Config
SqlServerOrmLiteDialectProvider.Instance) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) });
You can’t perform that action at this time.