`
jiaoronggui
  • 浏览: 1303721 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
博客专栏
B7c2eb31-a8ea-3973-a517-d00141f39b89
项目管理软件-redmin...
浏览量:115266
4a63e153-250f-30f6-a051-97cfc67cb3d3
IT职业规划
浏览量:197719
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
android代码将图片灰色处理 android,colormatrix
public static void setSepiaColorFilter(Drawable drawable) {
  if (drawable == null)
    return;

  final ColorMatrix matrixA = new ColorMatrix();
  // making image B&W
  matrixA.setSaturation(0);

  final ColorMatrix matrixB = new ColorMatrix();
  // applying scales for RGB color values
  matrixB.setScale(1f, .95f, .82f, 1.0f);
  matrixA.setConcat(matrixB, matrixA);

  final ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrixA);
  drawable.setColorFilter(filter);
}
android点仿网易,点两次返回键退出应用 android
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
	    if(keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN){   
	        if((System.currentTimeMillis()-exitTime) > 2000){  
	            Toast.makeText(getApplicationContext(), R.string.exit_title, Toast.LENGTH_SHORT).show();                                
	            exitTime = System.currentTimeMillis();   
	        } else {
	            finish();
	            System.exit(0);
	        }
	        return true;   
	    }
	    return super.onKeyDown(keyCode, event);
	}
ScrollView到制定位置 android scrollview
mScrollView.post(new Runnable() { 
        public void run() { 
             mScrollView.scrollTo(0, mScrollView.getBottom());
        } 
});
memcached参数中文解释 memcached
最近在研究memcached的优化,顺便把man memcached文档翻译了,只翻译参数部分,其他部分没啥使用价值,也拿来分享下吧,希望能对谁有点用。

在线地址:https://github.com/liuxd/MyTranslation/blob/master/translation/memcached-1.4.man

全文内容:
01	memcached 1.4.2
02	-p <num>      监听的TCP端口(默认: 11211)
03	-U <num>      监听的UDP端口(默认: 11211, 0表示不监听)
04	-s <file>     用于监听的UNIX套接字路径(禁用网络支持)
05	-a <mask>     UNIX套接字访问掩码,八进制数字(默认:0700)
06	-l <ip_addr>  监听的IP地址。(默认:INADDR_ANY,所有地址)
07	-d            作为守护进程来运行。
08	-r            最大核心文件限制。
09	-u <username> 设定进程所属用户。(只有root用户可以使用这个参数)
10	-m <num>      单个数据项的最大可用内存,以MB为单位。(默认:64MB)
11	-M            内存用光时报错。(不会删除数据)
12	-c <num>      最大并发连接数。(默认:1024)
13	-k            锁定所有内存页。注意你可以锁定的内存上限。
14	              试图分配更多内存会失败的,所以留意启动守护进程时所用的用户可分配的内存上限。
15	              (不是前面的 -u <username> 参数;在sh下,使用命令"ulimit -S -l NUM_KB"来设置。)
16	-v            提示信息(在事件循环中打印错误/警告信息。)
17	-vv           详细信息(还打印客户端命令/响应)
18	-vvv          超详细信息(还打印内部状态的变化)
19	-h            打印这个帮助信息并退出。
20	-i            打印memcached和libevent的许可。
21	-P <file>     保存进程ID到指定文件,只有在使用 -d 选项的时候才有意义。
22	-f <factor>   块大小增长因子。(默认:1.25)
23	-n <bytes>    分配给key+value+flags的最小空间(默认:48)
24	-L            尝试使用大内存页(如果可用的话)。提高内存页尺寸可以减少"页表缓冲(TLB)"丢失次数,提高运行效率。
25	              为了从操作系统获得大内存页,memcached会把全部数据项分配到一个大区块。
26	-D <char>     使用 <char> 作为前缀和ID的分隔符。
27	              这个用于按前缀获得状态报告。默认是":"(冒号)。
28	              如果指定了这个参数,则状态收集会自动开启;如果没指定,则需要用命令"stats detail on"来开启。
29	-t <num>      使用的线程数(默认:4)
30	-R            每个连接可处理的最大请求数。
31	-C            禁用CAS。
32	-b            设置后台日志队列的长度(默认:1024)
33	-B            绑定协议 - 可能值:ascii,binary,auto(默认)
34	-I            重写每个数据页尺寸。调整数据项最大尺寸。
php-mobile-detect使用 php
php-mobile-detect 是一个 PHP 类,用来通过 User-Agent 检测各种手机设备。

示例代码:
01	include("Mobile_Detect.php");
02	$detect = new Mobile_Detect();
03	if($detect->iOS()){
04	    // code to run for the Apple iOS platform.
05	}
06	if($detect->isAndroidOS()){
07	    // code to run for the Google Android platform.
08	}
09	if ($detect->isMobile()) {
10	    // any mobile platform
11	}
12	if($detect->isTablet()){
13	    // any tablet
14	}
Watir的基本语法(Watir Syntax)

1.使用Watir工具,需要在脚本中加上
require 'watir'
2.创建一个IE的测试实例
ie = Watir::IE.new
或者在创建的同时直接转到页面
ie = Watir::IE.start("http://mytestsite")
Watir使用start方法同时创建一个浏览器实例并转到一个页面。
3.页面导航
ie.goto("http://mytestsite")
4.操纵Web页面对象
4.1超链接
4.1.1使用Text属性点击超链接
ie.link(:text , "Pickaxe").click
对应的HTML代码为:
<a href="http://pragmaticprogrammer.com/titles/ruby/">Pickaxe</a>
4.1.2使用URL属性点击超链接
ie.link(:url , "http://pragmaticprogrammer.com/titles/ruby/").click
对应的HTML代码为:
<a href="http://pragmaticprogrammer.com/titles/ruby/">Test Site</a>
4.2复选框
4.2.1使用name属性设置复选框
ie.checkbox(:name, "checkme").set
4.2.2使用name属性清除复选框
ie.checkbox(:name, "checkme").clear
4.2.3使用name和value属性设置复选框
ie.checkbox(:name, "checkme", "1").set
4.2.4使用name和value属性清除复选框
ie.checkbox(:name, "checkme", "1").clear
对应的HTML代码为:
<input type = "checkbox" name = "checkme" value = "1">
4.3单选框
4.3.1使用name属性设置单选框
ie.radio(:name, "clickme").set
4.3.2使用name属性清除单选框
ie.radio(:name, "clickme").clear
4.3.3使用name和id属性设置单选框
ie.radio(:name, "clickme", "1").set
4.3.4使用name和id属性清除单选框
ie.radio(:name, "clickme", "1").clear
对应的HTML代码为:
<input type = "radio" name = "clickme" id = "1">
4.4下拉框
4.4.1使用name属性和值来设置下拉框
ie.select_list( :name , "selectme").select("is fun")
4.4.2使用name属性和值来清除下拉框
ie.select_list( :name , "selectme").clearSelection
对应的HTML代码为:
<select name = "selectme" > <option name=1> <option name=2>Web Testing <option name=3>in Ruby <option name=4>is fun </select>
4.5在Web页面中输入数据
4.5.1使用文本输入框的那么属性设置输入内容
ie.text_field(:name, "typeinme").set("Watir World")
4.5.2清空文本输入框
ie.text_field(:name, "typeinme").clear
对应的HTML代码为:
<input type = "text" name = "typeinme" >
4.6从Web页面上提交数据
4.6.1按钮
4.6.1.1通过值或标题属性点击按钮
ie.button(:value, "Click Me").click
4.6.1.2通过name属性点击按钮
ie.button(:name, "clickme").click
对应的HTML代码为:
<input type = "button" name = "clickme" value = "Click Me">

4.6.2表单
4.6.2.1表单中的按钮
使用value或标题属性
ie.button(:value, "Submit").click
对应的HTML代码为:
<form action = "submit" name = "submitform" method="post"><input type = "submit" value = "Submit"></input></form>
4.6.2.2表单中的图片按钮
使用那么属性
ie.button(:name, "doit").click
对应的HTML代码为:
<form action = "submit" name = "doitform" method="post"><input type="image" src = "images/doit.gif" name = "doit"></form>
4.6.2.3没有按钮的表单
Watir can submit a form by identifying it by its name, action and method attributes.
可以通过name、action以及method属性来提交表单
ie.form(:name, "loginform").submit
ie.form(:action, "login").submit
对应的HTML代码为:
<form action = "login" name = "loginform" method="get"><input name="username" type="text"></input></form>
4.6.3框架
ie.show_frames可以打印出当前页面框架的数量和名称
Watir允许通过名称属性来访问框架,如ie.frame("menu")
如果要访问menu框架中的一个超链接,可以ie.frame("menu").link(:text, "Click Menu Item").click
4.6.4嵌套框架
ie.frame("frame1").frame(:name, "nested_frame")
4.6.5新窗口
一些Web应用会弹出新窗口或打开一个新窗口,可以使用attach方法来访问并控制新窗口。通过标示新窗口的URL或者title来访问。
ie2 = Watir::IE.attach(:url, 'http://mytestsite')
ie3 = Watir::IE.attach(:title, 'Test New Window')
也可以使用正则表达式
ie4 = Watir::IE.attach(:title, /Test New/)
注意:不要把新窗口分配到你的ie变量,最好给新窗口一个不同的名字
5.验证结果
比较好的方法是在测试案例中假如验证点
5.1对象存在
使用Watir方法contains_text
ie.contains_text("Reached test verification point.")
if ie.contains_text("Reached test verification point.")
  puts: "Test passed. Page contains the text: Reached test verification point."
else
  puts: "Test failed! Page didn't contain text: Reached test verification point."
end
5.2使用test::unit Assertions
5.2.1需要test::unit
require 'test/unit'
5.2.2创建测试实例
class TC_myTest < Test::Unit::TestCase
  ...fill in Test Case methods here...
end
5.2.3创建测试用例方法
在测试类中,需要声明象下面的方法:
def test_myTestCase
  fill in method body with Watir code and assertion here
end
方法必须以test开头,ruby会随机运行测试案例,如果需要顺序执行,需要在test后加上字母或数字来强迫它顺序执行,比如“test_a_mytest”
定义测试方法的类:
class TC_myTest < Test::Unit::TestCase
  def test_ myTestCase
    Watir code and assertion here...
  end
  def test_anotherTestCase
    Watir code and assertion here...
  end
  def test_aTestCase
    Watir code and assertion here...
  end
end
5.2.4使用Assertions
Watir通过在一个asert覆写Watir方法支持assertions。
assert(ie.contains_text("Reached test verification point.")
5.2.5Setup and Teardown
def setup
  fill in code that will run before every test case here...
end
def teardown
  fill in code that will run after every test case here...
end
6.Tips and Tricks
Running Tests With the Browser Not Visible
Run the tests with a "-b" option if you don't want the browser to be visible. ex. myTest.rb -b
sqlite时间参数 http://www.cnblogs.com/zxtx/articles/2181963.html
计算机当前时间
SELECT date(‘now’)
计算机当前月份的最后一天
SELECT date(‘now’,’start of month’,’+1 month’,’-1 day’)
计算UNIX 时间戳1092941466表示的日期和时间
SELECT datetime(‘1092941466’,’unixepoch’)
计算 UNIX 时间戳1092941466 表示的本地日期和时间
SELECT datetime(‘1092941466’,’unixepoch’,’localtime’)
计算机当前UNIX 时间戳
SELECT strftime(‘%s’,’now’)
两个日期之间相差多少天
SELECT jolianday(‘now’)-jolianday(‘1981-12-23’)
两个日期时间之间相差多少秒
SELECT julianday('now')*86400 - julianday('2004-01-01 02:34:56')*86400
计算今年十月份第一个星期二的日期
SELECT date('now','start of year','+9 months','weekday 2');
得到年
strftime(‘%y’,'2008-4-28')
得到月
strftime(‘%m’,'2008-4-28')
同样,我们也可以通过strftime来得到其它所要的信息,但是要记得,给时间加引号

 例1.
select datetime('now');
结果:2006-10-17 12:55:54

例2.
select datetime('2006-10-17');
结果:2006-10-17 12:00:00

例3.
select datetime('2006-10-17 00:20:00','+1 hour','-12 minute');
结果:2006-10-17 01:08:00

例4.
select date('2006-10-17','+1 day','+1 year');
结果:2007-10-18

例5.
select datetime('now','start of year');
结果:2006-01-01 00:00:00

例6.
select datetime('now','start of month');
结果:2006-10-01 00:00:00

例7.
select datetime('now','start of day');
结果:2006-10-17 00:00:00

例8.
select datetime('now','+10 hour','start of day','+10 hour');
结果:2006-10-17 10:00:00

例9.
select datetime('now','localtime');
结果:2006-10-17 21:21:47

例10.
select datetime('now','+8 hour');
结果:2006-10-17 21:24:45
Java中将中文姓名转换为拼音的简单实现 http://www.blogjava.net/taody/archive/2012/04/25/376553.html
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;

public class SpellHelper {
    //将中文转换为英文
    public static String getEname(String name) {
        HanyuPinyinOutputFormat pyFormat = new HanyuPinyinOutputFormat();
        pyFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        pyFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        pyFormat.setVCharType(HanyuPinyinVCharType.WITH_V);

        return PinyinHelper.toHanyuPinyinString(name, pyFormat, "");
    }

    //姓、名的第一个字母需要为大写
    public static String getUpEname(String name) {
        char[] strs = name.toCharArray();
        String newname = null;
                
        //名字的长度
        if (strs.length == 2) {    
                newname = toUpCase(getEname("" + strs[0])) + " "
                    + toUpCase(getEname("" + strs[1]));
        } else if (strs.length == 3) {
               newname = toUpCase(getEname("" + strs[0])) + " "
                    + toUpCase(getEname("" + strs[1] + strs[2]));
        } else if (strs.length == 4) {
            newname = toUpCase(getEname("" + strs[0] + strs[1])) + " "
                    + toUpCase(getEname("" + strs[2] + strs[3]));
        } else {
            newname = toUpCase(getEname(name));
        }

        return newname;
    }

    //首字母大写
    private static String toUpCase(String str) {
        StringBuffer newstr = new StringBuffer();
        newstr.append((str.substring(0, 1)).toUpperCase()).append(
                str.substring(1, str.length()));

        return newstr.toString();
    }

    public static void main(String[] args) {
        System.out.println(getUpEname("李宇春"));

    }

}
mongrel_cluster启动bash redmine, mongrel, mongrel_cluster
    #!/bin/bash
    #
    # Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
    #
    # mongrel_cluster       Startup script for Mongrel clusters.
    #
    # chkconfig: - 85 15
    # description: mongrel_cluster manages multiple Mongrel processes for use \
    #              behind a load balancer.
    #              
     
    # source /usr/local/rvm/scripts/rvm
    # rvm use 1.8.7
    source /usr/local/rvm/environments/ruby-1.8.7-p302
     
    CONF_DIR=/etc/mongrel_cluster
    PID_DIR=/var/run/mongrel_cluster
    USER=mongrel
     
    RETVAL=0
     
    # Gracefully exit if the controller is missing.
    which mongrel_cluster_ctl >/dev/null || exit 0
     
    # Go no further if config directory is missing.
    [ -d "$CONF_DIR" ] || exit 0
     
    case "$1" in
        start)
          # Create pid directory
          mkdir -p $PID_DIR
          chown $USER:$USER $PID_DIR
     
          mongrel_cluster_ctl start -c $CONF_DIR
          RETVAL=$?
      ;;
        stop)
          mongrel_cluster_ctl stop -c $CONF_DIR
          RETVAL=$?
      ;;
        restart)
          mongrel_cluster_ctl restart -c $CONF_DIR
          RETVAL=$?
      ;;
        status)
          mongrel_cluster_ctl status -c $CONF_DIR
          RETVAL=$?
      ;;
        *)
          echo "Usage: mongrel_cluster {start|stop|restart|status}"
          exit 1
      ;;
    esac      
     
    exit $RETVAL
jitterbit
jitterbit
apache配置本地缓存的配置文件 apache
打开expire模块
LoadModule expires_module modules/mod_expires.so

在httpd.conf中增加
<IfModule mod_expires.c>    
ExpiresActive On
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/html A900
ExpiresByType text/xml A14400
ExpiresByType text/plain "access plus 1 hours"
ExpiresByType image/gif "access plus 1 day"
ExpiresByType image/jpg "access plus 1 day"
ExpiresByType image/jpeg "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
ExpiresByType image/bmp "access plus 1 day"
ExpiresByType
ruby获取指定字符串的文字编码 ruby
case NKF.guess(string)
when NKF::ASCII
  "ASCII"
when NKF::JIS
  "ISO-2022-JP"
when NKF::SJIS
  "Shift_JIS"
when NKF::EUC
  "EUC-JP"
when NKF::UTF8
  "UTF-8"
when NKF::UTF16
  "UTF-16"
when NKF::UNKNOWN
  "UNKNOWN"
when NKF::BINARY
  "BINARY"
end
Global site tag (gtag.js) - Google Analytics