Skip to content

Instantly share code, notes, and snippets.

@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 / 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.
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) {

Generating a new SSH key

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

This creates a new ssh key, using the provided email as a label.

Generating public/private rsa key pair.

When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

@gadzhimari
gadzhimari / nvm.md
Last active October 2, 2018 12:52
NVM

NVM is not compatible with the npm config "prefix" option

Solution: Try config the $NVM_DIR reference again. For example nvm use v7.10.0, and have the error: Run npm config delete prefix or nvm use --delete-prefix v7.10.0 --silent to unset it. You need overwrite nvm prefix,

npm config set prefix $NVM_DIR/versions/node/v7.10.0

Update node via nvm

@gadzhimari
gadzhimari / combineReducers.js
Created January 14, 2018 19:56
Calculate total price in different currencies
const selected = [
{ price: 20 },
{ price: 45 },
{ price: 67 },
{ price: 1305 }
];
const reducers = {
rubles: function(state, item) {
const newPrice = state.rubles + item.price;
@gadzhimari
gadzhimari / treeWalker.js
Last active January 14, 2018 10:55
Tree Walker
/* Replace all text nodes which has parent div element to wrapped by p tag.
Example
Before
<body>
<p>Boom</p>
text
<div>Bam</div>
</body>
After
@gadzhimari
gadzhimari / calcCurrentSlide.js
Last active November 29, 2017 09:38
Calculation formula of prev and next slide
const images = ['1.jpg', '2.jpg', '3.jpg'];
const total = images.length;
const next = (current + 1) % total;
const prev = (current + (total - 1)) % total;
@gadzhimari
gadzhimari / js-task-1.md
Created July 26, 2017 18:01 — forked from codedokode/js-task-1.md
Задания на яваскрипт (простые)