Skip to content

Instantly share code, notes, and snippets.

Avatar
🌿
For the time being, I may be slow to respond.

Michael Floering hangtwenty

🌿
For the time being, I may be slow to respond.
View GitHub Profile
@hangtwenty
hangtwenty / window and globalThis polyfills for node, typescript.md
Last active Mar 27, 2021
Some polyfills for browser and node.js interop: window, fake-indexeddb, etc
View window and globalThis polyfills for node, typescript.md
@hangtwenty
hangtwenty / How to make VS Code focus the Debug sidebar instead of Explorer.md
Last active Mar 26, 2021
How to make VS Code focus the Debug sidebar instead of File Explorer
View How to make VS Code focus the Debug sidebar instead of Explorer.md

It took me a little bit to find this setting so I'm writing it down for friends.

After you finish a debug session in VS Code, it may change the sidebar's focus back to the File Explorer.

I don't think it is the default setting, but mine was set that way (and I didn't remember that).

To change it in your settings JSON:

@hangtwenty
hangtwenty / postfix template for immediately-invoked async function.md
Last active Mar 21, 2021
JetBrains Postfix Completion (or could be a Live Template) for immediately-invoked async function
View postfix template for immediately-invoked async function.md

what

Run an async function at the top level of your JS/TS module, using the IIFE pattern.

An async function expression can be used as an IIFE (Immediately Invoked Function Expression) which runs as soon as it is defined. MDN

why even make a snippet?

  • I do this a lot when scripting/ testing stuff out, and there's something about typing it out that makes me lose my train of thought. (It's not to reduce my number of keystrokes!)
  • This shows how you can make some easy Live Templates of your own
@hangtwenty
hangtwenty / tip - get js-live-templates.md
Created Mar 21, 2021
JavaScript/TypeScript snippets for JetBrains: instead of looking for Sublime Snippets to import, get some Live Templates.
View tip - get js-live-templates.md
@hangtwenty
hangtwenty / Remove broken or misbehaving plugin from JetBrains IDE.md
Last active Mar 23, 2021
JetBrains IDEs (PyCharm, RubyMine, IntelliJ...) — Remove broken or misbehaving plugin
View Remove broken or misbehaving plugin from JetBrains IDE.md

There's a plugin in the JetBrains marketplace that is broken in a peculiar way (at least on my machine), that makes it so it doesn't work and it is invisible/ can't uninstall it with the Preferences GUI.

In this case it's a plugin called stackoverflow. I reported the bug but this works for other plugins as well.

Back up your settings (and settings folders) before you mess with them.

To remove a plugin from all JetBrains IDEs:

@hangtwenty
hangtwenty / cht.sh autocomplete troubleshooting.md
Last active Mar 9, 2021
Note about installing tab completion for cheat.sh aka cht.sh ( https://github.com/chubin/cheat.sh ), with zsh.
View cht.sh autocomplete troubleshooting.md

From the cht.sh README:

ZSH Tab completion

To activate tab completion support for cht.sh, add the :zsh script to the fpath in your ~/.zshrc:

    $ curl https://cheat.sh/:zsh > ~/.zsh.d/_cht
    $ echo 'fpath=(~/.zsh.d/ $fpath)' >> ~/.zshrc
    $ # Open a new shell to load the plugin
View undefined method 'str' for ActiveRecord.md

Error when running rails db:migrate:

undefined method `str' for #<ActiveRecord...>

Solution is so trivial it took me a bit. I accidentally put foo:str instead of foo:string, in the arguments to rails generate .... So, just re-run with the correct field type name.

@hangtwenty
hangtwenty / Alfred Workflows — where to find (or add) a script.md
Last active Mar 8, 2021
Where to find helper script files, etc, for Alfred Workflows. (alfredapp.com)
View Alfred Workflows — where to find (or add) a script.md

ℹ️ There's also an Alfred Workflow for searching and grabbing this directory.

  • Manage Alfred Extension - List and view details about installed Alfred extensions. Additional features added: Open in iTerm, Copy Path and Browse Data Directory.

Directory with all Alfred Workflows:

cd /Applications/AlfredSync/Alfred.alfredpreferences/workflows
@hangtwenty
hangtwenty / Uniform Type Identifiers (UTI).md
Last active Mar 8, 2021
I always forget where to find this, so here's a copy. It's an old-but-still-useful thing from the Apple Developer documentation archive, and it's from 2005 (whoa, right?)
View Uniform Type Identifiers (UTI).md

What's a Uniform Type Identifier?

Each UTI provides a unique identifier for a particular file type, data type, directory or bundle type, and so on. In addition, other type identifier namespaces for a particular type can be grouped under one UTI, with utility functions available to translate from one format to another.

What's the table below?

The following tables list uniform type identifiers (UTIs) that are declared by the system as of OS X v10.4. [Which was released in 2005. That means it's NOT up to date. Apple Developer stuff has the up to date docs. Still, these can be useful for scripting, Alfred Workflows, and so on.]

Note: T

View Rails troubleshooting -- devise:install error.md

While running ...

rails g devise:install

... got this error: