refusing to merge unrelated histories 各种技巧

先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法pull





因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在git pull,

这句代码是在git 2.9.2版本发生的,最新的版本需要添加--allow-unrelated-histories

git pull origin master --allow-unrelated-histories


new 发布于 2018-6-28 05:50

js正则替换 各种技巧

代码如下:

        var str = '纳兰雪'; return new Array(str.length).join('*') + str.substr(-1);
                    

这种方法的原理是取最后一个字符,其他的根据字符串长度生成对应的*个数。通过new Array(str.length).join('*')获得元素的间隔,然后拼接这些间隔,拼出来的刚好是少一个字符,再加上截取的最后一个字符。

另一种方法:

        'wuhaidong很牛逼的'.replace(/.(?=.)/g, '*');
                    

这里主要用的是正则的(?=pattern),这东西还真没用过,平时看手册都不会去注意,原来这么有用的。可以理解为不占匹配位,不占匹配位就不会替换。

标签: js

new 发布于 2018-1-23 02:57

Linux 网卡启动失败 各种技巧

Bringing up interface eno16777736:  Error: Connection activation failed: Device not managed by NetworkManager or unavailable




Just follow the below steps and everything will be ok...


1. Remove Network Manager from startup Services.

#chkconfig NetworkManager off



2. Add Default Net Manager

#chkconfig network on



3.Stop NetworkManager first

#service NetworkManager stop



4.and then start Default Manager

#service network start

5./etc/init.d/network restart


new 发布于 2017-10-18 03:35

注册码 各种技巧

webstorm

http://im.js.cn:8888

https://idea.qmanga.com/

http://idea.medeming.com



http://idea.iteblog.com/key.php

20180801可用

http://xdouble.cn:8888/


9MWZD5CC4E-eyJsaWNlbnNlSWQiOiI5TVdaRDVDQzRFIiwibGljZW5zZWVOYW1lIjoiMjAxNzY1MDYxQGNxdS5lZHUuY24gLiIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJGb3IgZWR1Y2F0aW9uYWwgdXNlIG9ubHkiLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IklJIiwicGFp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SIb3DQEBCwUAA4ICAQAF8uc+YJOHHwOFcPzmbjcxNDuGoOUIP+2h1R75Lecswb7ru2LWWSUMtXVKQzChLNPn/72W0k+oI056tgiwuG7M49LXp4zQVlQnFmWU1wwGvVhq5R63Rpjx1zjGUhcXgayu7+9zMUW596Lbomsg8qVve6euqsrFicYkIIuUu4zYPndJwfe0YkS5nY72SHnNdbPhEnN8wcB2Kz+OIG0lih3yz5EqFhld03bGp222ZQCIghCTVL6QBNadGsiN/lWLl4JdR3lJkZzlpFdiHijoVRdWeSWqM4y0t23c92HXKrgppoSV18XMxrWVdoSM3nuMHwxGhFyde05OdDtLpCv+jlWf5REAHHA201pAU6bJSZINyHDUTB+Beo28rRXSwSh3OUIvYwKNVeoBY+KwOJ7WnuTCUq1meE6GkKc4D/cXmgpOyW/1SmBz3XjVIi/zprZ0zf3qH5mkphtg6ksjKgKjmx1cXfZAAX6wcDBNaCL+Ortep1Dh8xDUbqbBVNBL4jbiL3i3xsfNiyJgaZ5sX7i8tmStEpLbPwvHcByuf59qJhV/bZOl8KqJBETCDJcY6O2aqhTUy+9x93ThKs1GKrRPePrWPluud7ttlgtRveit/pcBrnQcXOl1rHq7ByB8CFAxNotRUYL9IF5n3wJOgkPojMy6jetQA5Ogc8Sm7RG6vg1yow==


vmware


适用于 vmware fusion 10 和 vmware fusion pro  10序列号  

FG3TU-DDX1M-084CY-MFYQX-QC0RD



new 发布于 2017-8-24 03:09

socket.io 2 游戏服务器

socket.io 中文手册,socket.io 中文文档转载于:http://www.cnblogs.com/xiezhengcai/p/3956401.html

服务端

io.on(‘connection’,function(socket));//监听客户端连接,回调函数会传递本次连接的socket

io.sockets.emit(‘String’,data);//给所有客户端广播消息

io.sockets.socket(socketid).emit(‘String’, data);//给指定的客户端发送消息

socket.on(‘String’,function(data));//监听客户端发送的信息

socket.emit(‘String’, data);//给该socket的客户端发送消息

广播消息

//给除了自己以外的客户端广播消息
socket.broadcast.emit("msg",{data:"hello,everyone"}); 
//给所有客户端广播消息
io.sockets.emit("msg",{data:"hello,all"});

