Skip to content

Instantly share code, notes, and snippets.

View defun99's full-sized avatar
👾
こんにちは世界

Nikita Rychagov defun99

👾
こんにちは世界
View GitHub Profile
@defun99
defun99 / clean_code.md
Created March 17, 2020 08:01 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

{"lastUpload":"2021-05-17T11:47:38.662Z","extensionVersion":"v3.4.3"}
@defun99
defun99 / gist:1a5c40aed2d09db67ec79a8396a7d9a9
Last active August 4, 2020 17:56
Linux setup no password sudo actions
At the end of the /etc/sudoers file add this line:
username ALL=(ALL) NOPASSWD:ALL
Increase amount of node watches
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@defun99
defun99 / gist:3e7ba80de76c1a0ba100ee17fe015850
Created August 27, 2020 13:49
Business logic definition
>Business logic is the weird flows and rules that only make sense in the context of the user’s business
@defun99
defun99 / gist:b0dff3a7b879050a365c742923ea7132
Created September 2, 2020 13:01
Freeing localhost port
1. Get process pid:
sudo lsof -iTCP:3004 -sTCP:LISTEN
2. sudo kill -9 <pid>
@defun99
defun99 / copy_collection.txt
Created September 11, 2020 10:53
Copy collection to another db (Mongo)
db.getCollection('col').find({}).forEach(function(d){ db.getSiblingDB('destinationDB')['col'].insert(d); });
@defun99
defun99 / docker_in_venv.md
Last active September 29, 2020 14:40
Add group docker to venv and user to this group
  sudo gpasswd -a $USER docker

  newgrp docker
const result = await axios({
method: 'post',
url: 'https://translation.googleapis.com/language/translate/v2/detect?key=AIzaSyAM0buje-vXIwgvH48sASmZDI-Jb4lMXMY',
data: {data},
headers: {'Content-Type': 'application/json'}
});
// result.data contains response
@defun99
defun99 / timeout.js
Created January 25, 2021 12:21 — forked from simonrenoult/timeout.js
Managing timeout. Especially handy with autocomplete.
// Props to : http://nathanleclaire.com/blog/2013/11/16/the-javascript-question-i-bombed-in-an-interview-with-a-y-combinator-startup/
var processOnTime = function ( next, delay ) {
var d = delay;
if ( ! next ) {
throw new ReferenceError();
}
if ( ! d || isNaN ( d ) ) {
d = 200;
@defun99
defun99 / timeout.js
Created January 25, 2021 12:21 — forked from simonrenoult/timeout.js
Managing timeout. Especially handy with autocomplete.
// Props to : http://nathanleclaire.com/blog/2013/11/16/the-javascript-question-i-bombed-in-an-interview-with-a-y-combinator-startup/
var processOnTime = function ( next, delay ) {
var d = delay;
if ( ! next ) {
throw new ReferenceError();
}
if ( ! d || isNaN ( d ) ) {
d = 200;