Skip to content

Instantly share code, notes, and snippets.

View 1st's full-sized avatar
🎯
Work smarter, not harder

Anton Danilchenko 1st

🎯
Work smarter, not harder
View GitHub Profile
@1st
1st / fix_virtualenv.sh
Last active November 12, 2019 23:08
Fix virtualenv after Python upgrade via Homebrew
# Edit file and add there next function:
nano ~/.zshrc
# - OR -
nano ~/.profile
# Paste this function in the file:
function fix_virtualenv {
#
# Usage: fix_virtualenv project_name
@1st
1st / 2047.py
Created October 2, 2019 18:18
2047 Year is coming
"""
>>> 1024+512+256+128+64+32+16+8+4+2+1
2047
>>> bin(2047)
'0b11111111111'
"""
@1st
1st / intro.md
Last active February 10, 2020 07:54
NPM watcher that helps to access data in the linked directory

Linking directory in ReactJS project

I found that users of Create-React-App script have issues with building few projects that are based on the same "core" library. Let's imagine that you have a ui directory where you keep all UI React components. And you have two projects - blog and shop.

Now you wish to use the shared UI components in both these projects. But if you will create a symlink to a "raw" source code (where you use ES2015) - you will see that your code can't be imported, because it expects that they should be already compiled.

@1st
1st / sublimetext_jedi.md
Last active April 4, 2016 20:26
SublimeJEDI traceback

What I need to do

I opened .py file to edit in SublimeText project. Inported library (from django import db) and wrote db. to show autocompletion. But nothing happens.

Step-by-step guide

SublimeText running without JEDI plugin installed

@1st
1st / brew_config.sh
Last active December 10, 2015 13:30
HomeBrew and PostgreSQL. Illegal instruction: 4
$ brew config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: dcb3cf09cba68f891bb8eda4b1735b50996a85b9
Last commit: 6 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit ivybridge
@1st
1st / pgsql.sh
Last active October 16, 2019 13:32
HowTo setup Postgres on macOS
# 0. install a Postgres
# we use HomeBrew for this
brew install postgres
# init file structure for all databases
initdb /usr/local/var/postgres
# 1. create new user for a database
# 1.1. user without password
@1st
1st / .zshrc
Last active March 21, 2020 01:16
My settings for Python dev env for macOS (file: ~/.bash_profile or ~/.zshrc)
#
# My settings for python dev env on MacBook.
# I use HomeBrew to install python and python3
# cat ~/.profile
#
# load all completions
source /usr/local/etc/bash_completion.d/*
# Python VirtualEnv
@1st
1st / 2015.py
Last active August 29, 2015 14:12
2015-binary.py
"""
2015 year calculations.
>>> # we missing 32 in this year pow(2,5)
>>> pow(2,5)
32
>>> 1024+512+256+128+64+0+16+8+4+2+1
2015
>>> bin(2015)
'0b11111011111'
@1st
1st / inheritance.py
Created September 28, 2014 18:02
Inheritance in Python
class A(object):
def aa(self):
print 'in A'
return self.__class__.__name__
class B(A):
def bb(self):
print 'in B'
return super(B, self).aa()