Skip to content

Instantly share code, notes, and snippets.

@ThinkZ
ThinkZ / README.md
Created September 18, 2016 07:18 — forked from joyrexus/README.md
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing

@ThinkZ
ThinkZ / 0_reuse_code.js
Created September 18, 2016 07:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
Header("Content-type:image/png");
//定义header,声明图片文件,最好是png,无版权之扰;
//生成新的四位整数验证码
session_start();//开启session;
$authnum_session = ’’;
$str = ’ABCDE69FIJKLMNO78PVWXYZabcdeQRSTUfghijkmn3pqrstGHuvwxyz120’;
//定义用来显示在图片上的数字和字母;
$l = strlen($str); //得到字串的长度;
//循环随机抽取四位前面定义的字母和数字;
<?php
$conn= mysql_connect("localhost","root","") or die("connect failed");
mysql_select_db("thinkz");
$result= mysql_query("select * from TEST") or die(mysql_error());
while ($myrow = mysql_fetch_row($result)) {
printf("%s __ %s __ %s __ %s <p>", $myrow[0], $myrow[1], $myrow[2], $myrow[3]);
This page updated : 2016-12-10 21:40
Google Chrome Portable
reference:
Download Google Chrome Portable
http://portableapps.com/apps/internet/google_chrome_portable
Google Chrome (for Windows)
@ThinkZ
ThinkZ / pip
Last active March 27, 2017 03:41
Python 2 & 3 @ ubuntu
python 2.7.12
python 3.5.2
# 安装 Python 发布版本,dev包必须安装,很多用pip安装包都需要编译
sudo apt-get install python2.7 python2.7-dev python3.5 python3.5-dev
# 很多pip安装的包都需要libssl和libevent编译环境
sudo apt-get install build-essential libssl-dev libevent-dev libjpeg-dev libxml2-dev libxslt-dev
# install mysql & nginx
sudo apt-get install mysql-server nginx-extras
经常有人讨论ADSL下载速度的问题,有的说2M应该是2048/8=256K/秒,很早就想深究这个问题了,以下根据协议的具体工作来分析2048K的ADSL下载速度到底应该是多少?
MTU1480#(目前大多城域网采用IP上行,不再用ATM,VLAN信息占12,因此不是1492)
同步速率2048000
DMT frame长度(byte)64#参考用,不必用来计算
字节/秒256000#以上统计物理层的速率,单位是Bit,为了方便计算,转换成Byte
ATM信元数量/秒4830.188679#53字节/信元,ADSL采用ATM方式来传送数据
有效信元字节/秒231849.0566#48字节/信元
最大接收以太网侦数/秒154.3602241#以太网侦长度1502,拨号方式都是以太网封装数据的
需如下操作:
在注册表HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe下面增加以下String:
FaceName = Bitstream Vera Sans Mono
之后你再运行cmd.exe,字体就变成bitstream mono了!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Date: 2015/7/03
# Created by 独自等待
# 博客 http://www.waitalone.cn/
import sys, os
from Crypto.Cipher import DES
def decode_char(c):
@ThinkZ
ThinkZ / cisco snmp
Last active March 27, 2017 03:54
about network snmp
路由器打开方法:
snmp-server community crm RO //crm为自定义的共同体名称,常用Public
snmp-server trap-source FastEthernet0/3/0 //监控的端口
snmp-server host x.x.x.x crm //在哪台终端(公网地址x.x.x.x)上应用共同体
snmp-server enable traps //启用snmp
交换机打开方法
Switch(config)#snmp-server community public ro #设置只读字符串,public为团体名称,ro为只读