Skip to content

Instantly share code, notes, and snippets.

View lajunta's full-sized avatar
🌴
On vacation

lajunta lajunta

🌴
On vacation
View GitHub Profile
@lajunta
lajunta / autobackupmongo.rb
Created November 6, 2010 17:09
auto backup mongo (ruby version and very concise)
#!/usr/local/ruby/bin/ruby -w
Dbpath = "/data/db" # database path
Backpath = "/data/dbbackup" # backup directory
Host = "" # mongo host to connect,empty is for local
Database = "" # database to use. empty is for all
Collection = "" # collection to use
User = ""
Passwd = ""
Now = Time.now
DATE = Now.strftime("%Y-%m-%d")
@lajunta
lajunta / firewall
Created November 8, 2010 09:47
simple firewall for 22 53 80
iptables -F
# 允许包从22端口进入
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# 允许从22端口进入的包返回
iptables -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --sport 53 -j ACCEPT
#允许本机访问本机
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
@lajunta
lajunta / iptables
Created November 12, 2010 07:44
some rules for iptables
#!/bin/sh
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
iptables -t nat -F
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
@lajunta
lajunta / backup
Created November 12, 2010 07:45
backup apps
#!/usr/bin/ruby
Backpath = "/backup/apps/dljy"
Now = Time.now
DATE = Now.strftime("%Y-%m-%d")
Dom = Now.mday # Day of month
Dow = Now.wday # Day of week
M = Now.month # Month of the year
W = Now.strftime("%W") # Week of the year
Doweekly = 6 # Saturday
@lajunta
lajunta / start unicorn
Created November 12, 2010 07:48
start and stop unicorn
#!/bin/sh
PATH=/var/lib/gems/1.9.1/bin:/usr/local/mongodb/bin:/usr/bin
cd /usr/local/railsites/zcms
unicorn_rails -p 80 -E production -D
exit 0
#stop
#!/bin/bash
pkill unicorn_rails
@lajunta
lajunta / mongobackup
Created November 12, 2010 07:50
backup daily (rollover 7 days ) and monthly
#!/usr/bin/ruby
Dbpath = "/data/db" # database path
Backpath = "/backup/db" # backup directory
Host = "" # mongo host to connect,empty is for local
Database = "" # database to use. empty is for all
Collection = "" # collection to use
User = ""
Passwd = ""
Now = Time.now
DATE = Now.strftime("%Y-%m-%d")
# This function cleans up messy HTML that was pasted by a user to a WYSIWYG editor.
# Specifically it also handles messy Word\Outlook generated HTML while keeping its original formattings.
require 'rubygems'
require 'sanitize'
def clean_up_document(html)
elements = %w[p b h1 h2 h3 h4 h5 h6 strong li ul ol i br div pre p]
attributes = {
'a' => ['href', 'title'],
---
gem: --no-ri --no-rdoc
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
- http://ruby.taobao.org/
:update_sources: true
:verbose: true
execute pathogen#infect()
syntax on
filetype plugin indent on
set nu
set autoindent
set tabstop=2
set shiftwidth=2
set softtabstop=2
set smarttab
set expandtab
execute pathogen#infect()
syntax on
filetype plugin indent on
set nu
set autoindent
set tabstop=2
set shiftwidth=2
set softtabstop=2
set smarttab
set expandtab