Categories
Social Media TechBiz WebApps

High Quality Engagement from Instagram Photo Walks

Last year I hosted over 25 photo walks organized through Instagram and about half of these were branded “experiences.” I did this to learn more about photography, marketing and working with brands. It was a fun experience but not so fun realizing I helped generate millions in revenue and just got an Instagram mug from it. 😀

I was able to reach a large audience for a fraction of the cost of a TV commercial (< 50%) , and was able to produce measurable and actionable results. stolioriginal

Here’s some data from the Stolichnaya photo walk which had the hashtag #stolioriginal :
https://gist.github.com/barce/f541cc4612ec9b11da1f

followers 234564
likes       9328
posts         67
guests        32


1240 (drinks & food)
1200 hotel + flight for organizer

$2440 for 234,564 viewers
$0.010


Commercial for a show like Two and a Half Men
$215,000 per 30 second commercial
8.5 million viewers
$0.025 per viewer

In one evening Stoli was able to reach over 200,000 eyeballs at a cost of a penny per eyeball! Great stuff, right?

Categories
Mobile Apps TechBiz WebApps

3 Alternatives to Showing Photos on Twitter after the Instagram Yank

If you post a photo with text from Instagram to Twitter, your photo will no longer show up on Twitter. Lots of blogs have already covered this story. Some have even gone so far as to defend this decision.

If you’re looking for photo services that haven’t yanked Twitter cards. Here are 3 that are cool to use.

  1. There’s Camera+ which has lots of filters and photo editing tools. The main feature that I like about Camera+ is the light box that allows you to select and arrange which images to edit.
    Here’s an example of Camera+ embedded into Twitter.
  2. Path is okay if you don’t mind blasting your closest friends with Twitter updates. The iPad version of this app is really beautiful and lots of thought went into the UI. Here’s its embed.
  3. Via.Me* is hands down the best for power users that need to post images to both Twitter and Facebook. Your photos also show up Pinterest-like on the app’s web page for leisurely desktop viewing. Below is Via.Me in a Twitter card.

* Disclosure: I work on the API at Via.Me.

Categories
Databases How-To MySQL WebApps wordpress

How To Back Up WordPress with mysqldump

Here’s a quick how to:

1. Tar up the directory:

tar cvf WordPress.tar wordpress/.
bzip2 WordPress.tar

2. Dump the database.

mysqldump --user user_name --password --host example.com --extended-insert=FALSE database_name > database_name.sql

I personally use extended-insert set to false because I often have to read the SQL.

Here is how to restore from backup:


tar zxvf WordPress.tar.bz
mysql --user user_name -p -hexample.com database_name < database_name.sql

Be sure to replace user_name, example.com and database_name with the appropriate values for your system.

I hope this helps.

Categories
ruby on rails Social Media TechBiz WebApps

What the Next Rails Will Look Like

History repeats itself, yet it is obscure to the very people making it: innovators and inventors. Ruby on Rails was an invention that hit the scene in July of 2004 as a revelation. There was a video that promised that you could make a blog in less than 15 minutes that left many speechless.

When Rails hit the seen, my reaction was:

1. This is something that we should have been doing all along.

Books like The Pragmatic Programmer had been preaching what Rails was doing since the 1990s. Software engineers would half-heartedly code the “Rails ways” but never got around to building something like Rails.

2. I need less people on my web team.

It seemed that you could work with just a designer and get lots done. I didn’t have to go to IT as much as database issues. I could use generators and save hours of time.

3. That startup that seemed impossible now seems within reach.

I remember a young Chris Wanstrath at a Ruby meetup I hosted saying with a tired look in his face that he wished he was working in Ruby. He was at CNET / CBS Interactive at the time. He’s built the best tool for developers out there and I use github.com every day.

That’s the past, now what’s the future?

The tough question to ask is, “What should we, as an industry, be doing that we are not?” The Rails philosophy was loudly yelling, “We aren’t doing DRY.”

It seems that there are 4 things that need to be done in the “next” Rails:

1. Mobile ready out of the box.

We should all be using CSS media queries and have the ability to support the mobile web. There are so many missed opportunities to retain users simply because mobile is still shockingly ignored.

2. Social Sharing out of the box.

This basically means that there has to be a standard for creating an API for APIs.

3. The backend will just look like an API.

Say good bye to complex SQL joins.

4. Designing tools with deep integration into the cloud.

Languages have been designed for CPUs in non-networked environments. This means that at a core-level, the next Rails will be SSL capable, e-commerce capable and ready to scale out of the box. Hints of this can be seen in Erlang.

Categories
AWS php sysadmin WebApps

