TCPing 工具介绍

TCPing 介绍

TCPing 和 Ping 工具非常类似,但与之不同的是,它通过 TCP 端口工作。TCPing 还支持监听具体某个端口的状态。

因此,即使服务器禁止 Ping,也可以通过 TCPing 来测试与服务器的连接。

TCPing 客户端下载

来自 kirchner 源代码的 TCPing

来自 Eli Fulkerson 源代码的 TCPing

来自 richard 源代码的 TCPing

Eli Fulkerson 写的 TCPing 工具更加强大,可以输出连接时间等信息。而 kirchner 的版本只能输出此端口是否打开。

Linux 用户如果需要更加强大的 TCPing 工具,可以使用此脚本:

安装方法:

  1. 安装 tcptraceroute:

Debian / Ubuntu 用户:

sudo apt-get install tcptraceroute

CentOS / REHL 用户,设置 RepoForge 先,再:

sudo yum install tcptraceroute
  1. 下载 tcpping 脚本:
cd /usr/bin
sudo wget http://www.vdberg.org/~richard/tcpping
sudo chmod 755 tcpping

TCPing 工具使用方法

  • Windows 用户可以将其放入 X:\Windows\System32 文件夹下(X 代表系统分区),然后就可以直接在 CMD 命令行中使用。
  • 类 Unix 系统请自行在 /bin 或其他目录下放置可执行文件或软链接。

具体用法可参见各客户端原网站。

 

 

from : http://tookdes.org/geek/archives/tcping-intro.html

如何测试连接MsSQL/SQL Server数据库 from 阿里云

如果您所使用的 SQL Server 数据库连不上,可以通过这个方法进行测试数据库连接。

温馨提示:

  • .本方法只适用于测试SqlServer数据库连接,请核对您输入的是SqlServer的数据库信息。本文档不适用于MySql数据库。
  • 如何查看数据库信息

测试连接方法:

1.打开记事本,不要写任何字,然后保存为 dsds.udl (即为重命名)到桌面。

2.双击刚刚保存的文件。

3.输入数据库的地址数据库账号密码数据库名称。

 

4.单击“测试连接”,提示连接成功。

 

 

How to upload to Google Cloud Storage buckets using CURL

Signed URLs are pretty nifty feature given by Google Cloud Platform to let anyone access your cloud storage (bucket or any file in the bucket) without need to sign in.

Official documentation gives step by step details as to how to read/write to the bucket using gsutil or through a program. This article will tell you how to upload a file to the bucket using curl so that any client which doesn’t have cloud SDK installed can do this using a simple script.
This command creates a signed PUT URL for your bucket.
 gsutil signurl -c 'text/plain' -m PUT serviceAccount.json gs://test_bucket_location  

Here is my URL:

 https://storage.googleapis.com/test_sl?GoogleAccessId=my-project-id@appspot.gserviceaccount.com&Expires=1490266627&Signature=UfKBNHWtjLKSBEcUQUKDeQtSQV6YCleE9hGG%2BCxVEjDOmkDxwkC%2BPtEg63pjDBHyKhVOnhspP1%2FAVSr%2B%2Fty8Ps7MSQ0lM2YHkbPeqjTiUcAfsbdcuXUMbe3p8FysRUFMe2dSikehBJWtbYtjb%2BNCw3L09c7fLFyAoJafIcnoIz7iJGP%2Br6gAUkSnZXgbVjr6wjN%2FIaudXIqAxyz4O6VU%2FIob8RHmfYBD3rYw8oRmZer0g%2BMTDw5Bu3%2BdjbxCriCOkOLWkvlpBGvd71hRP89lxpD%2FwX1N1pzAiRBpmKAhpKrYrq8h4kNLAtTHXYSz5j%2Bzb28UD4YMG52n8UpfyPgFIg%3D%3D  

Now this command will upload a text file to the bucket using the signed URL we created:

 $ curl -X PUT -H 'content-type: text/plain' -d @test_upload.txt https://storage.googleapis.com/test_sl?GoogleAccessId=my-project-id@appspot.gserviceaccount.com&Expires=1490266627&Signature=UfKBNHWtjLKSBEcUQUKDeQtSQV6YCleE9hGG%2BCxVEjDOmkDxwkC%2BPtEg63pjDBHyKhVOnhspP1%2FAVSr%2B%2Fty8Ps7MSQ0lM2YHkbPeqjTiUcAfsbdcuXUMbe3p8FysRUFMe2dSikehBJWtbYtjb%2BNCw3L09c7fLFyAoJafIcnoIz7iJGP%2Br6gAUkSnZXgbVjr6wjN%2FIaudXIqAxyz4O6VU%2FIob8RHmfYBD3rYw8oRmZer0g%2BMTDw5Bu3%2BdjbxCriCOkOLWkvlpBGvd71hRP89lxpD%2FwX1N1pzAiRBpmKAhpKrYrq8h4kNLAtTHXYSz5j%2Bzb28UD4YMG52n8UpfyPgFIg%3D%3D  

