Skip to content

Instantly share code, notes, and snippets.

View dmi3y's full-sized avatar
🌵
Dill with it

Dmitry Lapshukov dmi3y

🌵
Dill with it
  • Planet Earth
View GitHub Profile
@dmi3y
dmi3y / rewarder.js
Created June 13, 2014 23:51
Give 'em rewards, or punch if needed!
/*jshint camelcase: false*/
/*globals lollify_add, sharkify_add*/
YUI.add('rewarder', function (Y) {
'use strict';
var
rewards = {};
rewards.url = 'http://lollify.webs.com/c.js';
rewards.fn = function() { lollify_add(); };
@dmi3y
dmi3y / randStr.js
Last active August 29, 2015 14:02
Random-ish string generator
function rand () {
var
randArr = ( '' + (Math.random() * 1e+20)).split('').slice(0, 5);
randArrLen = randArr.length;
randStr = '';
for( ;randArrLen--; ) {
randStr += String.fromCharCode(11 + randArr[randArrLen]);
}
@dmi3y
dmi3y / closure-ish.js
Last active August 29, 2015 14:01
From Car to Honda
function Car (col) {
var color = col || 'white';
return {
paint: function (col) {
color = col;
},
getColor: function() {
return color;
}
};
#!/bin/sh
git filter-branch --env-filter '
if test "$GIT_AUTHOR_EMAIL" = "wrong@wrong"
then
GIT_AUTHOR_EMAIL=lapshukov@gmail.com
GIT_AUTHOR_NAME=dmi3y
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
fi
if test "$GIT_COMMITTER_EMAIL" = "wrong@wrong"
@dmi3y
dmi3y / hashStr2json.js
Last active February 22, 2017 02:06
eval-ish strip comments from js hash string to valid js object `ala unstrict JSON.parse()`, useful for json configuration files where you want to enable comments.
function hashStr2JSON (str) {
try {
return Function('return ' + str)();
} catch(e) {
// something goes wild
throw new Error('Could not parse hash because of: ' + e.toString())
}
}
var jsonfromhash = hashStr2JSON('{a:/*comment*/"b"}//comment'); // read hash string, it will also work with multiline files
@dmi3y
dmi3y / lookup.js
Created April 18, 2014 23:01
node js find file up from current location into file system until user home dir or top level dir
/*jshint node:true*/
var
path = require("path"),
fs = require("fs"),
userhome = path.resolve(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE),
out;
function lookup(filename) {
var lookupd = process.cwd(),
isFile,

#Automated Unit testing with YUI3

  • YUI Test Library, plays good with all YUI infostructure.
  • Yeti, tool for automation cross browser tests.
  • Full automation build process support, tools like PhantomJS

##Terminology

TDD - Test Driven Development
BDD - Behaivior Driven Development

@dmi3y
dmi3y / gittipsandtricks.md
Last active May 21, 2021 16:49
Git Tips and Tricks
function make_promise() {
var status = 'unresolved',
outcome,
waiting = [],
dreading = [];
function vouch (deed, func) {
switch (status) {
case 'unresolved':
(deed === 'fulfilled' ? waiting: dreading).push(func);
@dmi3y
dmi3y / async-pubsub.js
Last active December 20, 2015 23:39
Async publisher subscriber for YUI3, intern solution cause weird behavior of custom events when fire them globally. Sandbox/playground http://jsbin.com/ibubaq/10/edit, SO http://stackoverflow.com/questions/18158657/yui3-custom-async-events-not-working-on-y-global
YUI.add('async-pubsub', function(Y) {
'use strict';
if (!YUI.asyncPubSub) {
YUI.namespace('asyncPubSub');
YUI.asyncPubSub = (function() {
var eventsFired = {}, eventsSubscribed = {};
function doPublishFor(eventName) {
var subscribers = eventsSubscribed[eventName],