Kim's Workstation
(As shown in this tweet from September 8, 2020)
(As shown in this tweet from September 8, 2020)
/** | |
* Register Activities as a custom post type | |
*/ | |
function cpt_register_activities() { | |
$labels = array( | |
"name" => __( "Activities", "twentytwenty" ), | |
"singular_name" => __( "Activity", "twentytwenty" ), | |
"menu_name" => __( "Activities", "twentytwenty" ), | |
"all_items" => __( "All Activities", "twentytwenty" ), | |
"add_new" => __( "Add New Activity", "twentytwenty" ), |
// Username regex | |
// Starts with @ | |
// Can contain only numbers, lowercase letters, -, ., _ | |
// NOTE: this can be avoided by escaping characters (slash command settings) | |
const usernameRegex = /^@+[0-9a-z_\-.]*$/; | |
// Get all user ID mentions from a string | |
// <@UXXXX|user> (slash commands) | |
// <@UXXXX> (app mention text) | |
// Returns an array of user mentions |
import { Injectable } from '@angular/core'; | |
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http'; | |
import { AuthService } from './../auth/auth.service'; | |
import { Observable } from 'rxjs/Observable'; | |
import { catchError } from 'rxjs/operators'; | |
import 'rxjs/add/observable/throw'; | |
import { ENV } from './env.config'; | |
import { EventModel } from './models/event.model'; | |
import { RsvpModel } from './models/rsvp.model'; |
service cloud.firestore { | |
match /databases/{database}/documents { | |
match /<COLLECTION_NAME>/{document=**} { | |
allow read: if true; | |
allow create: if request.auth != null && request.auth.uid == request.resource.data.uid; | |
allow update, delete: if request.auth != null && request.auth.uid == resource.data.uid; | |
} | |
} | |
} |
{ | |
"rules": { | |
".read": "true", | |
".write": "auth != null", | |
"<ITEMS>": { | |
".indexOn": "<PROPERTY TO INDEX BY>", | |
"$comment": { | |
".write": "(!data.exists() && newData.child('uid').val() == auth.uid) || (data.exists() && data.child('uid').val() == auth.uid && !newData.exists()) || (data.exists() && data.child('uid').val() == auth.uid && newData.child('uid').val() == auth.uid)" | |
} | |
} |
newlinesToMarkup(text) { | |
const withPTags = '<p>' + text.replace(/\n([ \t]*\n)+/g, '</p><p>').replace('\n', '<br>') + '</p>'; | |
return withPTags; | |
} |
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { CoreModule } from './core/core.module'; | |
@NgModule({ | |
declarations: [], | |
imports: [ | |
BrowserModule, | |
CoreModule.forRoot() |
const indexOfObj = (array, key, value) => { | |
for (let i = 0; i < array.length; i++) { | |
if (array[i][key] === value) { | |
return i; | |
} | |
} | |
return -1; | |
}; |
import { Component, OnInit, Input, OnDestroy } from '@angular/core'; | |
import { expandCollapse } from './expandCollapse.animation'; | |
@Component({ | |
selector: 'app-anim', | |
animations: [expandCollapse], | |
template: ` | |
<button (click)="toggle()">{{showText}}</button> | |
<div *ngIf="show" [@expandCollapse]> | |
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vestibulum bibendum justo sed posuere. Integer consequat nec nisi ac lacinia. Nulla a urna at risus tempus mattis a ut sapien. Mauris eleifend ornare nibh, a semper ligula hendrerit ut. Nullam sit amet elementum mauris, ac lobortis lacus. Cras vestibulum pellentesque ligula vel laoreet. Vivamus eget nibh consequat, viverra mi vel, commodo lectus. Donec cursus aliquam purus nec blandit. Etiam et pellentesque diam, at egestas nisl. Mauris faucibus non erat quis malesuada.</p> |