Ask Stack: Are fewer lines of code better?

2013年10月12日 评论已被关闭 565 views

This Q&A is part of a biweekly series of posts highlighting common questions encountered by technophiles and answered by users at Stack Exchange, a free, community-powered network of 80+ Q&A sites.

Mike Bryant asks:
Which of these programming styles is better?

<code>var result = methodOne(methodTwo(a, methodThree(b)), c, d); </code>

or

Read 20 remaining paragraphs | Comments

       



分类: OpenSource 标签:

Web Served, the finale: Congrats, you have a Web server! What’s next?

2013年10月10日 评论已被关闭 515 views
Aurich Lawson / Thinkstock

Welcome, dear readers, to the final piece in our long-running “Web Served” series. Starting last November, Ars has been helping to shed light on the fun world of DIY Web hosting—we started with setting up Nginx on Ubuntu, and we’ve progressed to advanced application hosting with PHP and even Node.js.

Along the way we’ve struggled with the command line and probably cursed at typos in config files. We’ve felt the incredible triumph of a simple “success” log file message and the crushing defeat of an error that appears to be happening for absolutely no reason. If you’ve stuck with us for the entire spread of articles, you’ve got a full-featured Web server capable of safely and quickly serving pages and running a wide range of awesome applications. Congratulations are in order—good job!

At this point you’ve got a functional Nginx Web server that’s configured with an eye toward speed and security. You’ve got it configured with SSL/TLS, (maybe) have some official certificates, and can serve data encrypted. You’ve got PHP set up along with the MySQL-compatible MariaDB, so you can handle serving most popular Web applications. Speaking of applications, you also probably have a WordPress blog, a Vanilla forum, and maybe even your own MediaWiki wiki.

Read 54 remaining paragraphs | Comments

       



分类: OpenSource 标签:

Google offers “leet” cash prizes for updates to Linux and other OS software

2013年10月9日 评论已被关闭 466 views

Google is offering rewards as high as $3,133.70 for software updates that improve the security of OpenSSL, OpenSSH, BIND, and several other open-source packages that are critical to the stability of the Internet.

The program announced Wednesday expands on Google’s current bug-bounty program, which pays from $500 to $3,133.70 to people who privately report bugs found in the company’s software and Web properties. Security researchers inside the company considered modifying the program to reward bug reports in open-source software, but eventually decided against that approach. The reason: bug bounty programs often invite a flood of reports of varying quality that can overwhelm the finite resources of open-source developers. What’s more, it’s frequently much harder to patch a vulnerability than merely to find it.

“So we decided to try something new: provide financial incentives for down-to-earth, proactive improvements that go beyond merely fixing a known security bug,” Michael Zalewski, a member of the Google security team, wrote in a blog post. “Whether you want to switch to a more secure allocator, to add privilege separation, to clean up a bunch of sketchy calls to strcat(), or even just enable ASLR—we want to help.”

Read 2 remaining paragraphs | Comments

       



分类: OpenSource 标签:

“Most powerful” Arduino ever has ARM Cortex-A8 chip, runs “full Linux”

2013年10月3日 评论已被关闭 888 views
The Arduino Tre.
Arduino

The Arduino line of open source electronic prototyping platforms is getting some major upgrades. Earlier today, the first Intel-powered Arduino was announced, and it will be available by the end of November.

Arduino has also announced the Arduino Tre, based on the Texas Instruments Sitara AM335x ARM Cortex-A8 processor. Texas Instruments said that with the Tre’s 1GHz processor, it is the “most powerful Arduino to date” and the first that will be able to run “full Linux.” It will be available in spring 2014 from arduino.cc and other distributors, with pricing not yet announced.

“For the first time ever, Arduino users can use the full capabilities of Linux and gain access to a variety of new on-board connectivity options to develop a range of powerful, advanced applications while leveraging the simplicity of the Arduino software experience,” the Texas Instruments announcement said. “The Sitara-processor-powered Arduino Tre serves as a network hub that can connect to millions of classic Arduino nodes, enabling customers to be at the forefront of the Internet-of-Things era.”

Read 8 remaining paragraphs | Comments

       



分类: OpenSource 标签:

Code review 工具gerrit之体验

2013年9月17日 评论已被关闭 6,238 views

