Skip to content

Instantly share code, notes, and snippets.

View EddiG's full-sized avatar
🛠️
making good stuff for good people

Eduard Gilmutdinov EddiG

🛠️
making good stuff for good people
View GitHub Profile
@EddiG
EddiG / macos.md
Last active April 16, 2024 16:55
Tips and tricks regarding MacOS

Creating case sensitive/insensitive volumes (https://www.dssw.co.uk/reference/diskutil.html)

# For case insensitive
diskutil apfs addVolume disk1 APFS <Volume name>
# For case sensitive
diskutil apfs addVolume disk1 "Case-sensitive APFS" <Volume name>

The newly created volume will be mounted to the /Volume/

@EddiG
EddiG / babel-js-config.md
Last active April 20, 2021 06:49
Use Babel configuration from JS file
@EddiG
EddiG / elasticsearch-ami.md
Last active April 17, 2018 14:36
Little instruction of running Elasticsearch on Amazon

Running Elasticsearch on Amazon Machine Image (AMI)

  1. Install the Elasticsearch following this instruction
  2. Install Java sudo yum install java-1.8.0-openjdk
  3. Choose the installed Java version sudo /usr/sbin/alternatives --config java
  4. Install Amazon specific plugin sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install discovery-ec2
  5. Edit configurations in /etc/elasticsearch/
  6. Run the Elasticsearch sudo -i service elasticsearch start
  7. Look at the logs if didn't start /var/logs/elasticsearch/
  8. Add to autostart on reboot sudo chkconfig elasticsearch on (for verifying sudo chkconfig --list)
@EddiG
EddiG / apollo-custom-mutation.md
Last active March 30, 2018 05:35
That is how you can reuse the Mutation component from React Apollo client
const DeleteItemMutation = ({ id, render }) => (
  <Mutation mutation={DELETE_ITEM_MUTATION}>
    {mutate =>
      render({
        deleteItem: id => {
          mutate({
            variables: { id },
            // optimisticResponse
 // update
@EddiG
EddiG / makefile-docker.md
Created March 23, 2018 18:10
The Makefile to leveraging Docker
image = 'node:8.9.3'
container = 'my-project'
volume = 'my-project-volume'
site_port = '8080:8080'

build:
	docker run -it -d -v '$(CURDIR)':/app -v ${volume}:/app/node_modules -w /app -p $(site_port) --name $(container) $(image) /bin/bash
	docker exec -it $(container) yarn install
@EddiG
EddiG / python3.md
Last active May 3, 2021 11:46
Cheatsheet of Python 3

Python 3

Discovery helpers

Getting a description about some of the classes or functions
help(tuple)
help(tuple.count)
Getting attributes of object
dir(tuple)
@EddiG
EddiG / docker.md
Last active April 20, 2021 06:48
I will try to consolidate my knowledge about Docker here

How to use Docker

As Node.js powered development environment

Initialize new container with name my_project
docker run -it -d -v "$(PWD)":/app -v /app/node_modules -w /app -p 8080:8080 --name my_project node:8 /bin/bash

Notice how we mount new volume above node_modules folder. In this way, we significantly improve performance for host machines powered by OSX or Windows. Otherwise, we will stay with a poor native performance when the Docker synchronize file system state on host and container on npm install command execution.

// fork.js
const { fork } = require('child_process');

const getMessage = () =>
  new Promise((resolve, reject) => {
    fork('src/child')
      .on('message', message => {
        resolve(message);
 })

The example of how to render something only on client side

Inspired by facebook/react#10923 (comment)

class OnlyOnClient extends Component {
  static propTypes = {
    placeholder: PropTypes.node,
    html: PropTypes.string
  };

 state = {

Polyfill for localStorage in Safari private browsing mode

Inspired by https://gist.github.com/juliocesar/926500

function getLocalStorage() {
  try {
    window.localStorage.setItem('__test-localstorage__', '1');
    window.localStorage.removeItem('__test-localstorage__');
    return window.localStorage;
  } catch (error) {
 const localStorage = {