Quick Tip: Understanding CSS3 Gradients

Quick Tip: Learning and Understanding CSS3 Gradients

Creating an image only for the purpose of displaying a gradient is inflexible, and is quickly becoming a bad practice. Unfortunately, at the time of this writing, they very well might still be required, but hopefully not for much longer. Thanks to Firefox and Safari/Chrome, we can now create powerful gradients with minimal effort. In this video quick tip, we’ll examine some of the differences in syntax when working with the -moz and -webkit vendor prefixes.


Webkit CSS3

While Mozilla and Webkit generally adopt the same syntax for CSS3 properties, they unfortunately don’t quite agree when it comes to gradients. Webkit was first to embrace gradients, and uses the following structure:

/* Syntax, taken from: http://webkit.org/blog/175/introducing-css-gradients/ */
-webkit-gradient(<type>, <point> [, <radius>]?, <point> [, <radius>]? [, <stop>]*)

/* In practice... */
background: -webkit-gradient(linear, 0 0, 0 100%, from(red), to(blue));
Webkit

Don’t worry if your eyes gloss over at that syntax; mine did too! Just note that we require a comma-separated list of parameters.

  • What type of gradient? (linear)
  • X and Y axis coordinates of where to begin. (0 0 – or left-top corner)
  • X and Y axis coordinates of where to conclude (0 100% – or left-bottom corner)
  • What color to begin with? (from(red))
  • What color to conclude with? (to(blue))

Mozilla

Firefox, which implemented gradient support with version 3.6, prefers a slightly different syntax.

/* Syntax, taken from: http://hacks.mozilla.org/2009/11/css-gradients-firefox-36/ */
 -moz-linear-gradient( [<point> || <angle>,]? <stop>, <stop> [, <stop>]* )

/* In Practice */
background: -moz-linear-gradient(top, red, blue);
Mozilla
  • Note how we’ve placed the type of gradient, linear, within the vendor extension.
  • Where should the gradient begin? (top – we could also pass in degrees, as in -45deg)
  • What color to start with? (red)
  • What color to conclude with? (blue)

Color-Stops

What if you don’t need a 100% gradient from one color to another? This is where color stops come into play. A common design technique is to apply a short and subtle gradient, like this:

Subtle Gradients

Note the subtle off-white to white gradient at the top.

In the past, the standard implementation was to create an image, set it as the background of an element, and set it to repeat horizontally. However, with CSS3, this is a cinch.

