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
| Person = { | |
| // Push the implementation details of the database into a | |
| // different object to keep Person clean. | |
| // | |
| database: AddressBook, | |
| find: function(id) { | |
| if(id == "all") { | |
| return this.database.allCards(); | |
| } else { | |
| return this.database.openCard(id); |
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
| AddressBook = { | |
| // Change this to point to your own CouchDB instance. | |
| uri: "http://craig-01.vm.xeriom.net:5984/addressbook/", | |
| _request: function(method, uri) { | |
| var req = new XMLHttpRequest(); | |
| req.open(method, uri, false); | |
| req.send(); | |
| return req; | |
| }, |
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
| <!-- Add this to the head of addressbook.html --> | |
| <script src="http://yui.yahooapis.com/2.5.2/build/yahoo/yahoo-min.js"></script> | |
| <script src="http://yui.yahooapis.com/2.5.2/build/json/json-min.js"></script> |
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
| // Make YUI JSON available in the global namespace. | |
| // Add this to addressbook.js | |
| JSON = YAHOO.lang.JSON; |
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
| // This is horrible, I know, but it's just a simple example. | |
| window.onload = function() { | |
| var addressbook = document.getElementById("addressbook"); | |
| var personList = document.createElement("ul"); | |
| for(var offset in people) { | |
| var person = people[offset]; | |
| var personNode = document.createElement("li"); | |
| var name = document.createTextNode(person.name); | |
| personNode.appendChild(name); | |
| personList.appendChild(personNode); |
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
| RAILS_DEFAULT_LOGGER.debug "Launching database connection verifier" | |
| Thread.new do | |
| loop do | |
| sleep 1800 # Half an hour | |
| RAILS_DEFAULT_LOGGER.debug "Verifying database connections" | |
| ActiveRecord::Base.verify_active_connections! | |
| end | |
| end |
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
| # On db-01 | |
| sudo iptables -I INPUT 3 -p tcp --dport mysql -s db-02.vm.xeriom.net -j ACCEPT | |
| sudo iptables -I INPUT 3 -p udp --dport mysql -s db-02.vm.xeriom.net -j ACCEPT | |
| sudo iptables -I INPUT 3 -p udp --dport 694 -s db-02.vm.xeriom.net -j ACCEPT | |
| # On db-02 | |
| sudo iptables -I INPUT 3 -p tcp --dport mysql -s db-01.vm.xeriom.net -j ACCEPT | |
| sudo iptables -I INPUT 3 -p udp --dport mysql -s db-01.vm.xeriom.net -j ACCEPT | |
| sudo iptables -I INPUT 3 -p udp --dport 694 -s db-01.vm.xeriom.net -j ACCEPT |
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
| Chain INPUT (policy ACCEPT) | |
| target prot opt source destination | |
| ACCEPT all -- anywhere anywhere | |
| ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED | |
| ACCEPT udp -- db-01 anywhere udp dpt:694 | |
| ACCEPT tcp -- db-01 anywhere udp dpt:mysql | |
| ACCEPT tcp -- db-01 anywhere tcp dpt:mysql | |
| ACCEPT tcp -- anywhere anywhere tcp dpt:ssh |
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
| sudo sh -c "iptables-save -c > /etc/iptables.rules" |
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
| sudo apt-get install mysql-server --yes |