Building PHP with nginx, and fast-cgi on EC2

Here’s my quick and dirty guide to building PHP with nginx and fast-cgi on EC2:

yum install mysqld
yum install mysql
yum install mysql-server
yum install mysql-devel
service mysqld start
/usr/bin/mysqladmin -u root password 'your_password'
/usr/bin/mysqld_safe &
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear
 php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mbstring p
hp-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
yum install spawn-fcgi
# Next, download spawn-fcgi init.d shell script:
wget http://bash.cyberciti.biz/dl/419.sh.zip
unzip 419.sh.zip
mv 419.sh /etc/init.d/php_cgi
chmod +x /etc/init.d/php_cgi
# Start php app server, enter:
/etc/init.d/php_cgi start

# check to see if it's running
netstat -tulpn | grep :9000

Your /etc/nginx/nginx.conf file should look like this:
https://gist.github.com/1961501

Categories
os x ruby on rails WebApps

Rails on Nginx with Passenger on Mac OS X Lion

This is a quick and dirty guide to getting Ruby on Rails working on Nginx with Passenger on Mac OS X Lion:

brew install nginx
gem install passenger
cd ~/Library/Caches/Homebrew/
tar zxvf nginx-*.tar.gz 
cd nginx-*
passenger-install-nginx-module 

Now you to edit this file:

/usr/local/Cellar/nginx/1.0.11/conf/nginx.conf

Make sure there’s something like the stuff below:

  server {
        listen       8080;
        server_name  localhost;

        root /Users/me/repos/my_awesome_rails_app/public

        rails_env development;
        passenger_enabled on;

        charset utf-8;
  }

nginx
lynx http://localhost:8080

Guides Online:

http://mrjaba.posterous.com/rails-31-asset-pipeline-with-nginx-and-passen

http://samsoff.es/posts/running-rails-local-development-with-nginx-postgres-and-passenger-with-homebrew

Categories
Coding How-To ruby ruby on rails WebApps

Upgrade Your Rails Facebook App to SSL

On October 1st of this year, Facebook will be requiring that all apps on Facebook must support HTTPS (SSL).

I’ve provided a guide below which I’ve used for apps I’ve worked on that are Rails based.

This guide shows you how to change your Rails Facebook App into an app that supports SSL using Passenger and Apache2.

Step 1: Get an SSL cert or roll your own.

Dreamhost.com made it very easy to add an SSL cert for just $15.00 / year.

I tried out my app out using a locally signed certificate which seemed to work just fine:

openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Step 2: Install and compile Apache 2

Get the latest version of Apache: http://httpd.apache.org/download.cgi.

Configure and compile Apache:
./configure –prefix=/usr/local/apache2 –enable-rewrite –enable-so –enable-ssl
make && make install

Step 3: Configure your Rails app

gem install passenger
passenger-install-apache2-module

Step 4: Edit your Apache 2 config files:

Edit httpd.conf. For example:

LoadModule fcgid_module modules/mod_fcgid.so
LoadModule passenger_module /Users/jimbarcelona/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.8/ext/apache2/mod_passenger.so
PassengerRoot /Users/jimbarcelona/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.8
PassengerRuby /Users/jimbarcelona/.rvm/wrappers/ruby-1.9.2-p290/ruby


    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all


Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-ssl.conf


IPCCommTimeout 40
IPCConnectTimeout 10

# TODO: change this to production if you are on production
DefaultInitEnv RAILS_ENV development
SocketPath /tmp/fcgidsock

Edit extra/httpd-vhosts.conf:


  ServerName berkeley.l33tcave.com
  ServerAdmin wwwadmin@berkeley.l33tcave.com
  DocumentRoot /Users/jimbarcelona/rails_apps/github/hipsterhookups.com/public
  ErrorLog /usr/local/apache2/logs/rails_error_log
  RewriteEngine On
  
    AllowOverride All
    Options -MultiViews
  
  RailsEnv development

Edit extra/httpd-ssl.conf:

#   General setup for the virtual host
DocumentRoot "/Users/jimbarcelona/rails_apps/github/hipsterhookups.com/public"
ServerName berkeley.l33tcave.com:443
ServerAdmin you@example.com
ErrorLog "/usr/local/apache2/logs/error_log"
TransferLog "/usr/local/apache2/logs/access_log"

# needed for rails
Options Indexes ExecCGI FollowSymLinks
RewriteEngine On
RailsEnv development


AddHandler fcgid-script .fcgi

  
    AllowOverride All
    Options -MultiViews
  

Be sure to add your SSL certs in the httpd-ssl.conf too!

Step 5: Start Apache

# check syntax
apachectl configtest
# start apache
apachectl start