background: white; /* fallback for older/unsupporting browsers */
background: -moz-linear-gradient(top, #dedede, white 8%);
background: -webkit-gradient(linear, 0 0, 0 8%, from(#dedede), to(white));
border-top: 1px solid white;

This time, we set the gradient to conclude at 8%, rather than 100%, which is the default. Note that we’re also applying a border top to add contrast; this is very common.

If we wish to add a third (or Nth) color, we can do:

background: white; /* fallback for older/unsupporting browsers */
background: -moz-linear-gradient(top, #dedede, white 8%, red 20%);
background: -webkit-gradient(linear, 0 0, 0 100%, from(#dedede), color-stop(8%, white), color-stop(20%, red);
  • With the -moz version, we designate that, at 20% of the element height, we should now be at the color red.
  • For -webkit, we use color-stop, and pass in two parameters: where the stop should occur, and what the color should be.

Important Notes About CSS Gradients

  • Use them as much as you can. If it’s okay to let IE users see a solid color, I encourage you to use this method.
  • IE6/7/8, Opera, Safari 3, and Firefox 3 cannot render CSS3 gradients. Firefox and Safari users generally upgrade often, so that’s not as big of a deal.
  • Always apply a default, solid color, background for browsers that won’t understand the vendor prefixes.
  • Never use a red to blue gradient, as I did for the examples.
  • Webpages don’t need to look the same in every browser! :)

Setting up a Rails Server and Deploying with Capistrano on Fedora from Scratch

Setting up a Rails Server and Deploying with Capistrano on Fedora from Scratch

This article and video tutorial will teach you how to setup a basic Fedora server for Rails and PostgreSQL deployments. First, we’ll setup Apache and PostgreSQL. Then, we’ll use phpPgAdmin to create our application’s user and databases. After that, we’ll setup the Ruby platform using Passenger to run our application. Once all the components are installed, we’ll prep our application for deployment using Capistrano.

I’ll show you how to use Capistrano to automate remote tasks and take advantage of other features.


On With The Show


Understanding the Deployment Process

There is always a lot of confusion around deploying Rails applications. This tutorial hopes to sort some of that out. Most people know LAMP: Linux, Apache, MySQL, and PHP. We will setup LAPR: Linux, Apache, PostgreSQL, and Ruby. Setting up a LAPR server is very similar to setting up a LAMP server. The only wrinkle is getting Rails to talk to Apache. Thankfully, there is Passenger aka mod\_rails. Passenger is like mod\_php. It makes running Rails applications easy as pie. In order to run a Rails application through Apache, create a virtual host pointing the document root to the applications public directory and you’ll be riding on rails.

Capistrano is another part that people may not be familiar with. Capistrano is a Ruby gem designed to execute tasks on one or more remote machines. You’ll need SSH access to use Capistrano. Capistrano, affectionately known as Cap, automates the deploy process. We can use cap to take our code from some a repo and push it to the server, stop/start/restart the server, write custom tasks required by our application (think install required gems), or disable/enable a maintenance page. Using cap is not required but it sure beats using FTP to copy all the files around! Cap’s real power comes from the ability to write custom tasks in Ruby to manipulate the server. I’ve written a lot of applications that allow user file uploads. Then on the server side, some directory needs to be created with proper permissions for the uploads to succeed. It’s easy enough to write a cap task to create the directory and set the permissions. Then, if you ever change servers, you can simply run the cap task to setup the server again. There are many things you can do with Capistrano. You could even automate this entire tutorial to set up any number of machines at once!


Tutorial Sandbox

In order to complete this tutorial, you’ll need SSH + sudo access. If you don’t have a spare server sitting around, you can create one in VirtualBox. You can easily create a new VM and network it with your host system. I did this for the tutorial. When you start your virtual machine, make sure you use a bridged adapter so your VM gets an IP on the same subnet. I started with a fresh install without any customization. If you have access to a VPS like SliceHost, you can use these instructions as well.

Be sure to view the screencast before analyzing the code below.


Creating The Deployer

    $ sudo adduser -m deployer
    $ sudo passwd deployer
    $ sudo visudo deployer ALL=(ALL) NOPASSWD: ALL
    $ su deployer
    $ mkdir ~/.ssh
    $ touch ~/.ssh/authorized_keys2
    $ chmod -R 0700 ~/.ssh
    # copy your public key and paste it into the authorized_keys2 file
    $ service sshd start

Setting Up Postgres

    $ sudo yum groupinstall "PostgreSQL Database"
    $ sudo service postgresql initdb
    $ sudo service postgresql start
    $ su - postgres
    $ psql -d template1
    $ alter user postgres with password 'yourpostgresuserpassword';
    $ \q
    # Replace ident in /var/usr/lib/pgsql/data/pg_hba.conf with md5
    $ passwd postgres
    # set extra security in /etc/phpPgAdmin/config.inc.php to false
    # add 'Allow from YOUR_IP_HERE' to vhost in /etc/httpd/conf.d/phpPgAdmin.conf
    # enable http in the firewall
    $ sudo yum install httpd
    $ sudo service httpd start
    $ sudo service postgresql restart

Configuring Ruby, RubyGems, and Passenger

    $ sudo yum groupinstall Ruby
    $ sudo yum install rubygems
    $ sudo gem install gemcutter
    $ sudo yum install postgresql-devel
    $ sudo gem install pg
    $ sudo gem install passenger
    $ yum install gcc-c++ httpd-devel apr-devel
    $ sudo passenger-install-apache2-module
    # create this file /etc/http/conf.d/passenger.conf with these contents:
      LoadModule passenger_module     /usr/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so
      PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.9
      PassengerRuby /usr/bin/ruby

    $ sudo setenforce 0
    $ sudo service httpd restart

Creating the Deployer Folder

    $ sudo mkdir /var/www/html/apps
    $ sudo chown deployer:apache /var/www/html/apps
    $ sudo yum install git
    # at this point, create your databases in phpPgAdmin
 

Configuring Apache

    # echo "Include vhost.d/*.vhost" >> /etc/httpd/conf/httpd.conf
    $ sudo mkdir /etc/httpd/vhost.d
    $ sudo touch /etc/httpd/vhost.d/nettuts-demo.vhost
    # update that files conttents to:
      
          ServerName www.nettuts-demo.com
          DocumentRoot /var/www/html/apps/nettuts-demo/current/public
          
            Options FollowSymLinks
              Allow from all
              Options -MultiViews
          

          RewriteEngine On
          RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
          RewriteCond %{SCRIPT_FILENAME} !maintenance.html
          RewriteRule $ /system/maintenance.html [R=302,L]
      

Complete Cap File

    set :application, "nettuts-demo"
    set :repository,  "git://github.com/Adman65/Nettuts-Capistrano-Deployments.git"

    set :user, :deployer

    set :deploy_to, "/var/www/html/apps/#{application}"

    set :use_sudo, false

    set :scm, :git

    role :web, "192.168.1.112"                          # Your HTTP server, Apache/etc
    role :app, "192.168.1.112"                          # This may be the same as your `Web` server
    role :db,  "192.168.1.112", :primary => true # This is where Rails migrations will run
    role :db,  "192.168.1.112"

    default_run_options[:pty] = true

    namespace :deploy do
       task :start do ; end
       task :stop do ; end
       task :restart, :roles => :app, :except => { :no_release => true } do
         run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
       end

       desc "Installs required gems"
       task :gems, :roles => :app do
         run "cd #{current_path} && sudo rake gems:install RAILS_ENV=production"
       end
       after "deploy:setup", "deploy:gems"   

       before "deploy", "deploy:web:disable"
       after "deploy", "deploy:web:enable"
    end



Photo Set Member System

Photo Set Member System
I have a website that will offer photo sets for purchase. The photo sets cannot be downloaded but purchasing a photo set gives you access to that specific photo set for online viewing.

The folder structure is:
domain.com/members/category/model-name/name-of-photoset/

I want the user to be able to login, get a list over the sets he have paid for and view the sets online.

The content is of mature nature but not porn. I will use two well known credit card processing systems. The galleries and website are already finished, but I need a automated system for managing the login and what the user can have permission to view.

I Need Dailly 100 Page Views.

I Need Dailly 100 Page Views.
Hello programmers,
I am new to this freelancing site. I used some other methods to get work from other persons. This is my first time that i have put one of my project on public place.

Ok I need a Person who knows how to drive traffic to the website without any black hat technique.

I have such blogs.
See them.
http://searchtamilactressfree.blogspot.com/
http://search-live-tamil-videos.blogspot.com/
http://online-aptitude-test.blogspot.com/
http://bolywood-stuff-videos.blogspot.com/
http://live-stream-videos-india.blogspot.com/
http://watch-ipl-streaming-live.blogspot.com/

I want any of them dailly 100 page views for next 1 month.

Payment will be through Paypal.

If you can get this i will give you more work.
If i will satisfy from your work and your performance i will give you more money as well as a work.

So please bid on it.
I need to check everything about that links before bidding.

I don’t need any excuses after selection.

So please write “I read everything” in your PM to me.
Thank you.

Regards.

Sam.

Copy Site Adult

Copy Site Adult
I need someone to copy a site for me. I of course want the elements and such they have on their site copied, I would want my own text, images, links, content put on the site though. But I want you to base my site on what they have on theirs. What you do must be SEO friendly. IF you don’t know any SEO techniques for designing a site, do not bid.

PM so I can show you the site.
READ THIS PLEASE:
DO NOT BID, until I have sent you PM back.
DO NOT SEND ME SOME BORING LIST OF 100 SITE YOU SAY YOU WORKED ON.
DO NOT SEND ME YOUR FORM RESPONSE

DO Send 5-10 sites that you have worked on, that is all.
Thanks!

Tube Site Need Troubleshooting

Tube Site Need Troubleshooting
Hello,

I have two sites that need some troubleshooting done. First off, they are adult sites with adult videos so those who are comfortable with working with adult sites should PM me or bid.

These sites run off of an Adult Video Script (AVS). Those who have worked with this script or know their way around this script would be appreciated.

The problems I am having is the site doesn’t play videos. I believe it is a FFMPEG error but I am not sure how to fix it. Also, thumbnails will not generate and I have over 10k videos that are missing thumbnails. I would like videos to start playing again and the thumbnails to show and generate when a user uploads.

If you can troubleshoot and fix these problems, I have many more items that need to be done on my list.

Thank you.

Website Misc Tasks 2

Website Misc Tasks 2
I have an existing design that needs modifications and additons as listed below.

1)Three images within top section need to be fed by a folder – Javascript random to pull up 3 random images each time. This script will look into a directory and pull in 3 random images that are not the same as each other each time a page is loaded.

2)Take an existing WordPress theme and replace the top navigation with the top navigation from design (from top all the way down to the images) then have the blog section beneath this.

3) Left navigation of the site needs a little bit of jazzing up to make it look better

Kick Ass Website Background

Kick Ass Website Background
My Site: http://bioprotege-inc.sytes.net/Roleplay_Realm

Site Info: Make of Simple Ajax, php, and html coding.

I need a kick ass website background on my site to match my site look and feel.

not sure what bg im really looking for but just to match the theme look and feel of my site that i created because i cant make good looking backgrounds

id like you to post your idea(s) in pm to help me choose a proggramer to do the project better

if i had an example of a bg kind of theme it would be more around the site and not all over the site like one thats like a suit on the template that only kinda flows around the sides of the site like 100-200px per side and goes down to only a certain height

Note: the banner and ad space both have transparence under it its a transparent png file so i dont want the bg to say go underneith the site but like on the sides of the site and if it goes on top maybe 5px on the top since the template is absolute 10 px from the top of each browser.

if i had an example of something like what im looking to achive it would be like:http://www.webdesignerwall.com/ where the bg is around it but not the entire bg just like a cover on the template.

Site Upgrade Php+fix

Site Upgrade Php+fix
I need a way of updating my header, footer, menu etc. using the include statement I would like for the site to load fast and errorlessly in all browsers. I also have a problem with the admin panel that I can explain in detail:

my filter control updates a db,and it changes info on 3 pages/forms.it is not updating properly. and I need some help.
this stoped working when I had a site built that conects to the db. I can explain more later.

Help With Centos Server Move

Help With Centos Server Move
Hi there, thanks for looking at our project! PLEASE, do not bid unless you have read all of it … thanks.

We are looking for someone with lots of experience configuring CentOS / Apache servers. Here are the specifics:

My company has an auto classifieds website which runs out of a VPS (virtual private server) at a hosting company. We are moving our site to a dedicated server at the same company.

Although the hosting company’s staff has been helpful, the move has been tricky because:

– Our VPS contains 75+ scripts (mostly PHP, with some perl) which were developed by many different programmers over the last 10 years.

– Our VPS has many modules which these scripts require (netpbm, swftools, JRE, imagemagick, flex, html::tableextract, etc.)

– Because it’s not possible to simply “mirror” a VPS into a dedicated server, our hosting company has tried to build a dedicated server with the same “specs” as the VPS. However, because our VPS was imaged years ago, on the new server they have in some cases substituted newer versions of the modules that we use. This may be causing compatibiilty issues or even just things like different paths.

– The permissions on the files and directories are not all the same on the new dedicated server.

What we need is someone who is very experienced at this kind of thing, who will work with us to test, evaluate, and make sure that all scripts are working properly on the new server. Right now, about 60 of the 75 scripts are working fine on the new server, and 15 or so are having problems. All scripts work fine on the current (VPS) server.

I understand that this is a vague project description. I’m hoping that this will only take a day or two to sort out. If it turns out to take longer, we will adjust the payment accordingly.

In addition, if you can help us to get this done quickly and effectively, we may have further similar projects for you in the near future.

Thanks and we look forward to working with you.