Skip to content

Instantly share code, notes, and snippets.

View deliseev's full-sized avatar
🏠
Working from home

Denis Eliseev deliseev

🏠
Working from home
View GitHub Profile
curl https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore > .gitignore
curl https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore >> .gitignore
echo "db.sqlite3" >> .gitignore
@deliseev
deliseev / README.md
Last active September 10, 2018 18:51
SQLite JOINS

SQLite3 JOINS

INNER JOIN (L=R)

SELECT Authors.*, Books.*
FROM Authors INNER JOIN Books USING (ID);

INNER JOIN

# | ID | AuthorName | ID | BookName

word = input('Enter a word:')
fp = open('/Users/deliseev/Downloads/litf-win.txt', 'r', encoding='cp1251')
words = (w.split()[0] for w in fp.readlines())
nw = ''.join(sorted(word.upper()))
print(nw)
print([w for w in words if nw == ''.join(sorted(w.upper()))])
@deliseev
deliseev / launch.json
Created December 26, 2018 13:10
VSCode
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
@deliseev
deliseev / download.js
Last active February 8, 2019 06:25
КЛАДР
// Download archive .dbf files
const Fs = require('fs');
const Path = require('path');
const Axios = require('axios');
async function download() {
const url = 'https://www.gnivc.ru/html/gnivcsoft/KLADR/Base.7z';
const path = Path.resolve(__dirname, 'data', 'base.7z');
if (Fs.existsSync(path)) {
@deliseev
deliseev / permute.ts
Created February 15, 2019 05:47
Combinations (Computer Algorithms)
/**
* Heap's method
* https://stackoverflow.com/questions/9960908/permutations-in-javascript/37580979#37580979
* @param permutation - array of numbers for permutation
*/
function* permute(permutation: number[]): IterableIterator<number[]> {
const length = permutation.length;
let result = [...permutation];
let i = 1;
let c = new Array<number>(length).fill(0);
@deliseev
deliseev / itertools.js
Created February 28, 2019 15:00
Itertool for js
// drop leading zeroes from array
// TODO: make as polyfill
// e.g. https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Polyfill
const dropWhile = arr => arr.reduce(
(state, v) => (v === 0 && state.drop
? ({ arr: [...state.arr], drop: true })
: ({ arr: [...state.arr, v], drop: false })), { arr: [], drop: true },
).arr;
@deliseev
deliseev / draw_pattern
Created March 28, 2019 18:20
Draw simple pattern on <canvas>
ctx.fillStyle =
"#" +
(
((Math.cos(r) * 127 + 128) << 16) |
((Math.cos(r + pi2 / 3) * 127 + 128) << 8) |
(Math.cos(r + (pi2 / 3) * 2) * 127 + 128)
).toString(16);
@deliseev
deliseev / add_deps.sh
Created April 23, 2019 11:54
create-react-app
yarn create react-app ...
yarn add -D eslint-config-prettier eslint-plugin-prettier husky lint-staged prettier pretty-quick
[
{
"model": "persons.person",
"pk": 1,
"fields": {
"last_name": "Гагарин",
"first_name": "Юрий",
"middle_name": "Алексеевич",
"dob": "1934-03-09"
}