Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
fhefh2015 / gist:b6e55f338032fc9266dc
Last active March 8, 2016 08:19 — forked from libo1106/gist:9777985
flex未知高度垂直居中写法
<!DOCTYPE html>
<html lang="zh-CN" class="fullscreen">
<head>
<title>flex未知高度垂直居中写法</title>
<style>
html,
body {
width: 100%;
@fhefh2015
fhefh2015 / new_gist_file.php
Created March 8, 2016 08:25
获取远程文件的大小
function remote_filesize($url, $user = "", $pw = "")
{
ob_start();
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
if(!empty($user) && !empty($pw))
{
$headers = array('Authorization: Basic ' . base64_encode("$user:$pw"));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
@fhefh2015
fhefh2015 / new_gist_file.php
Created March 8, 2016 08:24
限制文件下载的速度
<?php
// local file that should be send to the client
$local_file = 'test-file.zip';
// filename that the user gets as default
$download_file = 'your-download-name.zip';
// set the download rate limit (=> 20,5 kb/s)
$download_rate = 20.5;
if(file_exists($local_file) && is_file($local_file)) {
// send headers
@fhefh2015
fhefh2015 / new_gist_file.php
Created March 8, 2016 08:21
阻止多个ip访问网站
if ( !file_exists('blocked_ips.txt') ) {
$deny_ips = array(
'127.0.0.1',
'192.168.1.1',
'83.76.27.9',
'192.168.1.163'
);
} else {
$deny_ips = file('blocked_ips.txt');
}
@fhefh2015
fhefh2015 / gist:43564a47e84b7d44d36f
Last active March 8, 2016 09:14 — forked from tomohisa/gist:2897676
iOS 子控制器
// add child view
UIViewController* controller = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];
[self addChildViewController:controller];
controller.view.frame = CGRectMake(0, 44, 320, 320);
[self.view addSubview:controller.view];
[controller didMoveToParentViewController:self];
// remove child view
UIViewController *vc = [self.childViewControllers lastObject];
[vc.view removeFromSuperview];
@fhefh2015
fhefh2015 / prober.php
Created March 8, 2016 09:20 — forked from shenyubao/prober.php
常用PHP探针
<?php
error_reporting(0); //抑制所有错误信息
@header("content-Type: text/html; charset=utf-8"); //语言强制
ob_start();
$title = "Yahei-PHP Prober";
$version = "v0.3.5"; //版本号
define('HTTP_HOST', preg_replace('~^www\.~i', '', $_SERVER['HTTP_HOST']));
@fhefh2015
fhefh2015 / new_gist_file.php
Created March 9, 2016 01:59
JSON数据HTTP Header标记
第一种:
header('Content-type: application/json');
第二种:
header('Content-type: text/json');
//第一种是标准兼容以后,第二种兼容IE6
@fhefh2015
fhefh2015 / new_gist_file
Created March 9, 2016 03:52
iOS关闭/收起键盘方法总结
//点击Return按扭时收起键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
return [textField resignFirstResponder];
}
//点击背景View收起键盘(你的View必须是继承于UIControl)
[self.view endEditing:YES];
//你可以在任何地方加上这句话,可以用来统一收起键盘
@fhefh2015
fhefh2015 / new_gist_file.php
Created March 9, 2016 06:25
防XSS 防SQL注入的代码
/**
* 过滤参数
* @param string $str 接受的参数
* @return string
*/
static public function filterWords($str)
{
$farr = array(
"/<(\\/?)(script|i?frame|style|html|body|title|link|meta|object|\\?|\\%)([^>]*?)>/isU",
"/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU",
@fhefh2015
fhefh2015 / new_gist_file
Last active March 9, 2016 15:07
设置navigationBar和navigationItem -> rightBarButtonItem文字颜色
//设置navigationBar文字颜色
[self.navigationController.navigationBar setTitleTextAttributes:
@{NSForegroundColorAttributeName:[UIColor yellowColor]}];
//navigationItem -> rightBarButtonItem文字颜色
[self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor yellowColor]}
forState:UIControlStateNormal]