Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘

Andrew Aidurber

🤘
View GitHub Profile
@Aidurber
Aidurber / logger.ts
Created Jul 15, 2020
A simple logger
View logger.ts
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 Jun 25, 2020
Dynamic paramters Prisma 2 - Ugly. Unable to find clean abstraction in the absence of aggregations
View projects.service.ts
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 Jun 19, 2019
Type safe text search of collection
View text-search-collection.ts
/**
* 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 Jul 1, 2020
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
View cleanup.sh
# 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 / inject-to-global.js
Created Sep 7, 2018
Codemod for styled-components V4 migration from injectGlobal to createClobalStyle
View inject-to-global.js
const importRenameMap = {
injectGlobal: 'createGlobalStyle'
};
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
let source = file.source;
source = renameInjectGlobalImportWithCreateGlobal(j, j(source)).toSource();
source = renameTagTemplate(j, j(source)).toSource();
@Aidurber
Aidurber / search.cs
Created May 10, 2015
High Performance String Searching C#
View search.cs
var matches = list.AsParallel().Where(s => s.Contains(searchTerm)).ToList();
You can’t perform that action at this time.