Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Artem Demo artemdemo

🎯
Focusing
View GitHub Profile
View reset-button.css
%reset-Button {
border: none;
margin: 0;
padding: 0;
width: auto;
overflow: visible;
background: transparent;
/* inherit font & color from ancestor */
View game-of-life-v02.js
// https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
const populate = (matrix) => {
return matrix.map(row => row.map(_ => Math.random() >= 0.5));
};
const createMatrix = (width, height) => {
const matrix = Array.from(new Array(height)).map(_ => Array.from(new Array(width)));
return populate(matrix);
};
View game-of-life-v01.js
// https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
const generateMatrix = (width, height) => {
return Array.from({length: height}, () => Array.from({length: width}, () => Math.random() >= 0.5));
};
const nextCellState = (matrix, rowIdx, colIdx) => {
const numberOfLiveNeighbors = [
[-1, -1], [-1, 0], [-1, 1],
[ 0, -1], [ 0, 1],
View PULL_REQUEST_TEMPLATE.md

What this PR does / why we need it:

Which issue(s) this PR fixes:

  • BACKEND-

How has this been tested:

Special notes for your reviewer:

@artemdemo
artemdemo / Jasmine-and-Babel6.md
Created Jun 15, 2017 — forked from mauvm/Jasmine-and-Babel6.md
Jasmine ES6 run script for use with Babel 6
View Jasmine-and-Babel6.md
$ npm install --save babel-cli babel-preset-es2015
$ npm install --save-dev jasmine

.babelrc:

{
  "presets": ["es2015"]
View templateengine-absurdjs-example.js
const template =
`My skills:
<%if(this.showSkills) {%>
<%for(var index in this.skills) {%>
<a href="#"><%this.skills[index]%></a>
<%}%>
<%} else {%>
<p>none</p>
<%}%>`;
console.log(TemplateEngine(template, {
View nano-template-example.js
data = {
user: {
login: "tomek",
first_name: "Thomas",
last_name: "Mazur",
account: {
status: "active",
expires_at: "2009-12-31"
}
}
View nano-template.js
/* Nano Templates - https://github.com/trix/nano */
function nano(template, data) {
return template.replace(/\{([\w\.]*)\}/g, function(str, key) {
var keys = key.split("."), v = data[keys.shift()];
for (var i = 0, l = keys.length; i < l; i++) v = v[keys[i]];
return (typeof v !== "undefined" && v !== null) ? v : "";
});
}
View templateengine-absurdjs.js
// TemplateEngine - AbsurdJS
// https://github.com/krasimir/absurd/blob/master/lib/processors/html/helpers/TemplateEngine.js
module.exports = function(html, options) {
var re = /<%(.+?)%>/g,
reExp = /(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,
code = 'with(obj) { var r=[];\n',
cursor = 0,
result;
var add = function(line, js) {
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
View simple-js-template-by-john-resig.js
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||