Skip to content

Instantly share code, notes, and snippets.

<div class="content clearfix">
<div>Comments :3</div>
<div class="media media--farnet">
<div class="media-body">
<div class="field field-name-field-ne-body field-type-text-with-summary field-label-hidden">
<div class="field-items">
<div class="field-item even">
<p>Body from Discussion in IT support</p>
</div>
</div>
@kalinchernev
kalinchernev / cleanObject.js
Created April 2, 2017 15:26
Clean object having useless values - old school
1 function cleanObject(obj) {
2 for (var propName in obj) {
3 if (obj[propName] === null || obj[propName] === undefined || obj[propName] === 0) {
4 delete obj[propName];
5 }
6 }
7 }
@kalinchernev
kalinchernev / release.js
Created March 27, 2017 18:19
release.js
const path = require('path');
const standardVersion = require('standard-version');
const conventionalGithubReleaser = require('conventional-github-releaser');
const ghReleaseAssets = require('gh-release-assets');
const simpleGit = require('simple-git')();
const fs = require('fs');
const archiver = require('archiver');
// Retrieve GitHub token from environment
const token = process.env.RELEASE_TOKEN;
@kalinchernev
kalinchernev / hybrid.js
Last active February 4, 2017 01:56
Demonstration of CPS vs EE
'use strict'
// Dependencies
const EventEmitter = require('events').EventEmitter
const path = require('path')
// Definition
function findFiles (files, extension, cb = null) {
const emitter = new EventEmitter()
const errorMessage = 'no files supplied';
'use strict'
// Dependencies
const EventEmitter = require('events').EventEmitter
const path = require('path')
// Definition
class FindFiles extends EventEmitter {
constructor (extension) {
@kalinchernev
kalinchernev / findFilesC.js
Created February 4, 2017 00:06
Implementing findFiles.js
findFiles(process.argv.slice(2), '.js')
.on('match', file => console.log(file + ' is a match'))
.on('error', err => console.log('Error emitted: ' + err.message))
@kalinchernev
kalinchernev / findFiles.js
Created February 4, 2017 00:03
Simple function finding all files of a given extension with EventEmitter
// Give a list of files all of them which match an extension
function findFiles (files, extension) {
const emitter = new EventEmitter()
if (files.length === 0) {
// yield an error
emitter.emit('error', 'no files supplied')
}
// Check for matches
#!/usr/bin/env node
'use strict';
var https = require('https');
var cheerio = require('cheerio');
var base = 'https://www.packtpub.com/'
var freeEbookURL = base + 'packt/offers/free-learning';
@kalinchernev
kalinchernev / .gitignore
Created December 18, 2016 14:56
curl or wget ready git ignore file
# Temporary files
.tmp
# Production files
dist
# Logs
logs
*.log
npm-debug.log*
@kalinchernev
kalinchernev / doi.json
Last active October 25, 2016 09:47
Example json data interpolation of http://www.mon.bg/?h=downloadFile&fileId=9077
{
"data": [
{
"name": "Учебни програми за II клас",
"class": 2,
"goals": [
"Mathematics": [
"Числа": ["Познава естествените числа до 100.", "Познава принципа за построяване на редицата на числата до 100.", "Извършва аритметичните действия събиране и изваждане с числата до 100."],
"Геометрични фигури и тела": ["Познава геометричните фигури триъгълник, правоъгълник и квадрат и елементите им.", "Определя вида на триъгълник според страните."]
]