分组

socket.on('group1', function (data) {
        socket.join('group1');
});
socket.on('group2',function(data){
        socket.join('group2');
 });

客户端发送

socket.emit(‘group1’),就可以加入group1分组;
socket.emit(‘group2’),就可以加入group2分组;

一个客户端可以存在多个分组(订阅模式)

踢出分组

socket.leave(data.room);

对分组中的用户发送信息

//不包括自己
socket.broadcast.to('group1').emit('event_name', data);
//包括自己
io.sockets.in('group1').emit('event_name', data);

broadcast方法允许当前socket client不在该分组内

获取连接的客户端socket

io.sockets.clients().forEach(function (socket) {
    //.....
})

获取分组信息

//获取所有房间(分组)信息
io.sockets.manager.rooms
//来获取此socketid进入的房间信息
io.sockets.manager.roomClients[socket.id]
//获取particular room中的客户端,返回所有在此房间的socket实例
io.sockets.clients('particular room')

另一种分组方式

io.of('/some').on('connection', function (socket) {
    socket.on('test', function (data) {
        socket.broadcast.emit('event_name',{});
    });
});

客户端

var socket = io.connect('ws://103.31.201.154:5555/some')
socket.on('even_name',function(data){
   console.log(data);
})

客户端都链接到ws://103.31.201.154:5555 但是服务端可以通过io.of(‘/some’)将其过滤出来。

另外,Socket.IO提供了4个配置的API:io.configure, io.set, io.enable, io.disable。其中io.set对单项进行设置,io.enable和io.disable用于单项设置布尔型的配置。io.configure可以让你对不同的生产环境(如devlopment,test等等)配置不同的参数。

客户端

建立一个socket连接

