Skip to content

Instantly share code, notes, and snippets.

View tfanme's full-sized avatar
🎯
Focusing

tfan tfanme

🎯
Focusing
View GitHub Profile
@tfanme
tfanme / gist:7260e926077b326b15da
Created November 4, 2014 07:25
rails server -e -p
rails server -e production -p 4000
@tfanme
tfanme / gist:9926277
Created April 2, 2014 01:15
查看Apache运行用户和组
只需要运行一下命令即可知道
ps -ef |grep httpd
运行之后就显示了httpd进程的运行用户
当然也可以通过查看apache的httpd.conf配置文件来查看apache运行用户和组.
@tfanme
tfanme / mongoid_belongto.rb
Created January 28, 2014 08:20
mongoid belongto relationship snip
require 'mongoid'
Mongoid.configure.connect_to('mongoid_test')
class Post
include Mongoid::Document
belongs_to :person
end
class Person
@tfanme
tfanme / mongoid_embedded.rb
Created January 28, 2014 08:19
mongoid embedded relationship snip
require 'mongoid'
Mongoid.configure.connect_to('mongoid_test')
class EventCourse
include Mongoid::Document
embeds_one :event
end
class Event
@tfanme
tfanme / nginx_vhost.conf
Created December 1, 2013 12:18
Nginx vhost configuration
server {
server_name foo.bar.com;
listen 80 default_server;
location = / {
proxy_pass http://localhost:11343/index.html;
}
location ~* /(fonts|js|html|css|images|img|lib|video)/ {
root /srv/www/foo.bar.com/public_html/public/;
@tfanme
tfanme / immutable.js
Created October 19, 2013 13:34
Primitive types are immutable
// sample 1
var a = 1; // new number
a = 5; // new number
a = a + 2; // new number
// sample 2
var name = "Roger";
name.toUpperCase(); // name is unchanged
name = name.toUpperCase(); // name = new string
@tfanme
tfanme / comparedByValue.js
Created October 19, 2013 13:32
Primitive types are compared by value
var a = "Roger";
var b = "Roger";
if (a == b) // => true
if (a === b) // => true
@tfanme
tfanme / passedByValue.js
Created October 19, 2013 13:31
Primitive types are passed by value
// sample 1
function foo(bar) {
bar = 2;
}
var a = 1;
foo(a);
alert(a); // => 1
// sample 2
var a = 1;
@tfanme
tfanme / mutable.js
Created October 19, 2013 13:29
Reference types are mutable
var point = { x: 1, y: 7 };
point.x = 2;
point.y = 9;
function fn() {
return true;
};
fn.x = 1;
@tfanme
tfanme / comparedByReference.js
Created October 19, 2013 13:28
Reference types are compared by reference
var a = { x: 1, y: 7 };
var b = { x: 1, y: 7 };
if (a == b) // => false
if (a === b) // => false
b = a;
if (a == b) // => true
if (a === b) // => true