Skip to content

Instantly share code, notes, and snippets.

View AndrewAllison's full-sized avatar

Andy Allison AndrewAllison

View GitHub Profile
<div fxLayout="column">
<div fxLayout="row">
<div fxFlex fxLayout="column">
<!-- GHOST ELEMENT -
Similar to Chosen with hidden selects....
We use this as a container becasue the changes don't bind well to a textarea it doesn't fire the correc caret event to track length.. !!!!-->
<div style="display:none" class="emoji-content-editable textarea" (emojiPickerCaretEmitter)="handleCurrentCaret($event)"
(input)="content = $event.target.textContent" [textContent]="content" contenteditable="true">
</div>
<md-input-container *ngIf="type === 'standard'" class="full-width" floatPlaceholder="never">
@AndrewAllison
AndrewAllison / clean.ps1
Last active November 3, 2017 06:23
Clean AWS stuffs
$array = aws s3api list-buckets --query "Buckets[].Name" | Where { $_ -like "*.tb-*" -and $_ -notlike "*.tb-nav*" }
"Found $array.Length buckets"
$count = 0
for ($i=0; $i -lt $array.Length; $i++) {
$count = $i + 1
$bucket = $array[$i] -replace '"' -replace ','
$bucket = $bucket.Trim()
@AndrewAllison
AndrewAllison / pin.ps1
Created November 3, 2017 07:19
Useful ping
Test-NetConnection 35.197.254.126 -port 11211
@AndrewAllison
AndrewAllison / main.ts
Last active December 2, 2017 10:19
RXJS using Take while
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
// Common rxjs operators
import 'rxjs/add/operator/takeWhile';
if (environment.production) {
@AndrewAllison
AndrewAllison / SearchType.component,html
Created December 4, 2017 08:30
Using reactive forms in a nice simple manner
<div [formGroup]="searchTermFormGroup">
<mat-form-field>
<input matInput formControlName="searchValueControl">
<mat-error>
Search term
<strong>required</strong>
</mat-error>
</mat-form-field>
</div>
@AndrewAllison
AndrewAllison / fake-http-client.spec.ts
Created December 13, 2017 15:40 — forked from dherges/fake-http-client.spec.ts
Angular HttpClient (3)
describe(`FakeHttpClientResponses`, () => {
it(`should expect a GET /foo/bar`, async(inject([HttpClient, HttpTestingController],
(http: HttpClient, backend: HttpTestingController) => {
http.get('/foo/bar').subscribe();
backend.expectOne({
url: '/foo/bar',
method: 'GET'
});
@AndrewAllison
AndrewAllison / strong-password-regex.md
Created September 13, 2019 16:56 — forked from arielweinberger/strong-password-regex.md
Strong password Regular Expression - NestJS Course
  • Passwords will contain at least 1 upper case letter
  • Passwords will contain at least 1 lower case letter
  • Passwords will contain at least 1 number or special character
  • There is no length validation (min, max) in this regex!

Regular expression for JavaScript:

/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
@AndrewAllison
AndrewAllison / last24_hrs.js
Created September 18, 2019 05:18
Mongo Queries
db.system.profile.find({
"timestamp" : {
$lt: new Date(),
$gte: new Date(new Date().setDate(new Date().getDate()-1))
}
})
@AndrewAllison
AndrewAllison / grain.cs
Created October 9, 2019 07:57
Common C# test type thangs
using System;
/// <summary>
/// Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
/// </summary>
public static class Grains
{
public static ulong Square(int n)
{
if (n <= 0 || n > 64)
@AndrewAllison
AndrewAllison / Acronym.cs
Created October 9, 2019 07:59
Make nice Acronyms out of sentences.
using System;
using System.Linq;
using System.Text.RegularExpressions;
public static class Acronym
{
public static string Abbreviate(string phrase)
{
// Only letters, hyphens and spaces
phrase = new Regex("[^A-Za-z -]").Replace(phrase, "").ToUpperInvariant();