Skip to content

Instantly share code, notes, and snippets.

@RB-Lab
RB-Lab / karma.conf.js
Created November 30, 2015 10:39
Minimal Karma config for use with React & Babel & Browserify
// you need to $ npm i -D babel-preset-es2015 babel-preset-react babel-preset-stage-0 babelify karma karma-browserify karma-chai karma-mocha karma-mocha-reporter karma-phantomjs-launcher phantomjs-polyfill array.from
module.exports = function conf(config) {
config.set({
frameworks: ['browserify', 'mocha', 'chai'],
plugins: [
'karma-browserify',
'karma-mocha',
'karma-chai',
'karma-phantomjs-launcher',
{
"scripts": {
"clean": "rimraf lib",
"test": "karma start --single-run",
"tdd": "karma start",
"check": "npm run lint && npm test",
"build": "babel --ignore __tests__ src --out-dir lib",
"lint": "eslint src",
"preversion": "npm run clean && npm run check",
"version": "npm run build",
@RB-Lab
RB-Lab / atom.md
Last active December 11, 2015 16:31

Plugins

  • git-control
  • git-diff-popup
  • git-log
  • merge-conflicts
  • simple-drag-drop-text
  • tab-switcher
  • color-picker
  • editorconfig
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'javascript/vendor.[chunkhash].js',
minChunks: module => {
return module.resource &&
module.resource.indexOf(path.resolve(__dirname, '../node_modules')) === 0;
}
})
/**
* function sliceRing make circular slice of array
* @param {Array} arr
* @param {Number} start
* @param {Number} length
* @returns {Array}
*/
export default function sliceRing(arr, start, length) {
start = start % arr.length;
// -- Base -- //
// original from https://gist.github.com/amatiasq/2e4344792f28611fa499
function curry(fn, length) {
length = length || fn.length;
return function currified() {
var args = [].slice.call(arguments);
if (args.length === 0)
return currified;
@RB-Lab
RB-Lab / theSimpliestModules.js
Last active August 29, 2015 14:22
Synchronous module micro framework.
/**
* @name module
* @global
* @description Synchronous module micro framework.
* Allows to define and require modules with only one variable (module)
* in global scope.
* @exports module
* @example
* module('my-module', function(require, module){
* var lib = require('lib');
@RB-Lab
RB-Lab / key-codes.js
Created April 11, 2015 17:45
Common keycodes as CJS module
module.exports = {
ENTER: 13,
ESC: 27,
BACKSPACE: 8,
DELETE: 45,
TAB: 9,
LEFT_ARROW: 37,
UP_ARROW: 38,
RIGTH_ARROW: 39,
@RB-Lab
RB-Lab / grid.scss
Created February 10, 2015 20:14
Very simple 12-column grid system in scss
$small: 320px;
*[class^="col-"]{
float: left;
box-sizing: border-box;
@media only screen and (max-width: $small) {
&.not-for-small{
width: 100%;
float: none
}
function encodeAsUrl_(params){
return Object.keys(params).map(key => key + '=' + params[key]).join('&')
}
function handleResponce_(xhr, cb, errcb){
return function () {
if (4 === xhr.readyState) {
if(xhr.status >= 200 && xhr.status < 400){
cb(xhr);