Description
1 | Given a binary tree, find its maximum depth. |
1 | Given a binary tree, find its maximum depth. |
Sometimes we need get the form data as a json to put it into another ajax request with other data.
This is a method to get the data of form as json:
1 | function getFormJson(name) { |
Pros | Cons |
---|---|
Gives you physical control over your backup. | Requires a capital investment in hardware and infrastructure. |
Keeps critical data in-house. No third party has access to your information. | Needs space in your office for a rack or server room/closet, in addition to dedicated IT support. |
No need to rely on an Internet connection for access to data. | May be more susceptible to data loss during disaster situations due to its in-house location. How often you take the data offsite will reflect how much data you’ll lose in an emergency. |
Can be more cost-effective for small to mid-sized companies. | No uptime or recovery time guarantees. |
Pros | Cons |
---|---|
No need for onsite hardware or capital expenses. Well-suited to smaller companies that may outgrow storage too quickly. | The costs of the data recovery could outweigh the benefits for companies that are not as dependent on uptime and instant recovery. |
Storage can be added as needed. Solutions are often on-demand, so you only pay for what you need. | Every organization will have a limit to data that can be stored in the cloud due to storage availability and cost. |
Backup and restore can be initiated from anywhere, using any computer, tablet, or smartphone. | If the Internet goes down on your side or on your cloud provider’s side, you won’t have access to any of your information. |
Data can be backed up in the cloud as regularly as 15-minute intervals, minimizing data losses in disaster situations. Small data set recovery time is improved. | Full data recovery could prove very time-consuming and impactful on systems. |
Tech’s future may lie in the “fog” rather than the cloud. In other words, cloud solutions are great, but businesses may not want to have everything “out there” in the cloud. Some solutions will still need to be kept in-house or on the device, closer to the ground. For many companies, the best configuration will be somewhere in between, which the article refers to as “the fog”.
We usually get the length of a string by length
method. But it is not the correct result of the string which composites of chinese charaters because the chinese charaters will take 2 space for each. On the other side, one more method bytesize
of String
, will return the3
, the bytes length of the string.
1 | "abc123){*~".bytesize #=>10 |
So, I define a function to get the result I want:
1 | def kanjisize(string) |
and make it as a monkey patch of String
with the path of lib/core_extensions/string/kanji_size.rb
:
1 | module CoreExtensions |
1 | "abc123){*~".bytesize #=>10 |
One day, the upload feature of our server was failed because there were not enough memory on server.
So I logged into server and excute the free
command:
1 | $ free -g |
However, the result of the top
command showed that the free memory was 0 without any process which costed so much memory:
1 | $ ps aux | awk '{mem += $6} END {print mem/1024/1024}' |
After a long time research on Google, I found that there was another kind of cache, Slab, whichfree
command count as used memory.
1 | $ cat /etc/*-release |
1 | $ yum install java-1.8.0-openjdk |
1 | $ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo |
1 | $ chkconfig jenkins on |
原文地址: http://blog.csdn.net/guolin_blog/article/details/8986299
今天你的leader兴致冲冲地找到你,希望你可以帮他一个小忙,他现在急着要去开会。要帮什么忙呢?你很好奇。
他对你说,当前你们项目的数据库中有一张用户信息表,里面存放了很用户的数据,现在需要完成一个选择性查询用户信息的功能。他说会传递给你一个包含许多用户名的数组,你需要根据这些用户名把他们相应的数据都给查出来。
这个功能很简单的嘛,你爽快地答应了。由于你们项目使用的是MySQL数据库,你很快地写出了如下代码:
原文地址: http://blog.csdn.net/guolin_blog/article/details/9153761
听说你们公司最近新推出了一款电子书阅读应用,市场反应很不错,应用里还有图书商城,用户可以在其中随意选购自己喜欢的书籍。你们公司也是对此项目高度重视,加大了投入力度,决定给此应用再增加点功能。
好吧,你也知道你是逃不过此劫了,没过多久你的leader就找到了你。他告诉你目前的应用对每本书的浏览量和销售量做了统计,但现在想增加对每个书籍分类的浏览量和销售量以及所有书籍总的浏览量和销售量做统计的功能,希望你可以来完成这项功能。
领导安排的工作当然是推脱不掉的,你只能硬着头皮上了,不过好在这个功能看起来也不怎么复杂。
你比较喜欢看小说,那么就从小说类的统计功能开始做起吧。首先通过get_all_novels方法可以获取到所有的小说名,然后将小说名传入get_browse_count方法可以得到该书的浏览量,将小说名传入get_sale_count方法可以得到该书的销售量。你目前只有这几个已知的API可以使用,那么开始动手吧!