Skip to content

Instantly share code, notes, and snippets.

@khoand0000
khoand0000 / jslint-jshint-jscs-eslint.md
Last active December 29, 2015 12:26
Which linting tool do I choose?

My choice is ESLint

I like post. I have not used any tools before. I follow the post and decide to choose ESLint because I like feature: turn on/off and edit configuration. JSLint comes from Douglas Crockford, is a good choice. Ideally, all developers use only shared rules-base, come from a experience person. But each company have its rules-base, comes from a leader's experience, just suit to the company. As a developer, we need to follow the company's rules-base even we want to or not. As a freelancer, I have my own rules-base, some rules suit for me, some are not.

References:

@khoand0000
khoand0000 / object-oriented-vs-functional-style.md
Last active December 30, 2015 12:47
using object-oriented or functional style with underscore?

From http://underscorejs.org/#chaining

You can use Underscore in either an object-oriented or a functional style, depending on your preference

I decided that using functional style even I love OOP because:

  • I want code style is consistent when using jquery, _.php (_.php uses static functions for usage, it is similar to functional style), _.js
  • There is a special case: chaining using OO style, I known. It is exception.
@khoand0000
khoand0000 / functional-reactive-programming.md
Created December 29, 2015 09:30
Functional Reactive Programming
@khoand0000
khoand0000 / email-template-editor.md
Last active December 27, 2015 20:03
email template editor

Tools

--> use mailchimp.com, export html and change code

Compare wordpress email plugin

@khoand0000
khoand0000 / clearing-input-type-file-using-jquery.md
Last active December 27, 2015 16:37
Clearing <input type='file' /> using jQuery
@khoand0000
khoand0000 / compare-roles-plugin.md
Last active December 26, 2015 17:55
compare roles plugin wordpress

user-role-editor

  • pros: support multiple roles for user. Permit add/remove other capabiliies for given user.
  • cons: all capabilities are listed flat layout, not grouped, hard for normal user (not wordpress developer)

advanced-access-manager

  • pros: good UI, easy usage, hide backend menu (love the function)
  • cons: user has just only role, can't add more capabilities into given user, just enable/disable capabilities belong to role that user belongs to

capability-manager-enhanced

  • pros: clear UI, I like table layout. copy role from existing role
@khoand0000
khoand0000 / multiple-modals-overlay.md
Created December 26, 2015 11:53
solution for multiple modals overlay

I copied the solution from link: http://stackoverflow.com/questions/19305821/multiple-modals-overlay

$(document).on('show.bs.modal', '.modal', function () {
    var zIndex = 1040 + (10 * $('.modal:visible').length);
    $(this).css('z-index', zIndex);
    setTimeout(function() {
        $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
    }, 0);
});
@khoand0000
khoand0000 / common-underscore-functions.md
Last active January 22, 2016 09:38
common underscore functions
pure js jquery angular _.js _.php pure php note
- [$.map] - [_.map] ->map [array_map] -
- - - [_.filter] ->filter [array_filter] -
- - - [_.pick] ->pick [array_filter] filter object (whitelisted keys)
- - - [_.omit] - filter object (blacklisted keys)
- - - [_.reduce] ->reduce - -
- - - [_.chain] Underscore::from - -
- - - [_.value] ->value - -
- - - [_.pluck] - -