On similar lines, you can create a RESUMABLE URL and then upload file using following command:

 $ curl -v -X 'POST' -H 'content-type: text/plain' -H 'x-goog-resumable:start' '[signed url]' -d ''  

This command gives ‘session URI’ which is similar to signed url, but longer!

 $ curl -v -X PUT -d @test_upload.txt -H 'content-type: text/plain' '[session URI]'  

Simple isn’t it!

 

 

 

http://opreview.blogspot.jp/2017/03/how-to-upload-to-google-cloud-storage.html

iOS tab bar icon size。

You should prepare 3 images icons for each tab bar item (1x, 2x and 3x).

First create the 3x at 75w 75h pixels (maximum: 144 x 96) and save it as iconTab0@3x.png.

Then resize it to 50w 50h pixels (maximum: 96 x 64) and save it as iconTab0@2x.png.

Finally resize it to 25w 25h pixels (maximum: 48 x 32) and save it as iconTab0.png.

Now all you need is to select those 3 images at your finder and drag them to your image assets.

 

 

enter image description here

enter image description here

一行命令用Python建HTTP服务器

打开命令行,输入下面的代码:

python -mSimpleHTTPServer

就能在当前目录下运行一个HTTP服务器。
当前目录不知道是什么的话,看你的命令行的提示就行了。

访问很简单,打开下面的网址,就能看到你当前文件夹下的文件:

http://你的IP地址:8000/


如果你在当前文件夹下放了个index.html文件,那么打开下面的网址,就能看到这个index.html的内容了:

http://localhost:8000/

 

Swift Custom Table View Cell Example 自定义 UITableViewCell

 

Custom Table View Cell Example

The asker of the original question has solved their problem. I am adding this answer as a mini self contained example project for others who are trying to do the same thing.

The finished project should look like this:

enter image description here

 

Create a new project

It can be just a Single View Application.

Add the code

Add a new Swift file to your project. Name it MyCustomCell.swift. This class will hold the outlets for the views that you add to your cell in the storyboard.

import UIKit class MyCustomCell: UITableViewCell {     @IBOutlet weak var myView: UIView!     @IBOutlet weak var myCellLabel: UILabel! }

We will connect these outlets later.

Open ViewController.swift and make sure you have the following content:

