Skip to content

Instantly share code, notes, and snippets.

Ron Apelbaum ronapelbaum

Block or report user

Report or block ronapelbaum

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
View git-increment.js
const proc = require('child_process');
const gitGetTag = cb => proc.execFile('git', ['describe', '--abbrev=0', '--tags'], (err, res) => cb(res.trim()));
const gitPutTag = (tag, cb) => proc.execFile('git', ['tag', tag], (err, res) => cb(res.trim()));
const parseTag = (tag) => {
try {
return /v(\d+)\.(\d+)\.(\d+)(-(\d+))?/.exec(tag).slice(1)
} catch (e) {
// do nothing
@ronapelbaum
ronapelbaum / generators.js
Created Sep 20, 2018
play with javascript generators
View generators.js
const sleep = ms => new Promise(res => setTimeout(()=>res(ms), ms))
// main1();
// main2();
// run(main3);
run2(main3);
function main1() {
console.log(1);
sleep(100).then(t => console.log(2, t));
@ronapelbaum
ronapelbaum / app.js
Last active Jul 23, 2018
test.js - minimal nodejs test
View app.js
const app = () => {
const list = []
return {
add: (item) => list.push(list),
get: () => list.slice(0),
}
}
module.exports = app
@ronapelbaum
ronapelbaum / package.json
Last active Mar 29, 2018
NPM Version Management Auto-Patch
View package.json
{
"name": "my-package",
"version": "1.2.0",
"scripts": {
"patch-version": "node patch-version.js",
"tag-version": "node tag-version.js \"release-tag\"",
"prerelease": "npm run patch-version && npm run tag-version",
"release": "npm publish",
}
}
@ronapelbaum
ronapelbaum / README.MD
Created Jun 13, 2017
Remove the `/* eslint-disable */` comment at file header, for changed files on branch
View README.MD

When you try to add eslint to a large project, you better try this approach as in this script.

Now, you want to enforce your team members to actually remove the /* eslint-disable */ comment at file header, for all files that they've changed.

Here you go.

@ronapelbaum
ronapelbaum / README.MD
Last active May 7, 2017
interview: front end developer (answers)
View README.MD

Interview: Front-End developer (answers)

basic algorithm

1. implement function reverseString(str)

  • use simple iteration
  • split() vs join()
  • array vs string

2. implement function factorial(n)

  • use simple recurtion
@ronapelbaum
ronapelbaum / README.MD
Last active Mar 28, 2018
interview: front end developer
View README.MD

interview: front end developer

basic algorithm

  1. implement function reverseString(str)
  2. implement function factorial(n)
  3. implement function removeFromArray(arr, arg1, arg2, ...)

javascript

  1. What will be the output of this:
@ronapelbaum
ronapelbaum / .travis.yml
Created May 4, 2017
How to run ESLint in you travis CI
View .travis.yml
language: node_js
node_js:
- "6"
script:
- npm run lint
- npm run build
- npm test
@ronapelbaum
ronapelbaum / index.html
Created Aug 7, 2016
improve your angular 1.x code style
View index.html
<script src="app.js"></script>
<script src="OtherService.js"></script>
<script src="MyService.js"></script>
@ronapelbaum
ronapelbaum / MyService.js
Last active Aug 7, 2016
improve your angular 1.x code style (2)
View MyService.js
function MyService(OtherService) {
this.foo = function () {
OtherService.goo();
}
}
MyService.$inject = ['OtherService'];
angular.module('app').service('MyService', MyService);
You can’t perform that action at this time.