ITeye博客

李俊良

李俊良 · 共 104 篇文章

js回溯算法解决数独问题

直接上代码 代码里面注释很清晰 传说中的最难数组大概是在20ms左右解决 /** * 数独算法 */ class Sudoku { constructor({ display = false, sudokuMap = [] }) { // 是否展示算法过程 this.display = display; // 原始数独数组 this.sudokuMap = sudokuMap; // 回溯数组 this.stacks = []; // 是否已经解答完成 this.resolved = false; this.allTimes = 0; // 所有的循环次数统计 this.dataMap = …

2018-09-17 17:34 · 一些小函数 · nodejs · 评论(0)

html5 video标签播放问题

1、动态创建video标签 如果是用jquery的$html方法或者after等方法,都会有播放延时问题 需要使用标准的createElement方法创建 2、h264播放兼容问题 3、nginx server需要安装nginx_mod_h264_streaming更好

2014-11-14 15:57 · 评论(0)

git 使用

Git Server Group-level Structures DEC 10TH, 2012 | COMMENTS If you use a small number of git, you can use the following steps to quickly deploy a git server environment. For example, as I am now the situation to two people on assignment to Qita company to do projects, but to do something that is co…

2014-06-12 10:16 · 评论(0)

redis中统计sorted set的score的总和的lua脚本

eval "local res = 0;local totalCards;local i =0; totalCards = redis.call('zrangebyscore','inTimeCost','-inf','+inf','withscores');for i,v in ipairs(totalCards) do if i%2 == 0 then res = res + v; end; end;return res;" 0

2014-06-05 10:08 · 评论(0)

redis中文key或者value的查看

只需要在使用redis-cli的时候带上 redis-cli --raw即可,里面就全部都是中文了

2014-05-05 15:37 · 评论(0)

git grunt jshint实例

编辑.git/hook/pre-commit 文件 #!/usr/bin/env node var spawn = require('child_process').spawn; var grunt = spawn('grunt',['-gruntfile', '/opt/ninja-server/grunt/Gruntfile.js']); grunt.stderr.on('data',function(data){ console.log(data.toString()); }); grunt.stdout.on('data',function(data){ data = data.to…

2014-04-17 13:06 · 评论(0)

git server

此文件是依据markdown所编写,更好效果参见本人github的文档https://github.com/jackliu2013/recipes/blob/master/doc/linux/CentOS_6.4_git服务器搭建.md ##CentOS安装Git服务器 Centos 6.4 + Git 1.8.2.2 + gitosis## 1.查看Linux系统服务器系统版本 ``` cat /etc/redhat-release # 查看系统版本 CentOS release 6.4 (Final) ifconfig # 查看服务器的IP eth0 Link encap:Etherne…

2014-04-16 22:04 · 评论(0)

nodejs socket.io 结合php 通过 redis来配置登录验证

io.set('authorization', function (handshakeData, accept) { if (handshakeData.headers.cookie) { handshakeData.cookie = cookie.parse(handshakeData.headers.cookie); if(handshakeData.cookie && handshakeData.cookie['PHPSESSID']){ var sessionClient = redis.createClient(); var sessionData; sessionClient.g…

2013-11-15 18:33 · 评论(0)

nodejs 控制脚本

/** super.js 用于启动js服务 保证js服务停止后自动启动 并且加入日志记录 */ var spawn = require('child_process').spawn, server = null; function startServer(){ console.log('restart server'); server = spawn('node',['/data/pushserver/js/pushserver.js','>','push.log']); console.log('node js pid is '+server.pid); server.on('close'…

2013-11-15 18:27 · 评论(0)

远程url访问自动更新SVN

1.给PHP指定一个用户,修改php-fpm配置文件即可 2.给这个用户加入到免sudo登陆列表中/etc/sudoers php ALL=(ALL) NOPASSWD:ALL 3.脚本文件 sudo svn update

2013-11-13 12:08 · 评论(0)

整形转2进制后里面有多少个1

var input = 10140101;//传入的参数 var count = 0; function getCount(ins){ if(ins == 0){ return count; } var ret = ins%2; var shan = Math.floor(ins/2); if(ret == 1){ count++; } return getCount(shan); } var ret = getCount(input); console.log(ret);

2013-11-08 18:03 · 评论(0)

nginx 反向代理nodejs websocket,实现负载均衡

1.要求安装nginx1.3以上版本,具体安装请查询各种文档 2.nginx配置 map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream nodesocket { server 127.0.0.1:10080 fail_timeout=20s; server 127.0.0.1:10081 fail_timeout=20s; } server { listen 80; server_name socket.localhost.com; location / { proxy_pass http:…

2013-11-07 11:09 · 评论(0)

nginx php 配置

yum install libxml2-devel yum install freetype-devel jpeg-devel libpng-devel yum install libmcrypt libltdl yum install libtool-ltdl-devel yum install curl-devel yum install mysql-devel ./configure --prefix=/usr/local/php5.3.27 --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysqli …

2013-11-05 16:25 · 评论(0)

移动版和PC网站兼容的做法研究

现在兼容做移动版兼容 见过的比较多的是做媒体自适应 通过媒体的宽度等来处理 还有通过js来跳转 比如baidu会分为www.baidu.com和m.baidu.com 里面分的比较细致 还有一种是就是 www.m12305.com 这种方式 我把这三种分别说成 1.媒体自适应,css来判断 2.域名跳转适应 可以用多种技术 3. www.m12305.com ,后台判断user-agent来加载不同的模板文件 首先我觉得最好的还是第三种 纯靠媒体自适应不靠谱,因为PC端和移动端不仅仅是布局会有差异 还需要考虑数据量的差异,移动端加载的数据量应该比PC端稍微少一些 用域名跳转的方式也不好,因为…

2013-09-18 12:19 · 前端优化思考 · 评论(0)

瀑布流网站记录

美图世界

2013-09-07 23:09 · 评论(2)