Thursday, January 14, 2016

scaffold to make js library support amd and commonjs

Here is the scaffold using IIFE (Immediately-Invoked Function Expression):
(function (root, factory) {
  if(typeof define === "function" && define.amd) {
    // Now we're wrapping the factory and assigning the return
    // value to the root (window) and returning it as well to
    // the AMD loader.
    define(["postal"], function(postal){
      return (root.myModule = factory(postal));
    });
  } else if(typeof module === "object" && module.exports) {
    // I've not encountered a need for this yet, since I haven't
    // run into a scenario where plain modules depend on CommonJS
    // *and* I happen to be loading in a CJS browser environment
    // but I'm including it for the sake of being thorough
    module.exports = (root.myModule = factory(require("postal")));
  } else {
    root.myModule = factory(root.postal);
  }
}(this, function(postal) {
  // module code here....

  var sub;
  var ch = postal.channel("myModule");
  var myModule = {
    sayHi:function() {
      ch.publish("hey.yall", { msg: "myModule sez hai" });
    },
    dispose: function() {
      sub.unsubscribe();
    }
  };

  return myModule;
}));
Here is the reference blog:
http://ifandelse.com/its-not-hard-making-your-library-support-amd-and-commonjs/

Monday, January 4, 2016

Bootstrap 3.x review

We are based on Bootstrap!!!!! Semantics, reusable, customizable

We are using HTML5 for semantics tags!!!

<article>    Defines an article
<aside>    Defines content aside from the page content
<details>    Defines additional details that the user can view or hide
<figcaption>    Defines a caption for a <figure> element
<figure>    Specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.
<footer>    Defines a footer for a document or section
<header>    Specifies a header for a document or section
<main>    Specifies the main content of a document
<mark>    Defines marked/highlighted text
<nav>    Defines navigation links
<section>    Defines a section in a document
<summary>    Defines a visible heading for a <details> element
<time>    Defines a date/time

Variables:
    colors (grayscale and semantic),
    Scaffolding (bg-color, text-color),
    Links (link-color, link-hover-color)
    Typography (font-family, font-size, line-height, headings)
    Icons (icon-font-path, icon-font-name)
    Components (padding vertical/horizontal, line-height, border-radius, active-color, active-bg, caret-width-base)
    transitions
    animations
    opacity
    placeholder

Mixin: Use mixins, like size(), sizable(), opacity()

color/background color
border
spacing (padding/margin)
font weight (400, 500, 600)
font size (xs, sm, default, md, lg, xl, )
h1-h6
text
floating (pull-left, pull-right)
pull/push
variables (font-size-base, line-height-base)
alignment (text-left, center, right, justify, nowrap) - we need a mx-text-wrap
list (either ul/li, or div/div, list-inline, list-unstyled)
block (p, pre, pre-scrollable)
table
contextual (active, success, info, warning, danger)
forms (form-group, form-control, inline-form, input-group, input-group-addon, form-horizontal, .form-control-static)
input: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color
textarea
checkbox/radio
select
validation states (.has-warning, .has-error, or .has-success)
button: Use the button classes on an <a>, <button>, or <input> element.
button-style:default, primary, success, info,warning, info, danger, link (.btn-block to span the full width of a parent)
accessibility: additional text hidden with the .sr-only class (screen-reader)
utility class: states: active, disabled,
images (img-responsive, center-block, img-rounded, img-circle, img-thumbnail)

Contextual colors
Contextual backgrounds
close
Carets
pull-left/pull-right/navbar-left/navbar-right
center-block
clearfix
show/hidden/invisible (block element, sr-only)
Print classes

Inline text elements (mark, del, s, ins, u, small, strong, em, )

Bootstrap's global default font-size is 14px, with a line-height of 1.428. This is applied to the <body> and all paragraphs. In addition, <p> (paragraphs) receive a bottom margin of half their computed line-height (10px by default).

Monday, December 28, 2015

OTC medicine

过敏药
Benadryl (学名diphenhydramine, 苯海拉明, ) 第一代抗组织胺(anti-histamine), 因为会作用在中枢神经,所以会嗜睡
新一代的抗组织胺, Claritin (学名loratadine),Zyrtec(学名cetirizine), Allegra (学名fexofenadine)
Walmart有便宜的,包装上多半是直接写学名(就是loratadine/cetirizine)

Diphenhydramine, 苯海拉明,常用于各种普通过敏(酒精、过敏性鼻炎、皮肤过敏),同时也可用于晕动症(常乘车或乘船游玩者必备之一)。
主要用于一般性过敏引起的荨麻疹和皮肤瘙痒症状,还可用于预防晕船、晕车、晕飞机等晕动病。由于服用后的不良症状多为困乏嗜睡,该药品一般归于药房的助眠药物区域。

如果是需要应付繁重的学习任务或工作安排,建议可以选择 Levocetirizine Hydrochoride(左旋西替利嗪)、Desloratadine(地氯雷他定), 第三代抗组胺

止痛消炎