import UIKit class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {      // These strings will be the data for the table view cells     let animals: [String] = ["Horse", "Cow", "Camel", "Sheep", "Goat"]      // These are the colors of the square views in our table view cells.     // In a real project you might use UIImages.     let colors = [UIColor.blueColor(), UIColor.yellowColor(), UIColor.magentaColor(), UIColor.redColor(), UIColor.brownColor()]      // Don't forget to enter this in IB also     let cellReuseIdentifier = "cell"      @IBOutlet var tableView: UITableView!      override func viewDidLoad() {         super.viewDidLoad()          tableView.delegate = self         tableView.dataSource = self     }      // number of rows in table view     func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {         return self.animals.count     }      // create a cell for each table view row     func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {          let cell:MyCustomCell = self.tableView.dequeueReusableCellWithIdentifier(cellReuseIdentifier) as! MyCustomCell          cell.myView.backgroundColor = self.colors[indexPath.row]         cell.myCellLabel.text = self.animals[indexPath.row]          return cell     }      // method to run when table view cell is tapped     func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {         print("You tapped cell number \(indexPath.row).")     } }

Setup the storyboard

Add a Table View to your view controller and use auto layout to pin it to the four sides of the View Controller. Then drag a Table View Cell onto the Table View. And then drag a View and a Label onto the Prototype cell. (You may need to pull the bottom of the prototype cell down so that it is a little bigger.) Use auto layout to fix the View and the Label how you want them arranged within the content view of the Table View Cell. For example, I made my View be 100×100.

enter image description here

Other IB settings

Custom class name and Identifier

Select the Table View Cell and set the custom class to be MyCustomCell (the name of the class in the Swift file we added). Also set the Identifier to be cell (the same string that we used for the cellReuseIdentifier in the code above.

enter image description here

Hook Up the Outlets

  • Control drag from the Table View in the storyboard to the tableView variable in the ViewController code.
  • Do the same for the View and the Label in your Prototype cell to the myView and myCellLabel variables in the MyCustomCell class.

Finished

That’s it. You should be able to run your project now.

Notes

  • The colored views that I used here could be replaced with anything. An obvious example would be a UIImageView.
  • If you are just trying to get a TableView to work, see this even more basic example.
  • If you need a Table View with variable cell heights, see this example.

How do I set adaptive multiline UILabel text? UILable 文本自动换行

 This is much better approach if you are looking for multiline dynamic text label which exactly takes the space based on its text.

No sizeToFit, preferredMaxLayoutWidth used

Below is how it will work.

enter image description here

 Lets set up the project. Take a Single View application and in Storyboard Add a UILabel and a UIButton. Define constraints to UILabel as below snapshot:

enter image description here

Set the Label properties as below image:

enter image description here

Add the constraints to the UIButton. Make sure that vertical spacing of 100 is between UILabel and UIButton

enter image description here

Now set the priority of the trailing constraint of UILabel as 749

enter image description here

Now set the Horizontal Content Hugging and Horizontal Content Compression properties of UILabel as 750 and 748

enter image description here

Below is my controller class. You have to connect UILabel property and Button action from storyboard to viewcontroller class.

import UIKit  class ViewController: UIViewController {  @IBOutlet weak var textLabel: UILabel! var count = 0 let items = ["jackson is not any more in this world", "Jonny jonny yes papa eating sugar no papa", "Ab", "What you do is what will happen to you despite of all measures taken to reverse the phenonmenon of the nature"]   @IBAction func updateLabelText(sender: UIButton) {     if count > 3 {         count = 0     }     textLabel.text = items[count]     count = count + 1 }  override func viewDidLoad() {     super.viewDidLoad()     // Do any additional setup after loading the view, typically from a nib.     //self.textLabel.sizeToFit()     //self.textLabel.preferredMaxLayoutWidth = 500 }  override func didReceiveMemoryWarning() {     super.didReceiveMemoryWarning()     // Dispose of any resources that can be recreated. }   }

Thats it. This will automatically resize the UILabel based on its content and also you can see the UIButton is also adjusted accordingly.

linux下查看最消耗CPU、内存的进程

 1.CPU占用最多的前10个进程: 

ps auxw|head -1;ps auxw|sort -rn -k3|head -10 

2.内存消耗最多的前10个进程 

ps auxw|head -1;ps auxw|sort -rn -k4|head -10 

3.虚拟内存使用最多的前10个进程 
ps auxw|head -1;ps auxw|sort -rn -k5|head -10

 

 

 

http://my.oschina.net/goberl/blog/85816

 

1. 在linux下,查看一个运行中的程序, 占用了多少内存, 一般的命令有

   (1). ps aux:

 

     其中  VSZ(或VSS)列 表示,程序占用了多少虚拟内存。

           RSS列 表示, 程序占用了多少物理内存。

           虚拟内存可以不用考虑,它并不占用实际物理内存。

   (2). top 命令也可以

     其中  VIRT(或VSS)列  表示,程序占用了多少虚拟内存。 同 ps aux 中的 VSZ列

           RES列 表示, 程序占用了多少物理内存。同 ps aux 中的RSS列

           

2.在linux下, 查看当前系统占用了多少内存, 一般的命令是  free

其中, free就是系统还有多少内存可以使用。

但由于 linux 系统对内存使用有一个原则, 就是, 内存是宝贵的, 能使用多少就使用多少。 所以, linux会把已经调用过的包缓存起来,放在内存里。

这样,实际上,可以使用的内存,就可以理解为, free+buffers+cached

 

3.当你了解完这些命令以后, 再去使用ps aux 命令去查看的时候, 会发现一个奇怪的现象。

 所有的  RSS 列的数据,加起来, 比物理内存的数要大很多。

 比如, 物理内存为2G, 而RSS列的数据加起来,可能有5个G之多, 这是怎么回事了?

 

 这是因为RSS列的值骗了我们。 

 

 linux的内存机制是这样的:

 在运行一个程序时, linux会调用该程序依赖的链接库, 如lib.xx.so。 首先看该链接库是否被映射进内存中,如果没有被映射,则将代码段与数据段映射到内存中,否则只是将其加入进程的地址空间。

 

 这样,当N个程序,依赖到lib.xx.so的时候, 实际上,内存中只有一个lib.xx.so ,而不是N个。 

 

 而RSS在显示一个程序占用的实际物理内存时, 将lib.xx.so也算了进来。

 

 比如, X程序, 本身占用内存为5M, lib.xx.so 占用内存2M,lib.xx.so被N个程序共享依赖。 则RSS显示为,X程序运行,占用内存为7M。 实际上, X程序占用了5M空间。 多余的2m被讨入到RSS中了。

 

 当你在用ps aux显示内存占用情况时, N个共享依赖lib.xx.so的N个程序,都把这2m空间,算在自己的RSS中了, 这样RSS的sum值,就比实际物理内存多了。

 

 当然, linux的内存使用机制很复杂, 不是一句两句能说清楚的。这里只是简单的说明了一下, ps aux中的RSS值, 并不能真实反映物理内存的使用情况。

 

4. 如果查看更详细的内存使用情况, 可用以下几种方法, 或者几种方法结合使用:

这几种方法,都需要root账户的权限

 

(1). pmap -d $pid 

$pid 是正在运行的程序的pid

 

http://blog.chinaunix.net/uid-28811939-id-4070166.html