var socket = io(“ws://103.31.201.154:5555”);

监听服务消息

socket.on('msg',function(data){
    socket.emit('msg', {rp:"fine,thank you"}); //向服务器发送消息
    console.log(data);
});

socket.on(“String”,function(data)) 监听服务端发送的消息 Sting参数与服务端emit第一个参数相同

监听socket断开与重连。

socket.on('disconnect', function() {
    console.log("与服务其断开");
});

socket.on('reconnect', function() {
    console.log("重新连接到服务器");
});
客户端socket.on()监听的事件:
connect:连接成功
connecting:正在连接
disconnect:断开连接
connect_failed:连接失败
error:错误发生,并且无法被其他事件类型所处理
message:同服务器端message事件
anything:同服务器端anything事件
reconnect_failed:重连失败
reconnect:成功重连
reconnecting:正在重连
当第一次连接时,事件触发顺序为:connecting->connect;当失去连接时,事件触发顺序为:disconnect->reconnecting(可能进行多次)->connecting->reconnect->connect。

new 发布于 2017-7-27 02:26

socket.io 记 游戏服务器

var express = require('express');
var path = require('path');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.use(express.static(path.join(__dirname,'/public')));

io.on('connection', function(socket){
    console.log('a user connected');
    socket.on('msg', function(data){
        console.log(data);
        socket.broadcast.emit('new msg', data);
    });
    socket.on('disconnect',function(){
        console.log('user disconnet');
    });
});

http.listen(3000, function(){
    console.log('listening on 3000');
});



前端

<!DOCTYPE html>
<html>
<head>
    <title>sk</title>
</head>
<script src="https://cdn.bootcss.com/socket.io/1.7.3/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>

<body>
test<br/>
<div id="content"></div>
<input type="text" id="msg">
<input type="button" id="send_btn" value="Send" >
</body>
<script>
  window.onload=function(){
    var socket = io.connect('http://127.0.0.1:3000');

    socket.on('new msg', function(data){
      console.log('<<'+data);
      $('#content').html($('#content').html()+'<br/>'+ data);
    });
    console.log("-------------");

    $('#send_btn').click(function(){
      socket.emit('msg', $('#msg').val());
      $('#msg').val('');
      return false;
    });
  }
</script>
</html>

标签: socket.io

new 发布于 2017-7-26 03:04

SVN DELETE 各种技巧

常用操作
1.使用svn从工作拷贝删除文件只是预定要删除,当你提交,文件才会从版本库删除。
$ svn delete myfile

2.然而直接删除一个URL,你需要提供一个日志信息:
$ svn delete -m “Deleting file ‘yourfile'” file:///tmp/repos/test/yourfile

3.强制删除本地已修改文件的例子:
$ svn delete –force file


new 发布于 2017-7-24 03:02

unity shader 内置变量 Unity游戏研究

官网Manual:http://docs.unity3d.com/Manual/SL-UnityShaderVariables.html

unity提供大量的内置变量,来供我们使用,主要包括一些 :矩阵运算/变形,光影,时间等等。用户可以在CGIncludes目录下的UnityShaderVariables.cginc进行查看。


_WorldSpaceCameraPos:float3——相机的世界坐标

_ProjectionParams:float4——投影参数(x=+-1,y=相机近裁剪面,z=相机远裁剪面,w=1/FarPlane)

_ScreenParams:float4——屏幕参数(x=相机渲染宽度,y=相机渲染高度,z=1+1/x,w=1+1/y)


new 发布于 2017-3-23 03:23

typescript——BASE64 TypeScripts

/**
 *
 * @author 
 *
 */
class Base64Util {
    public constructor() {
    }

    public static BASE64_CHARS:string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

        public static version:string = "1.0.0";

        public static encode(data:string):string {
            // Convert string to ByteArray
            var bytes: egret.ByteArray = new egret.ByteArray();
            bytes.writeUTFBytes(data);

            // Return encoded ByteArray
            return this.encodeByteArray(bytes);
        }

        private static encodeByteArray(data:egret.ByteArray):string {
            // Initialise output
            var output:string = "";

            // Create data and output buffers
            var dataBuffer:Array<any>;
            var outputBuffer:Array<any> = new Array(4);

            // Rewind ByteArray
            data.position = 0;

            // while there are still bytes to be processed
            while (data.bytesAvailable > 0) {
                // Create new data buffer and populate next 3 bytes from data
                dataBuffer = new Array();
                for (var i:number = 0; i < 3 && data.bytesAvailable > 0; i++) {
                    dataBuffer[i] = data.readUnsignedByte();
                }

                // Convert to data buffer Base64 character positions and 
                // store in output buffer
                outputBuffer[0] = (dataBuffer[0] & 0xfc) >> 2;
                outputBuffer[1] = ((dataBuffer[0] & 0x03) << 4) | ((dataBuffer[1]) >> 4);
                outputBuffer[2] = ((dataBuffer[1] & 0x0f) << 2) | ((dataBuffer[2]) >> 6);
                outputBuffer[3] = dataBuffer[2] & 0x3f;

                // If data buffer was short (i.e not 3 characters) then set
                // end character indexes in data buffer to index of '=' symbol.
                // This is necessary because Base64 data is always a multiple of
                // 4 bytes and is basses with '=' symbols.
                for (var j:number = dataBuffer.length; j < 3; j++) {
                    outputBuffer[j + 1] = 64;
                }

                // Loop through output buffer and add Base64 characters to 
                // encoded data string for each character.
                for (var k:number = 0; k < outputBuffer.length; k++) {
                    output += this.BASE64_CHARS.charAt(outputBuffer[k]);
                }
            }

            // Return encoded data
            return output;
        }

        public static decode(data:string):string {
            // Decode data to ByteArray
            var bytes:egret.ByteArray = this.decodeToByteArray(data);

            // Convert to string and return
            return bytes.readUTFBytes(bytes.length);
        }

        private static decodeToByteArray(data:String):egret.ByteArray {
            // Initialise output ByteArray for decoded data
            var output:egret.ByteArray = new egret.ByteArray();

            // Create data and output buffers
            var dataBuffer:Array<any> = new Array(4);
            var outputBuffer: Array<any> = new Array(3);

            // While there are data bytes left to be processed
            for (var i:number = 0; i < data.length; i += 4) {
                // Populate data buffer with position of Base64 characters for
                // next 4 bytes from encoded data
                for(var j: number = 0; j < 4 && i + j < data.length; j++) {
                    dataBuffer[j] = this.BASE64_CHARS.indexOf(data.charAt(i + j));
                }

                // Decode data buffer back into bytes
                outputBuffer[0] = (dataBuffer[0] << 2) + ((dataBuffer[1] & 0x30) >> 4);
                outputBuffer[1] = ((dataBuffer[1] & 0x0f) << 4) + ((dataBuffer[2] & 0x3c) >> 2);        
                outputBuffer[2] = ((dataBuffer[2] & 0x03) << 6) + dataBuffer[3];

                // Add all non-padded bytes in output buffer to decoded data
                for(var k: number = 0; k < outputBuffer.length; k++) {
                    if (dataBuffer[k+1] == 64) break;
                    output.writeByte(outputBuffer[k]);
                }
            }

            // Rewind decoded data ByteArray
            output.position = 0;

            // Return decoded data
            return output;
        }
}

new 发布于 2017-2-23 06:30

nodejs跨域问题 各种技巧

node配置


app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    next();
});



new 发布于 2017-2-14 06:10