Skip to content

Instantly share code, notes, and snippets.

@jeffwhelpley
jeffwhelpley / icon.component.ts
Last active October 24, 2024 04:50
An awesome icon component I created for Angular
import { Component, Input, ElementRef, Renderer2, PLATFORM_ID } from '@angular/core';
import { isPlatformServer } from '@angular/common';
import { RequestResponseAdapter } from '@gethuman/adapters';
import { config } from '@gethuman/config';
import { GhWebState } from '@gethuman/state';
@Component({
selector: 'icon',
standalone: true,
template: ``, // no content for <icon></icon> since we are setting a mask-image
#!/bin/sh
# this is from https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/
if [ "$#" -ne 1 ]; then
echo "Usage: Must supply a domain"
exit 1
fi
# Change these as appropriate for your organization
@jeffwhelpley
jeffwhelpley / backup.ts
Created January 22, 2020 15:45
Generate Firestore backup
export async function exportData(projectId: string, clientEmail: string, privateKey: string) {
const timestamp = moment().format('YYYY-MM-DD_x');
const name = `projects/${projectId}/databases/(default)`;
const outputUriPrefix = `gs://${projectId}.appspot.com/backups/${timestamp}`;
const fsAdmin = new v1.FirestoreAdminClient({
projectId,
credentials: {
client_email: clientEmail,
private_key: privateKey
class Cli
def run
# get the hash of fish data by scrapping the website (see further below)
fish_hash = self.get_fish_hash
# CLI stays in loop until user types quit
is_cli_active = true
while is_cli_active
@jeffwhelpley
jeffwhelpley / webpack_typescript_npmlink.md
Last active May 26, 2017 11:51
"Cannot find source file": Webpack issue compiling TypeScript project when npm linking to other TypeScript projects
@jeffwhelpley
jeffwhelpley / decorators.js
Last active February 14, 2017 02:40
Examples of different types of decorators
export function ClassDecorator(meta?: any): Function {
return function (target: any) {
let targetProto = target.prototype;
let targetMeta = targetProto.__meta = targetProto.__meta || {};
targetMeta.cls = meta;
};
}
export function MethodDecorator(meta?: any): Function {
return function (targetProto: any, methodName: string) {
server {
listen 80;
server_name dev.gethuman.com *.dev.gethuman.com;
location / {
proxy_pass http://localhost:8181;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@jeffwhelpley
jeffwhelpley / gist:2d14a615790af18b3549
Last active July 13, 2018 11:48
Using window object in Angular 2
// interface for Window
interface Window {
// add some stuff here
}
let someMockWindowObject = {
// add some mock functionality here
};
@jeffwhelpley
jeffwhelpley / sample.js
Last active September 24, 2015 14:43
Sample Angular Page
module.exports = {
model: function (postService, tokens, postUtil) {
return postService.find({ where: { urlId: tokens.urlId }, findOne: true })
.then(function (post) {
return {
pageHead: postUtil.getPageHeaderInfo(post),
post: post,
noindex: post.status === 'rejected' || !!post.duplicateOf
};
});
@jeffwhelpley
jeffwhelpley / gist:056e012544c631438ad2
Created July 12, 2015 02:06
playing nice: continuation-local-storage, hapi.js and pm2

I had a lot of issues trying to get continuation-local-storage (cls) working on a hapi.js app with pm2 in cluster_mode. Long story short, my mistake was wrapping cls around my server.start() when I should have been running it in a request handler. Here is the code you should use to get all this working:

var cls = require('continuation-local-storage');
var ns = cls.createNamespace('mySession');

var Hapi = require('hapi');
var server = new Hapi.Server();
server.connection({ port: 80 });