Skip to content

Instantly share code, notes, and snippets.

Avatar

Radovan Surlak radovansurlak

View GitHub Profile
@radovansurlak
radovansurlak / expenseTrackerChaiES6.js
Last active Mar 17, 2018
Playing around with ES6, classes, and testing with Chai and Mocha
View expenseTrackerChaiES6.js
const l = console.log;
chai.should();
mocha.setup('bdd');
// Pre-config ⇡⇡⇡⇡⇡
class MoneyTracker {
constructor() {
this.income = [];
View Readme.md

Faster Compass Hack

  1. Create a folder source\scss\compiled-custom
  2. Move custom.template.scss to source\scss\compiled-custom
  3. Run "npm install jit-grunt --save-dev"
  4. Run "npm install grunt-string-replace --save-dev"
  5. Copy "config.rb" to the root
  6. Replace the code in "gruntfile.js"
  7. Run "compass watch"
  8. Run "grunt sass"
@radovansurlak
radovansurlak / gist:b365166cfc8cc4bde28c32241a595748
Created Apr 4, 2017
Eloquent JS Challenge - Looping a Triangle
View gist:b365166cfc8cc4bde28c32241a595748
function triangle (width, symbol = '#') {
width > 0 ? (console.log(symbol), triangle(width-1, symbol+symbol[0])) : null ;
}
@radovansurlak
radovansurlak / main.js
Created Apr 3, 2017
JS Recursive Function + Ternary Operator - Power
View main.js
function power (num, pow) {
return (pow === 0) ? 1 : num * power(num, pow-1);
}
@radovansurlak
radovansurlak / main.js
Last active Apr 2, 2017
Extending String and Array Prototypes - Render To Document - ES6
View main.js
String.prototype.renderize = function (type, className, idName) {
return typeof type != 'undefined' ?
`<${type}${ typeof className != 'undefined' ? ' class=\'' + className + '\'' : '' }${typeof idName != 'undefined' ? ' id=\'' + idName + '\'' : ''}> ${this} </${type}>`
: new Error ('Unspecified HTML DOM element type (1st argument)')
}
String.prototype.render = function (type, className, idName) {
document.write(this.renderize(type,className,idName))
}
@radovansurlak
radovansurlak / main.js
Created Apr 1, 2017
OLOO Pattern - ES6
View main.js
let student = {
init: function (name, field, year) {
let instance = Object.create(this)
instance.name = name
instance.field = field
instance.year = year
return instance
}
}
@radovansurlak
radovansurlak / main.js
Last active Apr 1, 2017
ES6 - Functional Programming Example
View main.js
function addXNumbers () {
let numbers = Array.prototype.slice.call(arguments)
return numbers.reduce((acc, current) => acc + current)
}