Skip to content

Instantly share code, notes, and snippets.

@RobertWang
RobertWang / gist:4017566
Created November 5, 2012 14:56
php : fun : int2bin
function int2bin ( $int=0 ){
if ( $int>0 ) {
return int2bin ( floor($int/2) ) . $int % 2;
}
}
@RobertWang
RobertWang / llcolor.sh
Created November 28, 2012 15:10
bash : utils : colortable
#!/bin/bash
#llcolor
T='RGB'
fgs_a=(' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' ' 36m' '1;36m' ' 37m' '1;37m')
echo
echo -e "01234567012345670123456701234567012345670123456701234567012345670123456701234567"
echo -e "--------------------------------------------------------------------------------"
echo "fg \ bg | no-bg | 40m | 41m | 42m | 43m | 44m | 45m | 46m | 47m |"
echo -e "--------+-------+-------+-------+-------+-------+-------+-------+-------+-------"
@RobertWang
RobertWang / fav_osc.js
Created December 25, 2012 08:49
使用chrome浏览oschina.net页面时,收藏页面的快捷方法。把下面的代码添加到收藏夹去,看到某篇文章想收藏下来,就利用chrome的打印功能,将页面打印成pdf文档。
javascript:(function(){ var rm=['#OSC_Banner','#OSC_NavigatorMenu','#toolbar_wrapper','.ProjectOfNews','.NewsPrevAndNext','.RelatedNews','.HomeHotNews','.Comments','.CommentForm','.right', '#OSC_Banner2','#OSC_Topbar','.QuestionRelations','.SameQuestions','.ask_toolbar','.QuestionReplies','.AnswerForm']; $(rm).each(function(i, n){ $(n).remove(); }); var preTitle = ((new Date()).toISOString()).split('T')[0]; $('#OSC_Footer').css('padding-bottom','0px'); $('head title').text(preTitle+'_'+$('head title').text()); window.print(); })();
@RobertWang
RobertWang / demo_emu_hosts_curl_request.php
Last active August 24, 2019 13:05
[php]伪造host进行curl请求
<?php
/**
* 测试用例
* 用于处理需要绑定hosts的主机服务,比如某些接口调用等
*/
$apiurl = 'http://{$ServerRealIP}/weibo/send/mutil/'; // 修改原有的servername方式的url,使用真实服务器ip
$header = array('Host: {$ServerName}'); // 设置header中的伪造hosts主机地址
$data = array(
'param1' => 'value1',
'param2' => 'value2',
@RobertWang
RobertWang / function_curl_getpost.php
Created March 21, 2014 07:19
[php]CURL GET/POST
<?php
/**
* 提交GET请求,curl方法
* @param string $url 请求url地址
* @param mixed $data GET数据,数组或类似id=1&k1=v1
* @param array $header 头信息
* @param int $timeout 超时时间
* @param int $port 端口号
* @return array 请求结果,
@RobertWang
RobertWang / .bash_profile
Created March 27, 2014 07:54
.bash_profile
#############################################################################
# current prompt
#############################################################################
# \d – Current date
# \t – Current time
# \h – Host name
# \# – Command number
# \u – User name
# \W – Current working directory (ie: Desktop/)
# \w – Current working directory, full path (ie: /Users/Admin/Desktop)
@RobertWang
RobertWang / 查看Linux系统信息.markdown
Last active August 29, 2015 13:59
查看Linux系统信息

1. 查看内核版本

uname -r
cat /proc/version
uname -a

2. 查看发行版本号

<?php
/**
* dos2unix
* @author Robert <[email protected]>
*/
// 待处理的目录
$work_dir = getcwd();
$opts = array(
@RobertWang
RobertWang / sys_userAgent.js
Created May 9, 2014 02:53
[js]判断浏览器
function sys_userAgent(){
var userAgent = navigator.userAgent,
rMsie = /(msie\s|trident.*rv:)([\w.]+)/,
rFirefox = /(firefox)\/([\w.]+)/,
rOpera = /(opera).+version\/([\w.]+)/,
rChrome = /(chrome)\/([\w.]+)/,
rSafari = /version\/([\w.]+).*(safari)/;
var browser,version,ua;
ua = userAgent.toLowerCase();
@RobertWang
RobertWang / clone_mysql_table.sql
Created May 9, 2014 02:57
[mysql]在MySQL数据库中拷贝数据表
-- 在 MySQL 中拷贝表,将 old_table 表拷贝为 new_table 表。
-- 1. 不拷贝表数据,只拷贝结构。
CREATE TABLE new_table LIKE old_table
-- 2. 通过 SELECT 查询来拷贝,new_table 表会丢失主键、索引等信息。
CREATE TABLE new_table AS