一对一关系:有 A 和 B,A 拥有且仅拥有一个 B
This file contains 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
#!/usr/bin/env bash | |
ssh -t peter@happycasts.net ' | |
source ~/.bash_login && cd ~/happycasts && \ | |
git pull && \ | |
bundle exec rake db:migrate RAILS_ENV=production; \ | |
bundle && bundle exec rake assets:precompile &&\ | |
touch tmp/restart.txt | |
' |
This file contains 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 API < Grape::API | |
format :json | |
error_format :json | |
version 'v1', :using => :header, :vendor => "App" | |
rescue_from Mongoid::Errors::DocumentNotFound do |error| | |
rack_response({"error" => {"message" => "We didn't find what we were looking for"}}.to_json, 404) | |
end |
This file contains 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
[program:gunicorn-graphite] | |
command=/usr/local/bin/gunicorn_django -u www-data -g www-data -b 127.0.0.1:8080 --log-file=/opt/graphite/storage/log/webapp/gunicorn.log /opt/graphite/webapp/graphite/settings.py | |
process_name=%(program_name)s | |
autostart=true | |
autorestart=true | |
stopsignal=QUIT | |
user=www-data | |
[program:carbon-cache] | |
command=python /opt/graphite/bin/carbon-cache.py --debug start |
This file contains 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
upstream unicorn { | |
server unix:/tmp/unicorn.bthlabs.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
# server_name example.com; | |
root /index; |
This file contains 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
#!/usr/bin/env bash | |
ssh linode 'cd local_clone; cd happynewsdb; \ | |
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot authlove_development>authlove_development.sql; \ | |
git commit -a -m"i"; \ | |
git push;\ | |
cd ../happyecdb/ ; \ | |
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot ec_development>ec_development.sql; \ | |
git commit -a -m"i"; \ | |
git push;\ |
This file contains 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
> Tested on ubuntu 12.04 if rvm installed for single user | |
$ echo $PATH # Since cron doesn't have user's local environment, we need to specify it | |
$ echo $GEM_PATH # Copy this output to | |
# Modify schedule.rb with your new PATH's | |
# It should be like this one (add it to the top) | |
env :PATH, '/home/home_user/.rvm/gems/ruby-1.9.3-head/bin:/home/home_user/.rvm/gems/ruby-1.9.3-head@global/bin:/home/home_user/.rvm/rubies/ruby-1.9.3-head/bin:/home/home_user/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/home_user/.rvm/bin' | |
env :GEM_PATH, '/home/home_user/.rvm/gems/ruby-1.9.3-head@gemset:/home/home_user/.rvm/gems/ruby-1.9.3-head@global' | |
# Now update you crontab file |
Hubot需要Node和npm的比较新的版本,Mac os x安装非常简单,从nodejs.org下载安装就可以了
➜ node --version
v0.12.4
➜ npm --version
This file contains 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
{TextMessage} = require '../node_modules/hubot/src/message' | |
module.exports = (robot) -> | |
robot.router.post '/hubot/bearychat/:room', (req, res) -> | |
data = if req.body.payload? then JSON.parse req.body.payload else req.body | |
robot._send ?= robot.adapter.send; | |
robot.adapter.send = (user,strings...) -> | |
res.send {text: strings.toString()} if user.user.name is "http" | |
robot.adapter.send = robot._send if user.user.name isnt "http" |
Given an Array of Functions fns
, what argument(s) can you pass to fns.forEach
such that each function in fns
will execute, in order, without creating any anonymous (or named) functions or invoking the Function
constructor?
- Do not use the
function
keyword, or arrow functions() =>
. - Do not invoke the
Function
constructor. - Do not use method definitions.
Function#bind
& friends on theFunction.prototype
are ok.
OlderNewer