方法1:
tzselect
方法2:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
安装ntp
yum install ntp
更新时间。连网更新时间,如果成功,将系统时间,写入BOIS
ntpdate time.windows.com && hwclock -w
启用ntpd
chkconfig ntpd on
/etc/init.d/ntpd start
方法1:
tzselect
方法2:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
安装ntp
yum install ntp
更新时间。连网更新时间,如果成功,将系统时间,写入BOIS
ntpdate time.windows.com && hwclock -w
启用ntpd
chkconfig ntpd on
/etc/init.d/ntpd start
lsblk
yum install -y xfsprogs
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
sed -i 's/$releasever/6/g' /etc/yum.repos.d/glusterfs-epel.repo
mkfs.xfs -i size=512 /dev/xvdf
mkdir -p /export/xvdf
echo "/dev/xvdf /export/xvdf xfs defaults,nofail,noatime 1 2" >> /etc/fstab
mount -a
#install glusterfs
yum install -y glusterfs{-fuse,-server}
#start glusterfs
service glusterd start
#turn on auto-start
chkconfig glusterd on
mkdir /export/xvdf/brick1
gluster volume create pcvol 172.31.42.77:/export/xvdf/brick1
gluster volume start pcvol
gluster volume info
gluster volume status
#install glusterfs repo
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
#fix it for amazon linux
sed -i 's/$releasever/6/g' /etc/yum.repos.d/glusterfs-epel.repo
#install glusterfs
yum install -y glusterfs-fuse
#setup fstab
echo "172.31.42.77:/pcvol /data_pcvol glusterfs defaults,noatime 0 0" >> /etc/fstab
#mount
mkdir /data_pcvol
mount -a
ls /data_pcvol
原文链接:http://yanue.net/post-140.html
sudo yum remove ibus
gsettings set org.gnome.settings-daemon.plugins.keyboard active false
yum install fcitx fcitx-devel fcitx-configtool fcitx-cloudpinyin fcitx-pinyin
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
上面步骤完成之后其实就可以使用Fcitx输入法
不过看到搜狗输入法都已经出deb包了
所以就想着安装个搜狗输入法到Fcitx上去。
从下面的连接地址下载对应的deb包、32位系统用i386.deb、64位系统用amd64.deb
http://mirrors.ustc.edu.cn/deepin/pool/non-free/f/fcitx-sogoupinyin-release/
随便在从如下地址下载一个搜狗输入法的皮肤
http://mirrors.ustc.edu.cn/deepin/pool/main/f/fcitx-skins/
接着我们把解压出来的.so文件移动到Fcitx的指定目录即可(64位为例)
cp /usr/lib/x86_64-linux-gnu/fcitx/fcitx-sogoupinyin.so /usr/lib64/fcitx/
最后加上执行权限
chmod +x /usr/lib64/fcitx/fcitx-sogoupinyin.so
原文链接:http://fewspider.github.io/linux/Sublime-Text-Chinese-input-under-Linux.html
复制以下内容到sublime-imfix.c
/*
sublime-imfix.c
Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
By Cjacker Huang
gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
LD_PRELOAD=./libsublime-imfix.so subl
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
typedef GdkSegment GdkRegionBox;
struct _GdkRegion
{
long size;
long numRects;
GdkRegionBox *rects;
GdkRegionBox extents;
};
GtkIMContext *local_context;
void
gdk_region_get_clipbox (const GdkRegion *region,
GdkRectangle *rectangle)
{
g_return_if_fail (region != NULL);
g_return_if_fail (rectangle != NULL);
rectangle->x = region->extents.x1;
rectangle->y = region->extents.y1;
rectangle->width = region->extents.x2 - region->extents.x1;
rectangle->height = region->extents.y2 - region->extents.y1;
GdkRectangle rect;
rect.x = rectangle->x;
rect.y = rectangle->y;
rect.width = 0;
rect.height = rectangle->height;
//The caret width is 2;
//Maybe sometimes we will make a mistake, but for most of the time, it should be the caret.
if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) {
gtk_im_context_set_cursor_location(local_context, rectangle);
}
}
//this is needed, for example, if you input something in file dialog and return back the edit area
//context will lost, so here we set it again.
static GdkFilterReturn event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer im_context)
{
XEvent *xev = (XEvent *)xevent;
if(xev->type == KeyRelease && GTK_IS_IM_CONTEXT(im_context)) {
GdkWindow * win = g_object_get_data(G_OBJECT(im_context),"window");
if(GDK_IS_WINDOW(win))
gtk_im_context_set_client_window(im_context, win);
}
return GDK_FILTER_CONTINUE;
}
void gtk_im_context_set_client_window (GtkIMContext *context,
GdkWindow *window)
{
GtkIMContextClass *klass;
g_return_if_fail (GTK_IS_IM_CONTEXT (context));
klass = GTK_IM_CONTEXT_GET_CLASS (context);
if (klass->set_client_window)
klass->set_client_window (context, window);
if(!GDK_IS_WINDOW (window))
return;
g_object_set_data(G_OBJECT(context),"window",window);
int width = gdk_window_get_width(window);
int height = gdk_window_get_height(window);
if(width != 0 && height !=0) {
gtk_im_context_focus_in(context);
local_context = context;
}
gdk_window_add_filter (window, event_filter, context);
}
执行以下命令生成SO文件:
gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
编译时如果提示 gtk/gtk.h: No such file or directory,需要先安装编译工具
yum install gtk2-devel
LD_PRELOAD=./libsublime-imfix.so subl
复制subl目录下的sublime_text.desktop到/usr/share/applications/sublime_text.desktop并修改exec与icon
Icon=/opt/sublime_text_3/Icon/256x256/sublime-text.png
Exec=bash -c 'LD_PRELOAD=/opt/sublime_text_3/libsublime-imfix.so /opt/sublime_text_3/sublime_text' %F
现在,使用sublime可以支持fcitx输入法输入中文了,要将ibus替换成fcitx请参考我的另外一篇文章Fedora 20安装Fcitx输入法并安装搜狗资源包
upyun的pysdk存在bug,会导致部分文件上传失败。测试图片
部分图像处理软件会去掉图片的description,而python的fileno如果没有取到description会抛出一个异常,程序没有处理这个异常,从而导致了无法上传。 pysdk有判断这个方法是否存在,但是没有处理这个异常。 https://docs.python.org/3/library/io.html#io.IOBase.fileno
打开sdk的upyun.py中的173行处,修改
if hasattr(value, 'fileno'):
length = os.fstat(value.fileno()).st_size
elif hasattr(value, '__len__'):
length = len(value)
headers['Content-Length'] = length
elif value is not None:
raise UpYunClientException('object type error')
为
if hasattr(value, 'getvalue'):
length = len(value.getvalue())
headers['Content-Length'] = length
elif hasattr(value, '__len__'):
length = len(value)
headers['Content-Length'] = length
elif hasattr(value, 'fileno'):
length = os.fstat(value.fileno()).st_size
headers['Content-Length'] = length
elif value is not None:
raise UpYunClientException('object type error')
为了放心的重构,重构时不会压力太大!
实现了PHP的stripslaches一样的功能
stringwithslashes.decode('string_escape')
大部分时候是因为浏览器编码错误:
vim `which google-chrome`
在EXPORT下面加入:
LANG="zh_CN.UTF-8"
介绍你最熟悉的一个py框架,以及他的主要功能及类库说明,开发流程,以及项目结构?
请写一段py异常及日志处理的代码
请写一段py读写数据库的代码
用文字或者代码介绍下py中的列表生成式、装饰器、匿名函数以及函数式编程
设计一个新闻数据库,有100万记录,分为50个分类,分类列表页面需要显示该分类的最新20条新闻,请设计出新闻表结构以及索引,请写出建表以及查询SQL;