Ibuprofen (布洛芬)
Acetaminophen (对乙酰氨基酚)
这两种药物都是非类固醇(Nonsteroidal Anti-inflammatory Drug,NSAID)消炎药(不是抗生素Antibiotics),常用于39℃以上的发热(非细菌感染)、止痛(感冒的头痛、生理痛、宿醉后头痛)。

Ibuprofen是一种非类固醇的消炎药,也是世界卫生组织指定的必备药品之一。它主要用于减缓疼痛、炎症或者感冒引起的发热症状,为避免服用后可能会产生胃部不适或者胃灼热,一般推荐与食物同时服用。正常情况下儿童可以服用。推荐品牌:Motrin, Advil

Acetaminophen是非处方药类里一款缓解疼痛和退烧的非消炎药。按照标准剂量服用Acetaminophen是相当安全的,因此,患病婴儿或者儿童都适宜此药。 推荐品牌:Tylenol

另一种相似作用的药物叫做Asprin,阿司匹林,但是更容易诱发胃肠道反应(恶心、腹泻),还可能导致消化道溃疡。

不论是Ibuprofen(布洛芬),还是Acetaminophen、Paracetamol(对乙酰氨基酚),还是Asprin(阿司匹林),本身对胃肠道都会有刺激(只是程度有轻重),消化道溃疡发作时切勿服用。服用时切勿饮酒!

腹泻

Loperaminde,洛哌丁胺,又叫 易蒙停,止泻药,用于控制急性、慢性腹泻的症状。
腹泻,不论急性或慢性,丟失能量和电解质都是常有的事儿,所以不论能否自行判断病因,补充能量和电解质都是首要的。所以家里一定要常备生理盐水(Normal Saline,或自行冲泡糖盐水,以刚好感觉到有味道为宜)补充能量和电解质。

Pepto Bismol(主要成分为:Bismuth Subsalicylate 水杨酸亚铋)所以如果是作为抵抗胃酸过多的情况,Pepto Bismol还是有其道理,但是倘若仅仅是腹泻,似乎有点过了。

与易蒙停有相似用途的有蒙脱石散(Montmorillonite Powder,思密达,服用过量易致便秘)、鞣酸蛋白酵母散(Albumin Tannate and Barm powder,易吸收,但服用过量易致便秘),可以与Loperaminde(洛哌丁胺)联用。

药片和液体形式都适宜儿童服用。推荐品牌:Imodium, Pepto Bismol

感冒
Pseudoephedrine,伪麻黄碱,用于感冒或过敏引起的鼻塞、咳嗽、咳痰不爽。

晕动症
Meclizine,氯苯甲嗪,用于抗晕动症,可参考第2项“与晕动症相关的药物”。推荐品牌:Bonine, Dramamine

胃酸过多
Ranitidine,雷尼替丁,用于缓解胃酸过多所致的胃痛、胃灼热感(烧心)、反酸;用于治疗十二指肠溃疡、反流性食管炎等。Zantac, Priloses, PrevACID, Zegerid
禁忌:8岁以下孩子、孕期妇女、哺乳期妇女禁用。市面上同类用于减轻胃酸或者反胃的药物,还有Prilosec、Prevacid、Zegerid等。其中,Prevacid适合孕期服用,缓解孕妇胃灼热 推荐品牌:Zantac
与之近似用途的药物:Cimetidine, Famotidine, Omeprazole, Zegerid, Lansoprazole, Esomeprazole, Rabeprazole.

皮炎湿疹
Hydrocortisone cream, 氢化可的松乳膏,用于过敏性皮炎、脂溢性皮炎、过敏性湿疹、苔藓样瘙痒症。Cortizone 10, Benadryl cream
它对于治疗由感染或过敏引起的轻微皮肤不适非常有效。患病成人或儿童均宜使用。同类产品还推荐diphenhydramine cream。 推荐品牌:Cortizone

抗菌药膏

Neosporin Ointment,新斯波林软膏,抗菌药膏,可用于各种烧、烫、割、擦伤的局部杀菌.与之近似的药物如:Mupirocin Ointment(莫匹罗星软膏,百多邦)、Erythromycin Ointment(红霉素软膏)。相比较之下,Neosporin(新斯波林)和 Mupirocin(莫匹罗星)都更不容易促使细菌耐药,对于常见的程度较轻的烧、烫、割、擦伤能有很好的抗菌效果.

真菌感染
Clotrimazole,克霉唑,用于真菌感染,常用于皮肤癣病、女性阴道炎(真菌感染)。
与之有近似用途的药物有:Miconazole(咪康唑)、Ketoconazole(酮康唑)、Itraconazole(伊曲康唑)、Fluconazole(氟康唑)、Tebinafine(特比萘芬),其中以Fluconazole(氟康唑)的作用最强,以Terbinafine(特比萘芬)最安全(对肝影响更小)。一般通过局部涂抹来治疗皮肤上的真菌感染,比如癣菌病,尿布疹等。用于治疗女性宫颈感染时,可以选择其栓剂或者膏药形式。 推荐品牌:Lotrimin




Reference link:
http://www.sayweee.com/article/view/04quv
http://www.backchina.com/news/2015/02/15/346577.html
http://www.guokr.com/post/611235/