Skip to content

Instantly share code, notes, and snippets.

View Aidurber's full-sized avatar
👁️

Andrew Aidurber

👁️
View GitHub Profile
@Aidurber
Aidurber / logger.ts
Created July 15, 2020 06:47
A simple logger
interface ILogger {
log(...args: any[]): void
error(...args: any[]): void
info(...args: any[]): void
warn(...args: any[]): void
}
type Level = 'log' | 'info' | 'warn' | 'error'
const getColor = (level: Level) => {
switch (level) {
@Aidurber
Aidurber / projects.service.ts
Last active June 25, 2020 14:47
Dynamic paramters Prisma 2 - Ugly. Unable to find clean abstraction in the absence of aggregations
export async function getAllProjectsByStatus(user: UserDto, status: Status) {
return getAllProjects(user, { status: status.toUpperCase() as Status });
}
type ProjectQuery = {
status?: Status;
type?: ProjectType;
};
export async function getAllProjects(
user: UserDto,
@Aidurber
Aidurber / text-search-collection.ts
Last active June 19, 2019 09:06
Type safe text search of collection
/**
* Perform text search on collection of object for multiple keys
*
* @export
* @template T
* @param {T[]} values - The collection
* @param {Array<keyof T>} keys - An array of properties on the object (array of strings)
* @param {string} term - Search term
* @returns
*/
@Aidurber
Aidurber / cleanup.sh
Last active September 29, 2022 13:14
A handy script to clean up a mac thanks to - Gant Laborde's article: https://medium.freecodecamp.org/how-to-free-up-space-on-your-developer-mac-f542f66ddfb
# Cleanup old node_modules
echo "Cleaning node_modules in projects older than 30 days"
find . -name "node_modules" -type d -mtime +30 | xargs rm -rf
echo "Done cleaning node_modules"
# Clean up homebrew
echo "Clean homebrew"
brew update && brew upgrade && brew cleanup
echo "Done cleaning homebrew"
@Aidurber
Aidurber / search.cs
Created May 10, 2015 08:36
High Performance String Searching C#
var matches = list.AsParallel().Where(s => s.Contains(searchTerm)).ToList();