存档

文章标签 ‘自动’

PC网页端智能跳转至手机版识别代码

2017年6月4日 没有评论

提取自百度的自动识别代码,实现PC网页端智能跳转至手机版识别代码功能。如下:

function uaredirect(f){try{if(document.getElementById(“bdmark”)!=null){return}var b=false;if(arguments[1]){var e=window.location.host;var a=window.location.href;if(isSubdomain(arguments[1],e)==1){f=f+”/#m/”+a;b=true}else{if(isSubdomain(arguments[1],e)==2){f=f+”/#m/”+a;b=true}else{f=a;b=false}}}else{b=true}if(b){var c=window.location.hash;if(!c.match(“fromapp”)){if((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))){location.replace(f)}}}}catch(d){}}function isSubdomain(c,d){this.getdomain=function(f){var e=f.indexOf(“://”);if(e>0){var h=f.substr(e+3)}else{var h=f}var g=/^www\./;if(g.test(h)){h=h.substr(4)}return h};if(c==d){return 1}else{var c=this.getdomain(c);var b=this.getdomain(d);if(c==b){return 1}else{c=c.replace(“.”,”\\.”);var a=new RegExp(“\\.”+c+”$”);if(b.match(a)){return 2}else{return 0}}}};
使用方法:uaredirect(“http://m.baidu.com/”);

如何打开网页自动弹出QQ聊天窗口

2015年12月16日 没有评论

现在很多网站只要一打开,首页就会自动弹出一个QQ聊天询问窗口,这种行为有点不友好,但是越来越多人采用,那么如果我们要实现这样的功能,如何增加代码呢?

只要在html里面增加如下代码即可:

<iframe style=”display:none;” src=”tencent://message/?uin=你的QQ号码&Site=&menu=yes”></iframe>

php实现扫描二维码根据手机系统自动跳转至ios或者android下载地址

2015年7月6日 没有评论

自己将此文件命名为download.php,生成的二维码网址为http://www.域名.com/download.php

即可实现扫描二维码根据手机系统自动跳转至ios或者android下载地址。

php代码如下:

<?php
header(“Content-type:text/html; charset=utf-8″);
if(stripos($_SERVER[‘HTTP_USER_AGENT’],’iphone’) || stripos($_SERVER[‘HTTP_USER_AGENT’],’ipad’) || stripos($_SERVER[‘HTTP_USER_AGENT’],’ipod’)){
//ios download url
header(‘Location: http://itunes.apple.com/cn/’);
}
else if(stripos($_SERVER[‘HTTP_USER_AGENT’],’android’)){
$downArray=array(
//豌豆荚
‘wandoujia.com’     =>”,
//安智市场
‘anzhi.com’         =>”,
//安卓市场
‘apk.hiapk.com’     =>”,
//百度手机助手
‘shouji.baidu.com’  =>”,
//360手机助手
‘sj.360.cn’         =>”,
//应用汇
‘appchina.com’      =>”,
//应用宝
‘android.myapp.com’ =>”
);
header(‘Location: ‘.$downArray[array_rand($downArray)]);
}
else{
header(‘Location: http://m.baidu.com/’);
}
?>

分类: android 标签: , , ,

ubuntu自动执行crontab释放内存(free-m)

2015年5月18日 没有评论

写了ubunt下的shell脚本,用来自动监听内存使用情况,当可用内存小于指定大小的时候,自动释放内存。

#!/bin/bash
ROOT_UID=0
E_NOTROOT=67
if [ “$UID” -ne “$ROOT_UID” ]
then
echo “Must be root to run this script”
exit $E_NOTROT
fi

free -m |grep -i mem |awk ‘{if($4 > 1000){ printf(“good”) > “free_m_temp.txt”}else {printf(“bad”) > “free_m_temp.txt”}}’

#read line one
line=`awk “{ if (NR == 1) print}” “free_m_temp.txt”`

if [ “$line” == “bad” ]
then
sh -c “sync; echo 3 > /proc/sys/vm/drop_caches”
#service apache2 restart
#service mysql restart
echo “done , free memory with drop caches”
else
echo “no need to free memory”
fi

 

方案2:

#!/bin/bash
ROOT_UID=0
E_NOTROOT=67
if [ “$UID” -ne “$ROOT_UID” ]
then
echo “Must be root to run this script”
exit $E_NOTROT
fi

timenow=$(date +%M)
free -m |grep -i mem |awk ‘{printf($4-0) > “/home/vanpeople/free_m/freesize.txt”}’
cp -r /home/vanpeople/free_m/freesize.txt /home/vanpeople/free_m/log_size/$timenow.txt

line=`awk “{ if (NR == 1) print}” “/home/vanpeople/free_m/freesize.txt”`

if [ $line -lt 3000 ]
then
sh -c “sync; echo 3 > /proc/sys/vm/drop_caches”
timenow_ymdhis=$(date +%Y-%m-%d.%H:%M:%S)
echo $timenow_ymdhis.$line > /home/vanpeople/free_m/log_drop/$timenow_ymdhis.txt
#service apache2 restart
#service mysql restart
echo “done , free memory with drop caches”
else
echo “no need to free memory”
fi

 

分类: ubuntu高手 标签: , , ,

EditPlus注册码在线生成,非常方便简单。

2015年5月12日 没有评论

<input type=”text” size=”50″ name=”username” id=”username” />

<input type=”submit” value=”生成” onclick=”generate_editplus_regcode();” name=”generate” id=”generate” />

<pre lang=”javascript” line=”0″>

function generate_editplus_regcode()
{
var list = [0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8000,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16000,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32000,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];
var hexchars = [‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’A’,’B’,’C’,’D’,’E’,’F’];
var regcode = new Array(29);
var i = 0, j = 0, k = 0;
var len, temp, sum, result;
var username = document.getElementById(“username”).value;
username = username.replace(/^\s+|\s+$/g, “”);

for(i = 0;i < 5;i++,k++)
{
for(j = 0;j < 5;j++,k++)
{
regcode[k] = hexchars[parseInt(Math.random() * 16)];
}
if(k == 29) break;
regcode[k] = ‘-‘;
}

len = username.length;

sum = 1;
for(i = 0;i < len;i++)
sum += username.charCodeAt(i);
temp = (parseInt( (sum + 23) / 6 ) + 3) * 7 % 16;
regcode[6] = hexchars[temp & 0xF];

sum = 1;
for(i = 0;i < len;i++)
sum += username.charCodeAt(i);
temp = parseInt( (3 * sum + 39) / 8 ) % 16;
regcode[9] = hexchars[temp & 0xF];

sum = 1;
for(i = 0;i < len;i++)
sum += username.charCodeAt(i);
temp = parseInt( (3 * sum + 19) / 9 ) % 16;
regcode[7] = hexchars[temp & 0xF];

sum = 1;
for(i = 0;i < len;i++)
sum += username.charCodeAt(i);
temp = parseInt( (sum + 10) / 3 ) * 8 % 16;
regcode[10] = hexchars[temp & 0xF];

sum = 1;
for(i = 0;i < len;i++)
sum += username.charCodeAt(i);
temp = (parseInt( (9 * sum + 10) / 3 ) + 36) % 16;
regcode[4] = hexchars[temp & 0xF];

sum = 1;
for(i = 0;i < len;i++)
sum += username.charCodeAt(i);
temp =  parseInt( (5 * sum + 11) / 5 ) % 16;
regcode[8] = hexchars[temp & 0xF];

result = 0;
for(i = 0;i < len;i++)
result = ((result >> 8) & 0xFF) ^ list[username.charCodeAt(i) ^ (result & 0xFF)];
result = result.toString(16).toUpperCase();
regcode[2] = result.charAt(0);
regcode[3] = result.charAt(1);

len = regcode.length;
result = 0;
for(i = 2;i < len;i++)
result = ((result >> 8) & 0xFF) ^ list[regcode[i].toString().charCodeAt(0) ^ (result & 0xFF)];
result = result.toString(16).toUpperCase();
regcode[0] = result.charAt(0);
regcode[1] = result.charAt(1);

document.getElementById(“regcode”).value = regcode.join(“”);
}

</pre>

css.php