Skip to content

Instantly share code, notes, and snippets.

function getStringMemorySize(_string) {
"use strict";
var codePoint, accum = 0;
for (var stringIndex = 0, endOfString = _string.length; stringIndex < endOfString; stringIndex++) {
codePoint = _string.charCodeAt(stringIndex);
if (codePoint < 0x100) {
accum += 1;
continue;
}
@lirongfei123
lirongfei123 / 匹配汉字
Last active September 21, 2016 08:39
正则表达式
然后把范围扩大到^[\u2E80-\u9FFF]+$, 这样倒是都通过了, 这个应该就是匹配中日韩文字的正则表达式了, 包括我們臺灣省還在盲目使用的繁體中文
而关于中文的正则表达式, 应该是^[\u4E00-\u9FFF]+$, 和论坛里常被人提起的^[\u4E00-\u9FA5]+$很接近
这里是几个主要非英文语系字符范围
function cloneImg (elem) {
var imgNode = document.createElement("div");
var attributes = elem.attributes;
for (var i in attributes) {
if(!attributes.hasOwnProperty(i)) {
continue;
}
var attr = attributes[i];
if(attr.name == 'class') {
imgNode.className = attr.value;
// returns true if the element or one of its parents has the class classname
function hasSomeParentTheClass(element, classname) {
if (element.className.split(' ').indexOf(classname)>=0) return true;
return element.parentNode && hasSomeParentTheClass(element.parentNode, classname);
}
  • 显示日期的时候,单数加上零
  • 加上快捷键
  • 打开表单自动聚焦
.submiting {
position:relative;
text-indent: -110026px;
background:#5ba4e5;
&:before{
content: "";
position: absolute;
width: 6px;
height: 6px;
border: 4px solid rgba(0,0,0,.2);
defaults write com.apple.appstore ShowDebugMenu -bool true
@lirongfei123
lirongfei123 / chat.html
Created May 1, 2017 08:32 — forked from orkaplan/chat.html
simple node.js socket.io client/server example
<html>
<head>
<title>Node.js IL Chat</title>
<script type="text/javascript" src="/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script language="javascript">
var socket;
$(document).ready(function()
{
@lirongfei123
lirongfei123 / chat.html
Created May 1, 2017 08:32 — forked from orkaplan/chat.html
simple node.js socket.io client/server example
<html>
<head>
<title>Node.js IL Chat</title>
<script type="text/javascript" src="/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script language="javascript">
var socket;
$(document).ready(function()
{
@lirongfei123
lirongfei123 / nodejs-tcp-example.js
Created May 1, 2017 08:33 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');