This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var timer = Timer() | |
timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(ViewController.updateTimer), userInfo: nil, repeats: true) | |
//更新timer | |
func updateTimer() { | |
counter = counter + 0.1 | |
timeLabel.text = String(format: "%.1f", counter) + "--" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
搭建自己的JavaScript挖矿代理 | |
Posted on 2017-10-12 | |
本文介绍了如何搭建自己的js挖矿代理服务器,并在本篇博客中提供了示例。因此,当您决定继续阅读本篇博文时,您已经在为笔者挖取门罗币(Monero)了。 | |
0000b 背景 | |
自从某国外知名网站宣布尝试使用js挖矿来取代广告收入后,js挖矿开始被大家所知。据报道,传说中的知名网站使用的是coinhive提供的技术进行Monero的挖取。coinhive提供了成套的解决方案。只要大家愿意,完全可以在几分钟内将挖矿程序嵌入到自己的网站中。 不过,coinhive与其他矿池并没有合作。这就是说,如果你已经在其他矿池通过矿机或自己闲置的PC挖矿的话,通过网页挖到的收益并不能整合到已有的矿池中,此外coinhive还要缴纳30%的挖矿收入。再考虑到无论是coinhive还是其他各种矿池,都是要在挖到一定数量的货币以后才会进行支付,所以对于笔者这样算力有限的小矿工来说,集中算力在一个矿池挖矿才是正事。因此,本篇文章将介绍如何借用coinhive的挖矿脚本,躲过30%的苛捐杂税,在自己已经奋斗多年的矿池里挖矿。 | |
0001b 原理介绍 | |
coinhive提供的挖矿脚本使用websocket与服务端进行通信,而各大矿池通常使用Stratum Mining Protocol来与挖矿的worker通信。默认情况下,coinhive自己的脚本当然是连接到自家的服务器。我们要做的就是搭建一台代理服务器,完成Stratum Mining Protocol和coinhive使用的websocket协议之间的转换,然后配置coinhive的脚本,让其连接我们自己的代理服务器即可。So Easy! | |
0010b 开源代理服务器项目介绍 | |
有了想法之后,到GitHub上搜索了一番,果然已经有前辈完成了相关的工作,看来我们剩下的工作只需要将其部署到自己的服务器上就行了。在此提供两个开源项目: | |
* coinhive-stratum-mining-proxy 使用Python和twisted库编写的Proxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 滚动条 */ | |
::-webkit-scrollbar-thumb:horizontal { /*水平滚动条的样式*/ | |
width: 5px; | |
background-color: #CCCCCC; | |
-webkit-border-radius: 6px; | |
} | |
::-webkit-scrollbar-track-piece { | |
background-color: #fff; /*滚动条的背景颜色*/ | |
-webkit-border-radius: 0; /*滚动条的圆角宽度*/ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wAlert = window.alert; | |
window.alert = function (message) { | |
try { | |
var iframe = document.createElement("IFRAME"); | |
iframe.style.display = "none"; | |
iframe.setAttribute("src", 'data:text/plain,'); | |
document.documentElement.appendChild(iframe); | |
var alertFrame = window.frames[0]; | |
var iwindow = alertFrame.window; | |
if (iwindow == undefined) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
创建新的SSH key | |
ssh-keygen -t rsa -C "your-email-address" | |
config文件的内容如下: | |
#Default GitHub | |
Host github.com | |
HostName github.com | |
User one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var str = 'Tue Jan 09 2018 00:00:00 GMT+0800 (CST)'; | |
var getFormatDate = function (str) { | |
var monthToNumber = { | |
"Jan": "01", | |
"Feb": "02", | |
"Mar": "03", | |
"Apr": "04", | |
"May": "05", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('...').on('change', function () { | |
var filearr = []; | |
var myfile = document.getElementById('file'); | |
var files = this.files; | |
var formData = new FormData(); | |
for (var i = 0; i < files.length; i++) { | |
//提交时,我们把filearr中的数据遍历一遍 | |
console.log(i, files[i]); | |
formData.append('file', files[i]); //用append添加到formData中 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name docs.lvrui.io | |
rewrite ^(.*)$ https://$host$1 permanent; | |
} | |
server { | |
listen 443 ssl; | |
server_name docs.lvrui.io; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#先关闭mysql服务 | |
service mysqld stop | |
#安全模式启动mysql,加入--skip-networking 防止远程无密码登录 | |
# find / -name mysqld_safe 查找mysqld_safe文件路径 | |
mysqld_safe --skip-grant-tables --skip-networking & | |
#无密码登录 | |
mysql -u root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sel = window.getSelection(); //DOM | |
var range = sel.getRangeAt(0); // DOM下 | |
// DOM下 | |
sel.removeAllRanges(); // 删除Selection中的所有Range | |
range.deleteContents(); // 清除Range中的内容 | |
// 获得Range中的第一个html结点 | |
var container = range.startContainer; | |
// 获得Range起点的位移 | |
var pos = range.startOffset; |
OlderNewer