Skip to content

Instantly share code, notes, and snippets.

View shershen08's full-sized avatar

Mikhail Kuznetcov shershen08

View GitHub Profile
@shershen08
shershen08 / multiple-values-from-function.md
Created March 20, 2017 16:14
Multiple arguments return from function JS vs Python

Need to use array destruction

//Javascript, ES6
var addAndSubstract = function(a, b) {
        return [(a + b), (a - b)]
    };
[add_result, subs_result] = addAndSubstract(41, 42)

Native way to return multiple items

@shershen08
shershen08 / reloading.py
Last active July 30, 2017 08:20
File reload implementation
"""
Demo file to have a reloading on change
Run with '-reload' param to enable reloading
change increment_value var to see the reloading
--
Mechanism is copied from bottle-py framework implementaion - https://github.com/bottlepy/bottle/blob/master/bottle.py#L3633
"""
import time
@shershen08
shershen08 / parsetoat.js
Last active June 17, 2017 19:06
Parse html templates into angular-trnslate prepared ones
/**
Sample call: node ./node_modules/autotranslate-ng/index client\app\components\account-information\account-information.html acc
ount-information table
Params (positional):
- path_to
- label prefix
- tag/tag.class to exclude
@shershen08
shershen08 / app.js
Created July 3, 2017 20:07
Grid editor
var bus;
const handleFileSelect = evt => {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files; // FileList object.
listFilesContent(files);
};
const downloadFileHTML = item => {
@shershen08
shershen08 / css-html.txt
Created July 3, 2017 20:08
Editor css/html
body {
background: #eee;
font-family: Arial, 'sans-serif';
}
#drop_zone {
border: 2px dashed #bbb;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
padding: 25px;
@shershen08
shershen08 / test f-53
Created December 8, 2017 11:56
results.txt
1) create:
Request URL:http://remissionaire-admin-staging.herokuapp.com/api/v1/chats?load_from_source=1
Request Method:POST
Status Code:200 OK
payload: {"tags":"veg,vegan,ttttt-mew","load_from_source":1,"title":"test f-53"}
NEW TAG: ttttt-mew
-----------------
Request URL:http://remissionaire-admin-staging.herokuapp.com/api/v1/tag/add-new/
Request Method:POST
@shershen08
shershen08 / main.go
Created June 7, 2018 08:43
gin server concept to execute bash commands
package main
import (
"encoding/json"
"net/http"
"os/exec"
log "github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
)
var list = []
jQuery('h2').each((index, el) => {
list.push({
name: jQuery(el).find('a').text(),
type: jQuery(el).next('p').find('a').text() || jQuery(el).next().next().find('a').text()
})
})
copy(list)
@shershen08
shershen08 / classify-article-2.js
Created June 17, 2018 09:25
not cleaned list
[
{name: "Terms of Use", type: ""},
{name: "9 Pound Hammer", type: "Indica"},
{name: "Acapulco Gold", type: "Sativa"},
{name: "ACDC", type: "Hybrid"},
{name: "Afghani", type: "Indica"},
{name: "Afgoo", type: "Indica"},
{name: "AK-47", type: "Hybrid"},
//..
]
[
{name: "9 Pound Hammer", type: 0},
{name: "Acapulco Gold", type: 1},
{name: "ACDC", type: 2},
{name: "Afghani", type:0},
{name: "Afgoo", type: 0},
{name: "AK-47", type: 2},
..
]