Skip to content

Instantly share code, notes, and snippets.

@lenciel
lenciel / gist:4543970
Created January 16, 2013 02:01
Windows 7 VERR_LDR_MISMATCH_NATIVE
I was having a problem with Win7 and Virtualbox 4.2.6. All my vms cannot be started up.
the answer appears to be found by going to C:\USERS\<username>\AppData\Local\VirtualStore\Program Files
and then rmdir /s Oracle
the contents there are created by running Virtualbox without Administrator privilege and can safely be deleted.
the new version of Virtualbox will create new files there, if needed.

Sometimes we cannot successfully install packages using "pip install". We can then try to find compiled bundle in "exe" format for the specified python release version we are using.

If we found bundle compiled by some other developers and we want to install it into a specific virtualenv rather than globally, we can simply use the easy_install tool under the virtualenv we activated:

easy_install binary_installer_built_with_distutils.exe
@lenciel
lenciel / ssh-copy-id
Last active December 15, 2015 17:39
Get ssh-copy-id on Mac OS X
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
#
# http://www.devthought.com/2009/09/19/get-ssh-copy-id-in-mac-os-x/
#
@lenciel
lenciel / Android截屏
Last active December 22, 2015 15:29
Android如何命令行进行截屏
一般 Android 用户都知道同时按下音量减和电源键的屏幕截图方式,不过作为开发者,可能需要一个更为简便的方式将屏幕截图保存至开发电脑上。
该方式仅需在终端执行一条命令即可,涉及调用系统内置的 screencap 工具:
```
adb shell screencap -p | sed 's/\r$//' > screen.png
```
screencap 本身支持标准输出,所以可以用管道符链接。但是 adb shell 会将结果中的 LF 转换为 CR+LF(为了兼容性考虑?),于是会将 png 的格式破坏。于是这里使用行编辑器 sed 将 LF 前的 CR 移除。
@lenciel
lenciel / vertical align
Created January 15, 2014 18:19
vertical align anything
%vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.element p {
@extend %vertical-align;

Keybase proof

I hereby claim:

  • I am lenciel on github.
  • I am lenciel (https://keybase.io/lenciel) on keybase.
  • I have a public key ASAdpEB6qCAu--QM2AurwajcSOdLJ0NCda7NCK9RYsX6iAo

To claim this, I am signing this object:

基础知识

  • 计算机软硬件基础
  • 计算机网络
  • 操作系统
  • 数据结构和算法
  • 设计模式
  • 以及其他各种你应该懂的东西

前端开发

  • 前端标准/规范
@lenciel
lenciel / gist:3957313
Created October 26, 2012 06:54
Build vim on ubuntu 10.04 64bit with python and ruby support

By installing Vim with ruby support from the sources, it is build against the system wide installation of ruby. If you already installed Vim and/or ruby with sudo apt-get install vim (or sudo apt-get install ruby) or with brew install vim (e.g. brew install ruby) if you are using OS X, remove it completely from your system to install the latest version of Vim.

Install rbenv

I'm installing rbenv on different machines so I created the following script (named rbenv_install.sh) to install ruby 1.9.2-p320:


cd $HOME
sudo rm -rf .rbenv
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
@lenciel
lenciel / supervisord.conf
Created September 4, 2014 16:03
supervisor configuration file for sentry
;Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;
; Put this file in /etc/supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)

Latency Comparison Numbers

Note: "Forked" from Latency Numbers Every Programmer Should Know

Event Nanoseconds Microseconds Milliseconds Comparison
L1 cache reference 0.5 - - -
Branch mispredict 5.0 - - -
L2 cache reference 7.0 - - 14x L1 cache
Mutex lock/unlock 25.0 - - -