Add a scroll top button to your site

Html

JavaScript


  $(function(){
    $(document).on( 'scroll', function(){
      if ($(window).scrollTop() > 100) {
        $('.scroll-top-wrapper').addClass('show');
      } else {
        $('.scroll-top-wrapper').removeClass('show');
      }
    });
    $('.scroll-top-wrapper').on('click', scrollToTop);
  });

  function scrollToTop() {
    verticalOffset = typeof(verticalOffset) != 'undefined' ? verticalOffset : 0;
    element = $('body');
    offset = element.offset();
    offsetTop = offset.top;
    $('html, body').animate({scrollTop: offsetTop}, 500, 'linear');
  }

CSS

<style type="text/css">
  .scroll-top-wrapper {
    position: fixed;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    text-align: center;
    z-index: 99999999;
    background-color: #777777;
    color: #eeeeee;
    width: 50px;
    height: 48px;
    line-height: 48px;
    right: 30px;
    bottom: 30px;
    padding-top: 2px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    border-bottom-left-radius: 10px;
    -webkit-transition: all 0.5s ease-in-out;
    -moz-transition: all 0.5s ease-in-out;
    -ms-transition: all 0.5s ease-in-out;
    -o-transition: all 0.5s ease-in-out;
    transition: all 0.5s ease-in-out;
  }
  .scroll-top-wrapper:hover {
    background-color: #888888;
  }
  .scroll-top-wrapper.show {
    visibility:visible;
    cursor:pointer;
    opacity: 1.0;
  }
  .scroll-top-wrapper i.fa {
    line-height: inherit;
  }
</style>

Reference

http://www.webtipblog.com/adding-scroll-top-button-website/

A post json sample with PHP

Code:

<?php

$data = '{
  "user": "1234567890"
}';

//$data = '{}';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://my-awesome-app.com/api/login" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_POST,           true);
curl_setopt($ch, CURLOPT_POSTFIELDS,     $data );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json; Data-Version: 15;INU_X_APPLICATION_PLATFORM: iOS;charset=utf-8'));

$result=curl_exec($ch);

echo $result;

?>

How To Use Capistrano to Automate Deployments

DigitalOcean

Tealeaf

sitepoint

Beanstalk

Make a gem and release it

Install Bundler

$ gem install bundler

Create gem package

$ bundle gem gem_sample_ruby
or
$ bundle gem gem_sample_ruby -b -t
# -b: commands -t: test code

Add runtime dependency

$ cd gem_sample_ruby && vim gem_sample_ruby/gem_sample_ruby.gemspec
Gem::Specification.new do |spec|
  ... something ...

  spec.add_runtime_dependency 'nokogiri'
  spec.add_runtime_dependency 'json', '>= 1.7.3'
end

Bundle install

$ bundle install --path .bundle

Write the true code

$ vim lib/gem_sample_ruby.rb
require "gem_sample_ruby/version"

module GemSampleRuby
  def self.hello_ruby
    p "hello ruby"
  end
end

Run rake task

$ rake -T      # See all rake commands
$ rake build   # Build gem_sample_ruby-0.0.1.gem into the pkg derectory
$ rake install # Build and install gem_sample_ruby-0.0.1.gem into system gems

Use gem

$ cd .. && vim use_gem_sample_ruby.rb
require 'gem_sample_ruby'

puts GemSampleRuby.hello_ruby

$ ruby use_gem_sample_ruby.rb
hello ruby

Commit gem with git

$ cd gem_sample_ruby && git init
$ git add .
$ git commit -m "Version 0.0.1"
$ git remote add origin https://github.com/[your_github_username]/gem_sample_ruby.git
$ git push -u origin master

Release gem

$ curl -u [your_rubygems_username] https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
$ chmod 600 ~/.gem/credentials
$ ls -l ~/.gem/credentials

$ rake release # Create tag v0.0.1 and build and push gem_sample_ruby-0.0.1.gem to Rubygems

or

$ gem build gem_sample_ruby.gemspec
$ gem push gem_sample_ruby-0.0.1.gem

Check your gem

http://www.rubygems.org/gems/gem_sample_ruby

Reference