Skip to content

Instantly share code, notes, and snippets.

@bradkovach
bradkovach / README.md
Created November 18, 2024 17:45
Annotated, useful eslint no-restricted-syntax rules

These examples of the eslint no-restricted-syntax rule that demonstrate how you can use ESQuery to pin down structural code problems. While these examples are written for modern ESLint 8+ Flat Configuration, they are easily adapted to the older eslintrc format.

I hope to keep this updated as I develop more rules.

Some helpful tools for developing your own selectors for no-restricted-syntax:

@bradkovach
bradkovach / migration.md
Created February 16, 2023 05:34
Consolidating many angular micro-frontends into a single workspace...

In our case, the app source and build folders will still be within the respective projects, but now contained within a parent Angular workspace and npm package...

Benefits

  • Faster, easier updates
  • Less redundant code/architecture
  • Increased developer productivity (by spending less time fighting the architecture and overhead)
  • Code reuse.

One of our big goals is to get our 21 separate single-app Angular workspaces all to a single Angular workspace with many apps and projects. Currently, shamefully, we are at version 9. We want to enable trivial fast updates, and then keep the apps updated w/ a few mins of maintenance between each sprint moving forward.

@bradkovach
bradkovach / discord.sh
Last active June 4, 2021 17:16
PulseAudio script to allow Discord/etc to capture application audio AND microphone without microphone echo
#!/bin/bash
# Acknowledgements
# This script made heavy use of the guide at https://www.reddit.com/r/discordapp/comments/f22vz6/guide_how_to_stream_audio_to_discord_on_linux/
# and also the guide at https://endless.ersoft.org/pulseaudio-loopback/
# Gotchas
# The Discord app does not let me select the V1 input directly, so I have to use pavucontrol to change the input device *outside* of Discord
# The name of the input will not update within discord, but it should work properly.
@bradkovach
bradkovach / ScopeTree.ts
Last active May 15, 2021 17:56
Tree with namespaces
import { RegEx } from "../Helpers";
import * as _ from 'underscore';
interface IScopeNodeIndex<T> {
[path: string]: ScopeNode<T>
}
export class ScopeNode<T> {
constructor(
public value: T,
@bradkovach
bradkovach / app.ts
Last active September 5, 2017 18:39 — forked from scottmcarthur/app.ts
How to use AngularJS ng.resource.IResource with TypeScript.
/// <reference path="angular.d.ts" />
/// <reference path="angular-resource.d.ts" />
/*
The intent of this fork is to show you how to separate your IResource from your Interfaces.
We had a need in our project to keep the resource separate from the business entity, so this
updated example reflects those changes.
Furthermore, I've added TSDoc (comments starting with /**) comments, which your IDE should be
able to pick up and present while you work.
/**
* Attempts to parse a string and return a strongly-typed object.
* Supports Date, datetime, datetime with timezone, double, long and string
* @param x a String to attempt to parse
* @return Option[Any] a null-friendly container for the result. Some[Any] when match succeeded. None when the match failed.
*/
def Cast(x: String): Option[Any] =
{
val long_months = "(January|February|March|April|May|June|July|August|September|October|November|December)"
val short_months = "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"
@bradkovach
bradkovach / Keys.example.js
Created July 23, 2015 15:57
Javascript key map
/*
Keys.js - examples
--
just a demo of how this can clean up your code by removing meaningless magic numbers
*/
$('.my-field').on('keyDown', function(e)
{
if( e.keyCode === Keys.BACKSPACE )
{
SELECT DISTINCT User.id
FROM users User
LEFT JOIN ads Ad ON User.id = Ad.user_id
WHERE Ad.approved =1
AND Ad.active =1
<?php
App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
/**
* Users Controller
*
* @property User $User
* @property PaginatorComponent $Paginator
*/
<?php
/**
* Routes configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different URLs to chosen controllers and their actions (functions).
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)