Skip to content

Instantly share code, notes, and snippets.

@jngo
jngo / gist:44418
Created January 7, 2009 20:46 — forked from anonymous/gist:44410
Subdomains in Ruby on Rails
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
$("ul#featured").mouseover(function()
{
$("div.popup").slideUp();
});
$("ul#featured").mouseout(function()
{
$("div.popup").slideDown();
});
@jngo
jngo / gist:48324
Created January 17, 2009 12:17
Grabbing mysql production databases to your local system with rake.
# Via Ben Scharz (http://www.germanforblack.com/2007/grabbing-mysql-production-databases-to-your-local-system-with-rake)
namespace :db do
desc "Sync your local database with a remote one REMOTE=name_of_database LOCAL=your_local_db"
task :sync do
`ssh domain.com "mysqldump --skip-extended-insert -u db_username -p #{ENV['REMOTE']} | bzip2 " | bzcat | mysql -u root #{ENV['LOCAL'] || "app_development"}`
end
end

Why build a site? Why do your customers care?

The core purpose of a website is to help your customers answer the questions necessary to do business with you.

If your website is a series of answers to questions then the success of your site depends on what questions you answer--it's the questions and answers that show the customer you provide a service they're looking for, you're a good choice and that they should buy from you.

In general every customer has the following questions:

  1. Who are you?
  2. What do you offer?
@jngo
jngo / gist:119088
Created May 28, 2009 04:24
Implementing single name attribute for ActiveMerchant's CreditCard class.
class CreditCard < ActiveMerchant::Billing::CreditCard
def name_on_card
"#{first_name} #{last_name}".strip
end
def name_on_card=(name)
if name and match = name.strip.match(/^(.+)\s([^\s]+)$/)
self.first_name, self.last_name = match[1], match[2]
else
self.first_name, self.last_name = name, ''
@jngo
jngo / example_gist_create.rb
Created June 15, 2009 14:34 — forked from schacon/example_gist_create.rb
Gist API example.
require 'net/http'
require 'uri'
# /api/v1/:format/new
# /api/v1/:format/gists/:user
# /api/v1/:format/:gist_id
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'),
{ 'files[file1.ab]' => 'CONTNETS',
'files[file2.ab]' => 'contents' })
@jngo
jngo / application_controller.rb
Created June 15, 2009 23:16 — forked from pat/application_controller.rb
Returning HTML in AJAX calls for Ruby on Rails.
# Three things to add:
# * before_filter call
# * action_has_layout? method (if you have one, combine them)
# * adjust_for_inline
#
class ApplicationController < ActionController::Base
# ...
before_filter :adjust_for_inline
# Enable gzip compression.
SetOutputFilter DEFLATE
# Disable compression for browsers that do not support compression other than HTML.
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Disable compression for images.
SetEnvIfNoCase Request_URI \
@jngo
jngo / gist:3904793
Created October 17, 2012 10:05
Homebrew Path
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/Cellar/ruby/1.9.3-p194/bin:/usr/local/mysql/bin:$PATH"
@jngo
jngo / SketchSystems.spec
Last active June 19, 2019 15:10
Transaction
Transaction
View
Edit -> Edit
Edit
Cancel -> View
Save -> View