Skip to content

Instantly share code, notes, and snippets.

const deepFreeze = (obj) => {
// Retrieve the property names defined on obj
const propNames = Object.getOwnPropertyNames(obj);
// Freeze properties before freezing self
propNames.forEach(function(name) {
const prop = obj[name];
// Freeze prop if it is an object
if (typeof prop == 'object' && prop !== null) {
@gadzhimari
gadzhimari / dotfiles.md
Last active February 24, 2018 18:25
Dotfiles syncing through bare git repository

Note: No extra tooling, no symlinks, files are tracked on a version control system, you can use different branches for different computers, you can replicate you configuration easily on new installation.

git init --bare $HOME/.dotfiles
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
  • The first line creates a folder ~/.dotfiles which is a Git bare repository that will track our files.
  • Then we create an alias config which we will use instead of the regular git when we want to interact with our configuration repository.
  • We set a flag - local to the repository - to hide files we are not explicitly tracking yet. This is so that when you type config status and other commands later, files you are not interested in tracking will not show up as untracked.
  • Also you can add the alias definition by hand to your .zshrc or use the the fourth line provided for convenience.
@gadzhimari
gadzhimari / Brewfile.md
Last active February 25, 2018 15:25
Brewfile installation

Dumping your homebrew installed packages use the following command

brew bundle dump

This creates a Brewfile under the current directory. You can also write this from scratch easily and the specs are fairly easy. To install all packages from Brewfile run the following command

brew bundle

If you don't want download manually from Mac App Store, you can use Mas utility which download all specified apps from App Store for you automatically.

mas install wunderlist

Note: For apps installed from Mas you need to specify explicitly the id of app. If you don't know id, just run

mas search wunderlist // 410628904

Use this id with the name of app in your Brewfile config

@gadzhimari
gadzhimari / npm.md
Last active November 16, 2018 17:06
Npm cheatsheet

Install fixed version of package

npm install --save --save-exact react

Set a default in .npmrc config

npm config set save-exact=true

Install package from Git and Github repository

As of NPM version 1.1.65, we can do this: npm install /#

@gadzhimari
gadzhimari / git.md
Last active August 20, 2019 08:23
List of resources and helpful info about commands

Basics

In git there is three essential entity: blob, tree object and commit.

Reset

To throw away local changes exits couple of similar commands
git reset --hard
git checkout -f <branch>

Note: Untracked files will be untouched. The <branch> is optional and if we specified the HEAD it's unnecessary, because by default it's reference to the currently checked out commit.

@gadzhimari
gadzhimari / url-detect.js
Created November 6, 2018 18:25
Detect url in text
// const pattern = /(?:\[(.+)\]\()?((?:https?|ftp):\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=():!,\'\'\*]*))/ig;
// const pattern = /(?:\[(.+)\]\()?((https?:\/\/|ftps?:\/\/)?([a-z0-9\-]+\.){1,}([a-z0-9\-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:\/\?#\[\]@!$&'\(\)\*\+,;=%]+)?)?)/ig;
const pattern = /(?:\[(.+)\]\()?(((?:https?|ftps?):\/\/)?(?:www\.)?[-a-z0-9]+\.[a-z]{2,6}\b([-a-z0-9._~:\/\?#\[\]@!$&'()\*\+,;=%]+)?)/ig;
//
// const pattern = /(?:\[(.+)\]\()?((?:https?|ftp):\/\/\S+)/ig;
// const pattern = /(?:\[(.+)\]\()?(([--:\w?@%&+~#=]*\.[a-z]{2,4}\/{0,2})((?:[?&](?:\w+)=(?:\w+))+|[--:\w?@%&+~#=\(\)]+)?)/ig;
@gadzhimari
gadzhimari / dotfiles.md
Created November 8, 2018 07:34
Dotfiles configuration

Sync dotfiles

The best way to store your dotfiles is bare repository.

No extra tooling, no symlinks, files are tracked on a version control system, you can use different branches for different computers, you can replicate you configuration easily on new installation.

More about this techique

@gadzhimari
gadzhimari / adobe_cc.md
Created November 22, 2018 11:29
Completely Remove Adobe from your Mac in 2 Steps

Step 1

Download and run the Adobe Creative Cloud Cleaner Tool, their multi-app uninstaller and wipe assistant. Adobe does recommend running individual application uninstallers first, your call. Click the Clean All option.

Step 2

Type a one line command in terminal find ~/ -iname "*adobe*" and it's shows up all files which match pattern.

To remove all files

`sudo rm -rf /Applications/Adobe* /Applications/Utilities/Adobe* /Library/Application\ Support/Adobe /Library/Preferences/com.adobe.* /Library/PrivilegedHelperTools/com.adobe.* /private/var/db/receipts/com.adobe.* ~/Library/Application\ Support/Adobe* ~/Library/Application\ Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.adobe* ~/Library/Application\ Support/CrashReporter/Adobe* ~/Library/Caches/Adobe ~/Library/Caches/com.Adobe.* ~/Library/Caches/com.adobe.* ~/Library/Cookies/com.adobe.* ~/Library/Logs/Adobe* ~/Librar

@gadzhimari
gadzhimari / WebAssembly.md
Created November 30, 2018 17:28
Installation and configuration of Emscripten and things that related to WebAssembly

Cannot find /usr/bin/llvm-link, check the paths in ~/.emscripten

Solution: Manually set LLVM_ROOT to /usr/local/opt/emscripten/libexec/llvm/bin