跳至主要内容

博文

目前显示的是 三月, 2017的博文

docker tutorial

$sudo pacman -S docker $sudo systemctl enable docker && sudo systemctl start docker $docker pull daocloud.io/ubuntu:14.04 docker images //show all images docker commit 2e6f myubuntu //create img based on '2e6f' container docker   rmi   myubuntu  //remove image docker ps //show running containers docker ps -a //show all containers docker rm 2ef6 //remove container docker rm `docker ps -a` //remove all containers Start an interactive container $docker run -t -i daocloud.io/ubuntu:14.04 /bin/bash 暴露端口 docker run --name mynginx-container -d -p 8080:80 nginx-image 这样启动,您就可以通过 http://localhost:8080 或者  http://宿主 IP:8080 访问 Nginx 了。

python socket

======server=======: from socket import * sock=socket(AF_INET, SOCK_STREAM) sock.bind(( '' , 12345 )) sock.listen( 5 ) while True : c, addr=sock.accept() while True : try : data=c.recv( 1024 ) except : print (e) c.close() break if not data: break c.send( 'backinfo' .encode( 'utf8' )) c.close() sock.close() ====================== =========Client============= from socket import * c=socket(AF_INET, SOCK_STREAM) c.connect(( '127.0.0.1' , 12345 )) c.send( 'hello from client' .encode( 'utf8' )) data=c.recv( 1024 ) if not data: pass print (data.decode( 'utf8' )) c.close() ===================================

go url encoding

func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits. func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.

Android:如何设置底部控件view随着软键盘的弹出而上移

给EditText外加一个ScrollView,将高度设置统一,并给ScrollView设置属性 android:fillViewport="true"。 注: ScrollView只将EditView嵌套在其中即可,不可将其他组件放进来;不可随意在清单文件中给该activity设置软键盘属性。若弹出的软键盘遮挡了部分上移的view,可以在清单文件中给activity设置属性 android :windowSoftInputMode= "adjustResize" 一些不必要的属性不要随意添加,以免影响实现功能效果。 4.部分主要代码示例: [java]   view plain   copy   print ? <ScrollView               android:layout_width= "fill_parent"                          android:layout_height= "44dp"                android:fillViewport= "true"                android:scrollbars= "vertical" >           <EditText               android:id= "@+id/et_password"                android:layout_width= "match_parent"                android:layout_height= "44dp"                android:background= "@drawable/edt_bg"                android:drawableLeft= "@drawable/key"                android:drawablePadding= "0dp&

Android 四种特殊Interpolator源码解析 收藏

animation.setInterpolator(new BounceInterpolator()); 今天介绍4种动画插值器 OvershootInterpolator: "Overshoot" means 冲过头了,模拟了冲过了头回滚一点的效果 AnticipateInterpolator:“Anticipate” means 抢先,模拟了出发前先后退一步再前冲的动画效果 AnticipateOvershootInterpolator:以上两种的结合 BounceInterpolator:"Bounce" means 弹跳, 就是模拟了自由落地后回弹的效果 OvershootInterpolation 先来看Overshoot的实现的数学公式,mTension默认值为2.0f,有一个构造函数可以进行设置。 public float getInterpolation ( float t) { t -= 1.0f ; return t * t * ((mTension + 1 ) * t + mTension) + 1.0f ; } 如果带入默认值,简化下就是 y = 3 t^ 3 + 2 t^ 2 + 1 // t:[- 1 ~ 0 ] 然后去google搜索一下"3t^3+2t^2+1",就能看到下面这个曲线图 我们改下参数mTension,就能发现 mTension越大,冲过的距离越大,效果越明显! AnticipateInterpolation 再看下Anticipate的实现数学公式,mTension同样默认是2.0f: public float getInterpolation ( float t) { return t * t * ((mTension + 1 ) * t - mTension); } 于是带上实际参数2.0f,得到 y = 3 t^ 3 - 2 t^ 2 //t:[ 0 ~ 1.0 ] 同样的结论: mTension越大,抢先动画约长,效果越明显! BounceInterpolator 从源码我们能发现,实现方式是根据时间t,模拟了一次

android simpleAdapter

<? xml version= "1.0" encoding= "utf-8" ?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android :layout_width= "match_parent" android :layout_height= "match_parent" xmlns: app = "http://schemas.android.com/apk/res-auto" android :orientation= "horizontal" > <com.facebook.drawee.view.SimpleDraweeView android :layout_width= "50dp" app :placeholderImage= "@drawable/person" android :id= "@+id/main_list_avatar" android :layout_gravity= "center_vertical" android :layout_height= "50dp" /> <TextView android :layout_width= "match_parent" android :id= "@+id/main_list_title" android :layout_weight= "1" android :text= "Test" android :textColor= "#000" android :textStyle=

android sqlite

        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(MainActivity.this.getString(R.string.db_chat_history), null);         db.execSQL("create table if not exists unreaded(FromWho text,Msg text)");         Cursor cursor = db.rawQuery("select * from unreaded", null);         if(cursor.moveToFirst() && cursor.getCount() >= 1) {             do {                 sendMsg(cursor.getString(cursor.getColumnIndex("FromWho")),cursor.getString(cursor.getColumnIndex("Msg")));             } while (cursor.moveToNext());         }

archlinux mariadb installation

# pacman -S mariadb # mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql # systemctl enable mysqld.service # systemctl start mysqld.service # mysql_secure_installation 遗忘root密码的话,类似windows下: # systemctl stop mysqld.service # mysqld_safe --skip-grant-tables & # mysql -u root mysql mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; mysql> FLUSH PRIVILEGES; mysql> exit

git branch merge

3.2 Git 分支 - 分支的新建与合并 分支的新建与合并 让我们来看一个简单的分支新建与分支合并的例子,实际工作中你可能会用到类似的工作流。 你将经历如下步骤: 开发某个网站。 为实现某个新的需求,创建一个分支。 在这个分支上开展工作。 正在此时,你突然接到一个电话说有个很严重的问题需要紧急修补。 你将按照如下方式来处理: 切换到你的线上分支(production branch)。 为这个紧急任务新建一个分支,并在其中修复它。 在测试通过之后,切换回线上分支,然后合并这个修补分支,最后将改动推送到线上分支。 切换回你最初工作的分支上,继续工作。 新建分支 首先,我们假设你正在你的项目上工作,并且已经有一些提交。 Figure 18. 一个简单提交历史 现在,你已经决定要解决你的公司使用的问题追踪系统中的 #53 问题。 想要新建一个分支并同时切换到那个分支上,你可以运行一个带有  -b  参数的  git checkout  命令: $ git checkout -b iss53 Switched to a new branch "iss53" 它是下面两条命令的简写: $ git branch iss53 $ git checkout iss53 Figure 19. 创建一个新分支指针 你继续在 #53 问题上工作,并且做了一些提交。 在此过程中, iss53  分支在不断的向前推进,因为你已经检出到该分支(也就是说,你的  HEAD  指针指向了  iss53  分支) $ vim index.html $ git commit -a -m 'added a new footer [issue 53]' Figure 20. iss53 分支随着工作的进展向前推进 现在你接到那个电话,有个紧急问题等待你来解决。 有了 Git 的帮助,你不必把这个紧急问题和  iss53  的修改混在一起,你也不需要花大力气来还原关于 53# 问题的修改,然后再添加关于这个紧急问题的修改,最后将这个修改提交到线上分支。 你所要做的仅仅是切换回  ma