[js]奇怪的Grunt问题

不知何时起我的构建CSS Sprite的grunt task突然不能运行了。CSS Sprite是利用grunt-spritesmith构建的。原本以为是配置文件的问题,于是反复删改Gruntfile.js中的sprite段配置,无果;又以为是引擎的问题,于是反复安装、删除各种图形处理模块,也无果。最后偶然读到grunt-spritesmith的源代码,发现它注册了一个名叫sprite的任务。突然想起我自己好像也注册了同名任务:

grunt.registerNpmTask('sprite', ['sprite']);

原来如此!我本想用我注册的sprite任务去调用grunt-spritesmithsprite任务,结果两个正好同名,导致死循环调用。。。解决方法,把这行删掉就可以了。

记录下来引以为戒。

(Read More)

[Oracle]How to Unlock Expired Account

If you ever get this error in your dev then you should consider unlock your oracle account and set it to never expire.

ORA-28001: the password has expired

Login with your system account and run the following SQLs.

-- find out your profile name
SELECT profile FROM DBA_USERS WHERE username='<username>';

-- check password limit
SELECT resource_time, limit FROM DBA_PROFILES WHERE profile='<profile_name>';

-- reset password and unlock account
ALTER USER <username> IDENTIFIED BY <new_password> ACCOUNT UNLOCK;

-- disable expiration
ALTER PROFILE <profile_name> LIMIT password_life_time UNLIMITED;

-- disable password policy
ALTER PROFILE <profile_name> LIMIT password_verify_function NULL;

Then your account should be ready to use.

(Read More)

[python]避免SqlAlchemy的TypeError: can't compare offset-naive and offset-aware datetimes错误

SqlAlchemyDateTime字段有个问题,就是如果数据库本身不支持timezone,并且app中的datetime对象为timezone aware的话,向数据库中存储数据时会报告如下错误:

TypeError: can't compare offset-naive and offset-aware datetimes

虽然DateTime提供了timezone选项,但这个选项仅在数据库支持时区时才有效。对于常用的MySQL甚至SQLite,这个选项无能为力。

解决方法就是自定义一个timezone aware的数据类型(来源):

(Read More)

Gollum: 轻量级基于Git的Wiki系统

最近准备搭建一个wiki,看了维基百科上的wiki软件列表后觉得可用的实在太少。我希望架设一个轻量级的wiki,至少能满足以下条件:

其实GitHub自带的wiki系统能很好满足我的需求。后来看到GitHub用的wiki叫做Gollum,简单试用了一下发现效果很不错,能满足绝大部分需求,并且还有额外赠送的基于git的存储。

其实Gollum本身的安装很简单,一个gem install就能搞定,不过想支持OAuth2认证以及服务器配置比较麻烦。所以下面着重从这两方面介绍。

(Read More)

[linux]在笔记本上安装CentOS 6.6

禁用ACPI,这样关闭盖子时系统就不会休眠(否则硬盘会休眠,造成访问错误)。方法是编辑/boot/grub/grub.conf,在kernel一行末尾添加acpi=off

启动时自动启用网卡。编辑/etc/sysconfig/network-scripts/ifcfg-eth0,将其中的ONBOOT=no改成ONBOOT=yes

禁用IPV6。编辑/etc/sysctl.conf,增加以下两行然后重新启动:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

(Read More)

修正Windows和OSX双启动时的时钟错误

如果在同一台电脑上安装了Windows和OSX两个系统,那么每次启动到OSX之后再返回Windows,系统时钟都会显示错误的时间,需要手工修正。其实这个问题很容易解决:打开注册表编辑器(regedit.exe),查找以下键:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation

然后在该主键下建立DWORD (32-bit)键值,名称为RealTimeIsUniversal,值为1

重新启动,可以看到Windows总是显示正确的时间了。

参考:Fix Incorrect Clock Settings in Windows When Dual-Booting with OS X or Linux

(Read More)

MacOSX下交换Cmd和Option键

如果你的Mac电脑外接了个PC键盘,那么其他的键都还好,Cmd键和Option键的布局是反的——PC键盘最下面一排从左至右分别是Ctrl, Win, Alt,这几个键在Mac下相当于Ctrl, Cmd, Option,而Mac电脑实际的键位是Ctrl, Option, Cmd。这时可以试试Karabiner。安装后进入设置,勾选以下四个选项:

  • Command_L to Option_L
  • Command_R to Option_R
  • Option_L to Command_L
  • Option-R to Command_R

这样你的PC键盘就和Mac键盘一样顺手了。

(Read More)

在CentOS中停用SELinux和iptables

如果需要用CentOS作为开发服务器,那么还是把SELinux和iptables停掉比较方便。

停止iptables:

#!/bin/sh
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

停止SELinux:编辑/etc/sysconfig/selinux,将其中的SELINUX=permissive改成SELINUX=disabled

(Read More)

在VirtualBox中使用物理硬盘

在VirtualBox中使用物理硬盘不是那么容易,因为UI中没有提供映射物理硬盘的功能,需要用一点命令行才行。(参考文档

首先打开计算机管理->磁盘管理,查看要加载的物理硬盘的编号。比如要加载的物理硬盘为Disk 0,那么编号就是0,下面命令中的\\.\PhysicalDrive0最后的数字应该写0。

接下来以管理员身份启动VirtualBox。接下来以管理员身份启动一个cmd,输入以下命令:

C:\> VBoxManage.exe internalcommands createrawvmdk -filename D:\disk.vmdk -rawdisk \\.\PhysicalDrive0

这样就生成了D:\disk.vmdk,将这个文件作为硬盘加载到虚拟机中就可以了。 注意在执行上述命令之前一定要以管理员身份启动VirtualBox,不然会出现以下错误:

VBoxManage.exe: error: Failed to create the VirtualBox object!
VBoxManage.exe: error: Code CO_E_SERVER_EXEC_FAILURE (0x80080005) - Server execution failed (extended info not available)
VBoxManage.exe: error: Most likely, the VirtualBox COM server is not running or failed to start.

(Read More)

How to Connect to Cisco VPN

Enterprise users always have the problem of how to connect to their corporate VPN server. Usually corporate uses Cisco VPN, which is a little difficult to connect than other VPN. Fortunately we have solutions for several different platforms.

Information You Will Need

Before connecting to the VPN, you need to know the following information. Ask your network administrator if you don’t have this.

  • VPN Server Address
  • Group Name
  • Shared Secret
  • your username
  • your password

Sometimes you may need a RSA token, either a hardware token or a software token exists in your cell phone. This does not affect the way you connect to the VPN – just use your token as your password.

(Read More)