Skip to content

Instantly share code, notes, and snippets.

View lanrion's full-sized avatar
🎯
Focusing

lanrion lanrion

🎯
Focusing
  • guǎng zhōu
View GitHub Profile
@lanrion
lanrion / gist:80b0bef516aeba34ad45
Created May 23, 2014 01:40
重置virtualBox的ip
所VM换到另外一台机器运行时,会发现ip没有了,查看以下解决方法
http://www.serenux.com/2009/11/howto-fix-a-missing-eth0-adapter-after-moving-ubuntu-server-from-one-box-to-another/
@lanrion
lanrion / gist:781e83e837ef3514ad3d
Created May 21, 2014 08:25
mysql gem 安装失败的常见问题。
是由于其C++的编译器出了错误,使用此命令安装:
sudo apt-get install libmysql++-dev
@lanrion
lanrion / gist:cef99e8e83c8476ffafc
Last active August 29, 2015 14:01
正则表达式中(),所引起的全局变量的改变。

http://stackoverflow.com/questions/288573/1-and-1-in-ruby

  def method_missing(meth, *args, &block)
    if meth.to_s =~ /^find_by_(.+)$/
     # $1 即为(.+所得)
      run_find_by_method($1, *args, &block)
    else
      super # You *must* call super if you don't handle the
 # method, otherwise you'll mess up Ruby's method
@lanrion
lanrion / gist:3f14ed88ada29e2765b4
Last active August 29, 2015 14:01
Java 甲骨文技术沙龙分享会--WebSocket总结

WebSocket

常规网站实现“实时”的方式:

1)轮询(JavaScript中的setInterval) 最简单的是前台轮询,每隔一段时间去请求后台,以获取最新状态,这种方式最容易实现,但效果也最差,频繁盲目的调用后台,带来不必要的开销,且实时性无法保障,后台出现更新,前端需要在下一次轮询时才知道。

2)长轮询 为了解决这些弊端,进化出长轮询技术,轮询请求会在后台阻塞,相当于保持一个长连接,直到后台出现更新或者超时才返回,这样就可以保证更新的及时性,前端得到请求后,重新建立轮询连接,等待后台的更新通知。

@lanrion
lanrion / gist:e1010106e9fc1b9d19f4
Created May 5, 2014 03:38
VMBoxManage 启动与关闭虚拟机
http://www.linuxidc.com/Linux/2012-01/51362.htm
心得一:虚拟机无法启动
由于服务器需要断电,有同事就把服务器关掉了,但是服务器上的虚拟机并没有正常关闭,结果再开机的时候就显示下面的错误:
[root@localhost ~]# vboxmanage startvm winxp
Waiting for VM "winxp" to power on...
VBoxManage: error: The virtual machine 'winxp' has terminated unexpectedly during startup with exit code 0
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component Machine, interface IMachine, callee
@lanrion
lanrion / gist:a715b33f16b99eb0ce0a
Created May 1, 2014 11:33
linux 下screen 的使用。

1, 列出所有screen:

 screen -list

2, 创建新的screen

 screen -R name # 要么连接一个已有的,要么就创建一个。

rvm pkg install... 已经被废除了,现在 rvm 使用了更智能的方法

首先,升级你的 rvm $ rvm get head

然后,运行 $ rvm autolibs enable,接着运行 $ rvm requirements

这时候,rvm 会自动检测需要的依赖并执行安装,你会看到结果

最后,安装或升级你的 ruby $rvm reinstall all

@lanrion
lanrion / gist:11395545
Created April 29, 2014 09:46
添加本地ssh key 到远程机器上。

1, 生成ssh-key:

ssh-keygen -t rsa

2, 添加到远程机器:

cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'

@lanrion
lanrion / gist:11167800
Created April 22, 2014 06:53
linux中对代码、文件查找的两个重要命令grep和find
http://www.cnblogs.com/huanghuang/archive/2011/02/25/1964788.html
1、grep [option] PATTERN [FILE...]
举个例子: 在内核目录下查找包含"request_irq"字样的文件。
cd /work/system/linux-2.6.22.6/
//*表示查找当前目录下的所有文件、目录,-R表示递归查找子目录