Skip to content

Instantly share code, notes, and snippets.

View hilyjiang's full-sized avatar

Hily Jiang hilyjiang

  • Fuzhou, Fujian, CN
View GitHub Profile
@hilyjiang
hilyjiang / sshd.go
Created September 29, 2016 09:00 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@hilyjiang
hilyjiang / gmail_remove_image_proxy.user.js
Last active August 29, 2015 14:25 — forked from oradwell/gmail_remove_image_proxy.user.js
Gmail Image Proxy Disable - Greasemonkey script
// ==UserScript==
// @name Gmail remove gstatic
// @namespace ockcyp/gmail-remove-gstatic
// @version 0.1
// @description Remove gstatic from external image URLs (useful when URLs contain internal domains)
// @author ockcyp
// @grant none
// ==/UserScript==
setTimeout(function() {
// Page is loaded and the div is not already created
<?php
/**
* CIDR.php
*
* Utility Functions for IPv4 ip addresses.
* Supports PHP 5.3+ (32 & 64 bit)
* @author Jonavon Wilcox <jowilcox@vt.edu>
* @revision Carlos Guimarães <cvsguimaraes@gmail.com>
* @version Wed Mar 12 13:00:00 EDT 2014
*/
@hilyjiang
hilyjiang / convert_size_val
Created June 5, 2013 09:10
显示Human Recognize的存储大小
<?php
function convert_size_val($size){
$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i];
}
@hilyjiang
hilyjiang / xml_highlight_helper.php
Created May 7, 2013 07:06
高亮XML代码的函数,CodeIgniter Helper
<?php
// 高亮XML代码
if ( ! function_exists('xml_highlight'))
{
function xml_highlight($s)
{
$s = htmlspecialchars($s);
$s = preg_replace("#&lt;([/]*?)(.*)([\s]*?)&gt;#sU", "<span style=\"color:#0000FF\">&lt;\\1\\2\\3&gt;</span>",$s);
$s = preg_replace("#&lt;([\?])(.*)([\?])&gt;#sU", "<span style=\"color:#800000\">&lt;\\1\\2\\3&gt;</span>",$s);
@hilyjiang
hilyjiang / verify_email_helper.php
Created May 7, 2013 07:03
验证EMAIL是否合法的函数,CodeIgniter Helper
<?php
// 验证邮箱地址是否合法
if ( ! function_exists('verify_email'))
{
function verify_email($email)
{
$regex = "/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z0-9])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i";
return preg_match($regex, $email) === 1;
}