Skip to content

Instantly share code, notes, and snippets.

Alexey Kozlov astur

Block or report user

Report or block astur

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@astur
astur / log.js
Created May 25, 2018
Why node.js Error objects sucks?..
View log.js
~ $ node
> const err = new Error('TEST')
undefined
> JSON.stringify(err)
'{}'
> Object.keys(err)
[]
> Reflect.ownKeys(err) //where is a 'name'?
[ 'stack', 'message' ]
> for(let k in err) console.log(k)
@astur
astur / db.js
Created Feb 27, 2018
mongo 2/3 compatible db activation
View db.js
const mongo = require('mongodb').MongoClient;
const mongoString = process.env.MONGO_URI ||
'mongodb://localhost:27017/test';
module.exports = mongo.connect(mongoString)
.then(client => {
if('databaseName' in client){
return client;
}
const db = client.db(mongoString.split('/').pop());
@astur
astur / .gitconfig
Created Feb 2, 2018
tools in git config
View .gitconfig
#sublime
core.editor=subl -n -w
#diffmerge
diff.tool=diffmerge
difftool.diffmerge.cmd=diffmerge "$LOCAL" "$REMOTE"
merge.tool=diffmerge
mergetool.diffmerge.cmd=diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"
mergetool.diffmerge.trustexitcode=true
@astur
astur / .gitignore
Last active Jun 20, 2018
My .gitignore
View .gitignore
*~
_*
._*
*.orig
*.iws
.idea
.idea_modules/
*.tmlanguage.cache
@astur
astur / .eslintrc
Last active Sep 24, 2017
My .eslintrc
View .eslintrc
{
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"env": {
@astur
astur / react-redux-bp.js
Last active Dec 31, 2017
Boilerplate for small React+Redux app
View react-redux-bp.js
//ACTION_CREATORS
const actions = {
setText: function(text){
return{
type: 'SET_TEXT',
text: text
}
},
inc: function(){
@astur
astur / icrawler-amazon-tr-drafts.js
Created Jul 17, 2016
Example of using icrawler to scrape data from Amazon Top Reviewers (drafts)
View icrawler-amazon-tr-drafts.js
var icrawler = require('icrawler');
var fs = require('fs');
var opts = {
concurrency: 10,
cookies: {
'x-main': 'MnygWH5s8Ue0n9iKEDQqmL5XJfpwVc7y', //use your cookies here
'session-id': '111-3333333-5555555', //use your cookies here
},
headers: {
@astur
astur / index.js
Created Jul 15, 2016
tproger quotes scraping
View index.js
var needle = require('needle');
var log = require('cllc')();
var URL = 'https://tproger.ru/wp-content/plugins/citation-widget/getQuotes.php';
var count = 0;
var results = [];
log('Started');
log.start('%s quotes found');
@astur
astur / index.js
Last active Feb 20, 2018
LIS Map scraping (for Habr)
View index.js
var log = require('cllc')();
var tress = require('tress');
var needle = require('needle');
var cheerio = require('cheerio');
var fs = require('fs');
var sCookie = 'http://www.puntolis.it/storelocator/defaultsearch.aspx?idcustomer=111';
var sProv = 'http://www.puntolis.it/storelocator/buildMenuProv.ashx?CodSer=111';
var sLoc = 'http://www.puntolis.it/storelocator/buildMenuLoc.ashx?CodSer=111&ProvSel=%s';
var sMarker = 'http://www.puntolis.it/storelocator/Result.aspx?provincia=%s&localita=%s&cap=XXXXX&Servizio=111';
@astur
astur / index.js
Created May 22, 2016
Ferra scraping (for Habr)
View index.js
var tress = require('tress');
var needle = require('needle');
var cheerio = require('cheerio');
var resolve = require('url').resolve;
var fs = require('fs');
var URL = 'http://www.ferra.ru/ru/techlife/news/';
var results = [];
var q = tress(function(url, callback){
You can’t perform that action at this time.