之前一直使用gitlab来管理代码,由于gitlab并没有强制code-review的功能,所以仓库管理员一直在找合适的工具进行Code-review,于是推荐给我gerrit,我从开始一直认为gerrit只是个code-review的辅助工具,必须跟gitlab整合起来使用,在不将二者捏到一块不罢休的理念下把二者的关系弄得越来越糊涂,用惯了gitlab总觉得gerrit太挫,于是前阵子果断放弃gerrit。
但是在仓库管理员的逼迫及公司对Code-review的迫切程度的驱使下,不得已又抽空看了看gerrit,目前看来gerrit本身就可以管理git,跟gitlab可以没有丝毫瓜葛。以下权且算是一份安装笔记,因为gerrit的具体如何使用还没真正搞明白。

安装环境:Centos6.4 + gerrit-2.6.1 + LDAP + mysql-5.1.69

Install gerrit
参考: http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/index.html
下载war
wget http://gerrit-releases.storage.googleapis.com/gerrit-2.6.1.war

初始化数据库
Install/config mysql
CREATE USER ‘gerrit’@’localhost’ IDENTIFIED BY ‘pwd’;
CREATE DATABASE reviewdb;
ALTER DATABASE reviewdb charset=utf8;
GRANT ALL ON reviewdb.* TO ‘gerrit’@’localhost’;
FLUSH PRIVILEGES;

创建用户
sudo adduser gerrit
sudo su gerrit
java -jar gerrit.war init -d /home/gerrit/gerritapp

init时mysql有个报错:
阅读全文…

分类: git, linux 标签: , ,

nginx lua as http client

2013年9月17日 评论已被关闭 5,085 views

首先感谢agentzh的辛苦大作,这里使用了openresty的版本。

1. 编译openresty


wget http://openresty.org/download/ngx_openresty-1.2.8.6.tar.gz
tar xzvf ngx_openresty-1.2.8.6.tar.gz
cd ngx_openresty-1.2.8.6/
./configure --with-luajit
make
make install

2.获取lua http client


git clone https://github.com/liseen/lua-resty-http

3. nginx vhost配置
阅读全文…

分类: linux, nginx 标签: ,

nagios plugins check_proc_runtime

2013年6月3日 评论已被关闭 1,454 views

A nagios plugin of check proc running time. which can check a specified process running time, If it has been running too long time..

code:
check_proc_runtime

usage on nrpe:

$ cat nrpc.conf
command[check_proc_rsync]=/usr/local/nagios/libexec/check_proc_runtime -k rsync -e inotify -c 360

分类: python 标签: , ,

nginx+lua module直接调用redis实现url跳转

2013年5月24日 评论已被关闭 3,284 views

需求:想要实现的功能是lua通过id取redis中对应的url然后进行url跳转。

nginx编译用到的模块:
git clone https://github.com/simpl/ngx_devel_kit.git
git clone https://github.com/chaoslawful/lua-nginx-module
git clone https://github.com/agentzh/redis2-nginx-module.git
git clone https://github.com/agentzh/set-misc-nginx-module.git
git clone https://github.com/agentzh/echo-nginx-module.git
git clone https://github.com/catap/ngx_http_upstream_keepalive.git

阅读全文…

分类: nginx 标签: , ,

使Cacti流量图超过80M的解决方法

2013年4月3日 评论已被关闭 1,308 views

Before:

# /usr/local/rrdtool/bin/rrdtool info /var/www/html/rra/71/2995.rrd
ds[traffic_in].min = 0.0000000000e+00
ds[traffic_in].max = 1.0000000000e+07
ds[traffic_out].min = 0.0000000000e+00
ds[traffic_out].max = 1.0000000000e+07

阅读全文…

分类: linux 标签: ,

MAC上如何使用sed替换命令

2013年1月26日 评论已被关闭 2,106 views

mac上的sed命令貌似做了些许修改,-i参数不一样啦。。

MacBook-Pro:~ 2hei.net$ cat test.txt
abcd
MacBook-Pro:~ 2hei.net$ sed -i ‘s/abcd/1234/g’ test.txt
sed: 1: “test.txt”: undefined label ‘est.txt’

阅读全文…

分类: others 标签: ,