Step 6: Go to facebook and use https for canvas URLs

Categories
How-To ruby WebApps

Setting Up Cucumber and RSpec on Padrino

This is a quick guide on how to set up Cucumber and RSpec on Padrino.

I’ve created a simple test app on github that reflects the steps written down here.

1. Create the app:

padrino g project todo -t cucumber -d sequel -b

2. In the Gemfile use rake 0.8.7:

gem 'rake', "0.8.7"

3. In features/support/env.rb comment out “require ‘spec/expectations'” so it looks like:

# require 'spec/expectations'

At this point ‘cucumber features’ should work and should return a failed test for adding two numbers.

Also at this point, if you create any models, then bare specs for them will be created in the ‘spec/models’ folder.

Please feel free to leave questions or comments if you’ve got a different way of setting things up on Padrino.

Categories
How-To ruby WebApps

How To Test Image Uploads With MiniTest On Padrino

This week I got to pair program with Oren Golan whose last high profile job was at Border Stylo. While there, he wrote a series of excellent blog posts that I highly recommend reading. The one that caught my eye was his post on MiniTest, that’s a lighter version of RSpec.

We created a Padrino app that uses the Sequel gem as an ORM for SQLite.

We tested a raw file upload and the uploading capabilities of Carrierwave.

The working test is on http://github.com/barce/test, and to run it just clone the repo and type the following:

cd test
bundle install
padrino sq:migrate:up

Here’s the test:

# put this into the test/test.rb file
require 'rubygems'
gem 'minitest'
require 'minitest/autorun'
require 'rack/test'
require '../config/boot.rb'

class TestManualBadgeType < MiniTest::Unit::TestCase
  include Rack::Test::Methods

  FILE2UPLOAD  = "/Users/jimbarcelona/pink-pony.jpg"
  UPLOADEDFILE = "/Users/jimbarcelona/repos/oren/forks/test/test/pink-pony.jpg"

  def app() Test end

  def setup
    if File.exist?(UPLOADEDFILE)
      File.delete(UPLOADEDFILE)
    end
  end

  def test_opload
    post '/', 'file' => Rack::Test::UploadedFile.new(FILE2UPLOAD, 'image/jpeg')

    assert_equal last_response.status, 201
  end

  def test_carrierwave_201
    post '/carrierwave', 'file' => Rack::Test::UploadedFile.new(FILE2UPLOAD, 'image/jpeg')

    assert_equal last_response.status, 201
  end

  def test_carrierwave_file_exist
    post '/carrierwave', 'file' => Rack::Test::UploadedFile.new(FILE2UPLOAD, 'image/jpeg')
    assert_equal last_response.status, 201
  end
end

Now you’re ready to run the test upload:

cd test
ruby test.rb
Categories
scalability hacking sysadmin TechBiz WebApps

Why is Foursquare Down? 3 Educated Guesses

Why is Foursquare down?

Update (5 October 2010 at 5:36 pm PDT) : The folks at Foursquare tell us why in a post-mortem. There are autosharding issues with MongoDB. Yup, my guesses were wrong, unless you consider MongoDB a kind of cache. 😉

I used to work for a few sites that required high scalability expertise. Now that we’re over 5 hours into the outage I’ll share some of my thoughts.

But before I do, I’d just like to say, I really hope that it’s nothing bad and I really like the Foursquare peeps. I’m not putting out this article to harsh on anybody, but just to share some knowledge I have. Outages happen to everybody!

Also, I do not feel that this meltdown is in any way indicative of Amazon’s EC2. I have a site that shares the same IP space and facility as Foursquare and we have had no outages today.

  • The worst case scenario is a full scale Magnolia meltdown. This is where because of a backup process that was off, they cannot restore ever from backup. Odds: unlikely.
  • Someone turned off caching. I’m not sure how cache dependent the architecture is at Foursquare. If someone turned off the cache and the cache is just plain gone, then the caches have to be re-built. Rebuilding caches, depending on the time and complexity of each query can take up to 100x more time that it takes to retrieve the cache. If there’s some cached item that takes 100 seconds per user, the site will be down for a long time. They can only put a user back on foursquare at a rate of 100 per second if that’s the case, unless they can concurrently run the re-building of the cache.
  • There’s an issue with a hacker who has broken through security and is wreaking havoc on Foursquare. It’s happened to the best sites, e.g. Google in the 90s, and it’s pretty tough to recover from. Sometimes you let the criminals in and do their worst while keeping the site up. Sometimes you have 0 tolerance.
  • I wish Foursquare the best of luck. I am more than happy to lend a hand to their issues, if they need another pair of eyes.