-
通过ssh传输文件
scp -rp /path/filename username@remoteIP:/path
#将本地文件拷贝到服务器上#scp -rp username@remoteIP:/path/filename /path
#将远程文件从服务器下载到本地#tar cvzf - /path/ | ssh username@remoteip "cd /some/path/; cat -> path.tar.gz"
#压缩传输#tar cvzf - /path/ | ssh username@remoteip "cd /some/path/; tar xvzf -"
#压缩传输一个目录并解压#rsync -avh /path/to/file/or/dir user@host:/path/to/dir/or/file
rsync -avh user@host:/path/to/file/or/dir /path/to/file/or/dir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LatLngList = new Array (new google.maps.LatLng (52.537,-2.061), new google.maps.LatLng (52.564,-2.017)); | |
// Create a new viewpoint bound | |
var bounds = new google.maps.LatLngBounds (); | |
// Go through each... | |
for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) { | |
// And increase the bounds to take this point | |
bounds.extend (LatLngList[i]); | |
} | |
// Fit these bounds to the map | |
map.fitBounds (bounds); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# need sum total number from following string with number | |
# [\"02:00\",233.39],[\"02:01\",233.32],[\"02:02\",233.31],[\"02:03\",233.3],[\"02:04\",233.29],[\"02:05\",233.26],[\"02:06\",233.3],[\"02:07\",233.32],[\"02:08\",233.3],[\"02:09\",233.4],[\"02:10\",233.38],[\"02:11\",233.31],[\"02:12\",233.34],[\"02:13\",233.35],[\"02:14\",233.32],[\"02:15\",233.43],[\"02:16\",233.44],[\"02:17\",0.0],[\"02:18\",0.0],[\"02:19\",233.56],[\"02:20\",233.58],[\"02:21\",233.45],[\"02:22\",233.4],[\"02:23\",233.56],[\"02:24\",233.6],[\"02:30\",233.57],[\"02:31\",233.53],[\"02:32\",233.7],[\"02:33\",233.71],[\"02:34\",233.63],[\"02:35\",233.67],[\"02:36\",233.61],[\"02:37\",233.68],[\"02:38\",233.69],[\"02:39\",233.62],[\"02:40\",233.53],[\"02:41\",233.6],[\"02:42\",233.7],[\"02:43\",233.73],[\"02:44\",233.76],[\"02:45\",233.72],[\"02:46\",233.72],[\"02:47\",233.7],[\"02:48\",233.65],[\"02:49\",233.65],[\"02:50\",233.68],[\"02:51\",233.72],[\"02:52\",233.72],[\"02:53\",233.74],[\"02:54\",233.68],[\"02:55\",233.73],[\"02:56\" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongodump -h dbhost -u username -p -d dbname -o /tmp/data | |
#restore mongo data | |
mongorestore -h dbhost -d dbname --directoryperdb /tmp/data/dbname |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
begin | |
gem "mechanize", "2.7.0" | |
rescue Gem::LoadError => e | |
system("gem install mechanize -v=2.7.0") | |
Gem.clear_paths | |
end | |
begin | |
gem "activesupport", "3.2.12" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 8080; | |
server_name example.dev www.example.dev; | |
location / { | |
root /Users/Cobby/Sites/Example; | |
if ($host = 'www.example.dev' ) { | |
rewrite ^/(.*)$ http://example.dev:8080/$1 permanent; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name magento.local; | |
access_log /usr/local/opt/nginx/logs/magento.local.access.log main; | |
root /Users/eric/Sites/magento; | |
location / { | |
index index.php; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Real-Host $host; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original copyright from https://github.com/ruby-china/ruby-china/blob/master/app/models/mongoid/base_model.rb | |
# add simple support for conditional find batch | |
# usage: Model.find_in_batches({:cond => {} }) | |
module Mongoid | |
module BaseModel | |
extend ActiveSupport::Concern | |
module ClassMethods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//redis command: CLIENT SETNAME connection-name | |
subscriber.send_command('CLIENT', ['SETNAME', 'connection_name']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Configuration | |
attr_accessor :username, :password | |
def initialize | |
yield self | |
end | |
end | |
c = Configuration.new do |config| |