- Requests hitting the same load balancer can't handle HTTP and HTTPS at the same time because of SSL issues
- If you are trying to access an outside resource behind a firewall, you have to tell them every time you get a new webserver so they can whitelist the new IP
- If you know the IPs of your web servers and database servers, you can have requests hit these directly and bypass the load balancers.
- Could buy your own data center, but then you have to buy a load balancing router. Those are fucking expensive (tens or hundreds of thousands of dollars)
(function(a, b) { | |
function c(b, c) { | |
var g = b.nodeName.toLowerCase(); | |
if ("area" === g) { | |
var g = b.parentNode, i = g.name; | |
if (!b.href || !i || "map" !== g.nodeName.toLowerCase()) | |
return !1; | |
g = a("img[usemap=#" + i + "]")[0]; | |
return !!g && d(g) | |
} |
As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.
All the complexity is handled by ActiveRecord::Transactions
. Any model class or instance has a method named .transaction
. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.
define("DOMAIN", "test.se"); | |
define("MAILGUN_API", "XXX123"); // Mailgun Private API Key | |
function br2nl($string) { | |
return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $string); | |
} | |
function mg_send($to, $subject, $message) { | |
$ch = curl_init(); |
/* | |
* picked from http://stackoverflow.com/questions/5186441/javascript-drag-and-drop-for-touch-devices | |
* | |
*/ | |
function touchHandler(event) | |
{ | |
// trick to add support for touch event to elements/widgets that do not support it | |
// by convetting convert touchevents into mouseevents | |
// only apply this trick to ui-draggable elements |
unless Rails.env.production? | |
connection = ActiveRecord::Base.connection | |
connection.tables.each do |table| | |
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations" | |
end | |
sql = File.read('db/import.sql') | |
statements = sql.split(/;$/) | |
statements.pop |
brew tap homebrew/versions | |
brew install v8-315 | |
gem install libv8 -v '3.16.14.13' -- --with-system-v8 | |
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315 | |
bundle install |
Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications
like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.
open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl
You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html
#!/bin/sh | |
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
# CREATE block and create them in separate commands _after_ all the INSERTs. | |
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
# The mysqldump file is traversed only once. | |
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |