Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

i18u iahu

🌴
On vacation
View GitHub Profile
View 前后端分离.NodeJs.md

#前后端分离.NodeJs


##为什么要前后端分离

  1. 各种终端设备的兴起,需要我们把页面适配到更多的地方。
  2. 业务复杂,而我们希望尽可能地减少工作量,开始使用类似MV*的分层结构,使前端后分离成为必要。
  3. 前端需要处理更多的工作,希望有权操控View,Router(如:SPA的尝试)

历史发展的必然选择

@iahu
iahu / uninstall.sh
Created Apr 29, 2015
OSX 10.10 uninstall VMsvga2_v1.2.5
View uninstall.sh
#!/bin/bash
SLE=/System/Library/Extensions
RM=/bin/rm
PKGUTIL=/usr/sbin/pkgutil
TOUCH=/usr/bin/touch
if (( $UID != 0 )); then
echo This script must be run as root, try \'sudo $0\'
exit 1
@iahu
iahu / index.ios.js
Last active Oct 30, 2015
react-native setState issue
View index.ios.js
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var fs = require('NativeModules').FileSystem;
var {
AppRegistry,
@iahu
iahu / getShengmu.js
Created Aug 7, 2015
js获取汉字声母
View getShengmu.js
var getShengmu = (function () {
var idx = -1;
var MAP = 'ABCDEFGHJKLMNOPQRSTWXYZ';
var boundaryChar = '驁簿錯鵽樲鰒餜靃攟鬠纙鞪黁漚曝裠鶸蜶籜鶩鑂韻糳';
if ( !String.prototype.localeCompare ) {
throw Error('String.prototype.localeCompare not supported.');
}
return function getShengmu(c) {
@iahu
iahu / demo.html
Created Sep 22, 2015
篡改“浏览器后退按钮”历史纪录 demo
View demo.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
<style>
</style>
</head>
<body>
<p>demo.html</p>
@iahu
iahu / log.js
Last active Sep 28, 2015
js console wrapper,can print original call code line number
View log.js
var log = (function () {
if ( console && typeof console.log === 'function' ) {
if (console.log.bind) {
return console.log.bind(console);
} else {
return $.proxy(console.log, console);
}
} else {
return function () {
var log = window.__im_log = window.__im_log || [];
@iahu
iahu / outerHTML.js
Created Oct 29, 2015
element.outerHTML
View outerHTML.js
var p = document.getElementsByTagName("p")[0];
console.log(p.nodeName); // shows: "P"
p.outerHTML = "<div>This div replaced a paragraph.</div>";
console.log(p.nodeName); // still "P";
/*
Feature | Firefox (Gecko) | Chrome | Internet Explorer | Opera Safari
Basic support | 11 (11) | 0.2 | 4.0 | 7 1.3
View bracket-matcher.js
function getLeftMarkIndex (codeStr, idx) {
var leftCS = codeStr.slice(0, idx);
var leftMarkIdx;
var rOpenMark = /[\[\{\(]/;
var rCloseMark = /[\]\}\)]/;
var matchMarks = /([\[\{\(]|[\]\}\)])/;
var matchMap = {']': '[', '}': ']', ')': '('};
var unpairedCount = 0;
for (var i = leftCS.length - 1; i >= 0; i--) {
@iahu
iahu / safari-touchemulator.user.js
Created Dec 17, 2015
emulate touch events of safari(with iOS userAgent)
View safari-touchemulator.user.js
// ==UserScript==
// @name emulator_touch_events
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author author (uses https://github.com/hammerjs/touchemulator)
// @match http://tampermonkey.net/index.php?version=3.13.4890&ext=G3XV&updated=true
// @match *://*/*
// @grant none
// ==/UserScript==
@iahu
iahu / tips.css
Last active Jan 28, 2016
mobile-tips.js
View tips.css
.mo-tips {
position: fixed;
top: 50%;
left: 50%;
width: 240px;
/*min-height: 100px;*/
margin-top: -50px;
margin-left: -120px;
background-color: #fff;