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 / 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 / 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 / singleton.py
Created March 30, 2013 23:26
Singleton implantation on Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Singleton(type):
def __call__(self, *args, **kwargs):
if 'instance' not in self.__dict__:
self.instance = super(Singleton, self).__call__(*args, **kwargs)
return self.instance
@1st
1st / tests_for_toptal_on_codility.py
Last active May 19, 2022 19:58
My answers for tests on http://codility.com that I passed for company http://toptal.com I use Python language to solve problems.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Test that I passed on codility.com for TopTal company
#
# Task #1
def binary_gap(N):
@1st
1st / get_prime_number.py
Last active December 15, 2015 02:19
Solution for task: http://projecteuler.net/problem=7 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def get_prime_number(index):
'''
Return prime number by given index.
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
Args: