Skip to content

Instantly share code, notes, and snippets.

View termosa's full-sized avatar

Stanislav Termosa termosa

View GitHub Profile
ls ~/Code | node -e "rootPath=require('path').resolve('~/Code');process.stdin.on('data', d => console.log(JSON.stringify(d.toString().split('\n').filter(Boolean).map(name => ({ name, rootPath, enabled: true })), null, 4)))" > ~/Library/Application\ Support/Code/User/projects.json
@termosa
termosa / gist:f36b9fc0f3026e6826e2d79edb742c4b
Created April 3, 2021 07:04
Regular expression that removes duplications
^(.*)(\n\1)+$
$1
@termosa
termosa / load_all_from_clipboard.sh
Created April 3, 2021 07:03
Looping through the output of the previous command
pbpaste | while read -r link ; do curl -L -O -C "$link"; done
@termosa
termosa / instruction.md
Last active September 25, 2020 08:39
Make friends local and global Git hooks

How to make local hooks work when you have set Git core.hooksPath

If core.hooksPath is set in Git local .git/hooks won't be triggered.

I'm using husky quite often and I need global hooks at the same time. That was a pain for a while. Today I found a solution: I call my local hooks from the global hooks.

Instruction

@termosa
termosa / npmsize.sh
Last active January 29, 2020 10:00
Measure size of NPM package
npmsize() {
if [ $1 ]
then
PACKAGE_NAME=$1
CURRENT_DIR="$(pwd)"
LC_ALL=C
RANDOM_NAME="$(tr -dc 'a-z' </dev/urandom | head -c 32)"
TEMP_DIR="$HOME/.$RANDOM_NAME"
mkdir $TEMP_DIR
cd $TEMP_DIR
@termosa
termosa / loadModule.js
Created June 23, 2019 12:13
Asynchronously load JavaScript modules from web
;((root, name, factory) => {
if (typeof define === 'function' && define.amd)
define([], () => (root[name] = factory()))
else if (typeof module === 'object' && module.exports)
module.exports = factory()
else
root[name] = factory()
})(typeof self !== 'undefined' ? self : this, 'loadModule', () => {
const cache = {}
@termosa
termosa / static-navigator-methods.dart
Created May 22, 2019 06:21
[An Introduction to Flutter: The Interface] Static navigator methods
Navigator.push(context, MaterialPageRoute(...));
Navigator.pushNamed(context, '/sub');
Navigator.pop(context);
@termosa
termosa / navigator-pushnamed-method.dart
Created May 22, 2019 06:20
[An Introduction to Flutter: The Interface] Navigator pushNamed method
NavigatorState navigator = Navigator.of(context);
navigator.pushNamed('/sub');
@termosa
termosa / named-routes.dart
Created May 22, 2019 06:19
[An Introduction to Flutter: The Interface] Named routes
MaterialApp(
initialRoute: '/',
routes: {
'/': (context) => MainScreen(),
'/sub': (context) => SubScreen(),
},
)
@termosa
termosa / navigator_pop_method.dart
Created May 22, 2019 06:18
[An Introduction to Flutter: The Interface] Navigator pop method
NavigatorState navigator = Navigator.of(context);
navigator.pop();