Skip to content

Instantly share code, notes, and snippets.

View a-bronx's full-sized avatar

Andrey Bronnikov a-bronx

  • HID Global
  • Fremont, CA
View GitHub Profile
@a-bronx
a-bronx / esm-package.md
Created February 10, 2024 07:08 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@a-bronx
a-bronx / immutable-operations.spec.js
Created February 10, 2024 07:08 — forked from elliotlarson/immutable-operations.spec.js
JavaScript Immutable Operations on Arrays and Objects
// This is a Jest spec that explores some of the different ways to alter
// arrays and objects without mutating state. I'm trying different approaches
// available using:
//
// * Vanilla JS
// * Immutable.js
// * Lodash
// * Rambda
//
// The motivation for this is largely to work with a Redux store.
@a-bronx
a-bronx / How to import early.adoc
Last active February 5, 2024 23:36
PowerShell tricks

How to Import Early

Problem

You have a shared script/module with some function:

toolset.ps1

function Find-MsBuild() { ... }
@a-bronx
a-bronx / delete_git_submodule.md
Created November 16, 2022 20:47 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
class Schedule
{
// "Timetables" for different recurrence intervals.
private bool[] years;
private bool[] months;
private bool[] days;
private bool[] weekdays;
private bool[] hours;
private bool[] minutes;
private bool[] seconds;
@a-bronx
a-bronx / scooped.ps1
Last active November 18, 2023 10:01
A scoop of software
# Install scoop
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iwr -useb get.scoop.sh | iex
# Prepare scoop
scoop install aria2 # Multi-protocol download utility & accelerator
scoop install git # Version control system. Required for scoop.
# Add scoop buckets
@a-bronx
a-bronx / debounce.js
Created June 2, 2020 07:01 — forked from just-boris/debounce.js
small debounce implementation without lodash
export const DEBOUNCE_DEFAULT_DELAY = 200;
export default function debounce(func, delay = DEBOUNCE_DEFAULT_DELAY) {
let timeout;
return function(...args) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
@a-bronx
a-bronx / angularjs_directive_attribute_explanation.md
Created April 28, 2019 02:29 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
<# Object initializer syntax ( $config = @{ … } ) produces a Hashtable.
Unlike this, the ConvertFrom-Json function returns PSCustomObject instead.
This may be inconvenient if you keep configuration both in JSON files and in PS1 files.
To keep uniformity, convert object to Hashtable using this function
#>
function ConvertTo-Hashtable {
param(
[Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
$InputObject