Skip to content

Instantly share code, notes, and snippets.

@ericchen
ericchen / firewall.sh
Created November 14, 2015 14:52
firewall config
# firewall
ufw allow ssh
ufw allow http
ufw allow https
ufw logging on
ufw enable
# check rule
ufw status numbered
@ericchen
ericchen / Disk.md
Last active November 12, 2015 13:04
Digitalocean上Debian系统删除垃圾文件后磁盘空间仍然占100%
@ericchen
ericchen / xargs.sh
Created April 18, 2015 09:42
xargs remove file with special name on mac
ls | grep 发货 | tr '\n' '\0' | xargs -0 rm
# -*- coding: utf-8 -*-
from scrapy.item import Item, Field
class RamenStyle(Item):
shop_id = Field()
style = Field()
soup = Field()
class RamenReview(Item):
review_id = Field()
@ericchen
ericchen / login_by_cookies.md
Created January 22, 2015 13:07
导入cookies文件实现自动登录

##Download chrome plugin cookietxt-export and export cookie data to cookie.txt after you login manually##

agent = Mechanize.new

agent.cookie_jar.load('cookies.txt', :cookiestxt)

@ericchen
ericchen / bundle_local.md
Last active January 6, 2018 06:49
在Gemfile里面利用bundle修复gem插件的bug

###方法1: 可以将远端的github代码下到本地来修改,无须再自己fork一个新的项目,便于快速修改plugin中的错误, 下面是使用方法

Bundler also allows you to work against a git repository locally instead of using the remote version. This can be achieved by setting up a local override:

bundle config local.GEM_NAME /path/to/local/git/repository (bundle config local.active_shipping ~/gems/active_shipping/)

and setup the git repo pointing to a branch: gem 'active_utils', :github => 'Shopify/active_utils', :branch => '2.2.3'

##推荐使用方法2, 将github的源码copy到vendor下,然后在gemfile里面指定一下path##

How to install PhantomJS on Ubuntu

Version: 1.9.7

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
@ericchen
ericchen / com.md
Last active August 29, 2015 14:08
比较2个文件内容的不同

比较2个文件内容的不同行数

sort file1 file2 | uniq -u > file3

查找文件中的重复行

cat file | sort | uniq -d
@ericchen
ericchen / nginx_subdomain.md
Last active August 29, 2015 14:03
解决redirect_to跳转丢失子域名

问题描述

使用redirect_to跳转时子域名丢失,比如跳转到subdomain.example.com/admins/users时nginx会帮你解析到subdomain.example.com/admins/.example.com/admins/users

解决方法

在nginx配置文件里面添加如下代码

proxy_redirect off;