Thursday, January 5, 2017

Segrigate css js and html in rails

It is always easy to work when every asset is segregated from other. But in normal practice we write js in our html template files. Another mistake we bind our js events on ids, css classes which should not be there, by looking the htmlit will confuse you why you use the css property to give style  or to give js functionality. Best practice is to use data property of the element.

<%= link_to "Update Credit Card", "#", data: { behavior: "update-credit-card" } %>
 
and bind the js event on data
 
$(document).on("click", "[data-behavior~=update-credit-card]", function(){
  // code
 
}) 
 
our body tag should looks like
 
class="<%= controller_name %> <%= action_name %>">
  <%= yield %>
</body>
 
because by doing this we can write css on controller basis and for more specific we can take action help as well.

Tuesday, December 27, 2016

use of animate.css with callback function

I need to integrate the animate.css in rails 5 project. Well its pretty straight forward to integrate, I used gem animate.css-rails. I also require a callback when animation is done for this I need to write a javascript function.

var animateCss = function (element, animationName, callback) {
    var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
    element.addClass('animated ' + animationName).one(animationEnd, function () {
        element.removeClass('animated ' + animationName);
        if (typeof(callback) == 'function') {
            callback();
        }
    });
}
 
 
 
 

Sunday, November 27, 2016

Overriding the devise default routes

I need to integrate devise gem in Rails5.0 application. It works flawless but the client requirements were he wants the urls  in very user friendly way like sign-in for users/sessions/new and more.

I override the routes in my routes.rb file to meet client requirements but as a result of it there were a lot of routes also there in the application which comes from the devise which we don't want. i made some changes and my routes.rb looks like

devise_for :users, :controllers => {registrations: 'registrations'}, 
:skip => [:sessions, :passwords, :registrations, :confirmations]
 

devise_scope :user do
  get 'sign-up' => 'devise/registrations#new', :as => :new_registration
  post "/sign-up" => "registrations#create"
  get '/forgot-password' => "devise/passwords#new", :as => :new_user_password
  post '/forgot-password' => "devise/passwords#create"
  get '/reset-password' => "devise/passwords#edit", as: :edit_user_password
  post '/reset-password' => "devise/passwords#create", as: :user_password
  put '/reset-password' => 'devise/passwords#update', as: :user_password_update
 
  post '/confirmation' => "devise/confirmations#create", :as => :user_confirmation
  get '/resend-confirmation' => "devise/confirmations#new", :as => :new_user_confirmation
  get '/confirmation' => "devise/confirmations#show", :as => :user_confirmation_show
  get '/my-profile' => "devise/registrations#edit", :as => :my_profile_edit
 
  get 'sign-in' => 'devise/sessions#new', :as => :new_user_session
  post 'sign-in' => 'devise/sessions#create', :as => :user_session
  delete 'sign-out' => 'devise/sessions#destroy', :as => :destroy_user_session
end

Friday, August 26, 2016

Shallow copy and Deep copy javascript object using native or underscore.js

Unfortunately there is no method in javascript to clone a javascript object. So if you do something like

a = {key: 'value'}
b = a

Internally in javascript the reference of the object is store in variable copied to b so both variable pointing to the same object.

Underscore.js provide clone method which shallow copy the object. so if i do something like

a = {key: 'value'}
b = _.clone(a)

Both a and b variable have different references.

As underscore.js clone method does shallow copy, objects inside the variable a and b remains same. so if i do something like

a = {key: 'value', key2: {key3: 'value2'}}
b = _.clone(a)

Both variables have different references but the key2 still have the same reference. So if i do any activity on key2 it will affect both objects.

Now my requirement is to have a deep copy rather than shallow copy. To achieve this i use the power of JSON. so if i do something like

a = {key: 'value', key2: {key3: 'value2'}}
b = JSON.parse(JSON.stringify(a))

Now both variables having different references and object is deep copied.

Monday, June 20, 2016

firebase user authentication

Most applications need to know the identity of a user. Knowing a user's identity allows an app to provide a customized experience and grant them permissions to access their data. The process of proving a user's identity is called authentication. Firebase provides a full set of authentication options out-of-the-box.
When a user authenticates to a Firebase app, three things happen:
  • Information about the user is returned in callbacks on the client device. This allows you to customize your app's user experience for that specific user.
  • The user information returned contains a uid (a unique ID), which is guaranteed to be distinct across all providers, and to never change for a specific authenticated user.
  • The value of the auth variable in your app's Security and Firebase Rules becomes defined. This variable isnull for unauthenticated users, but for authenticated users it is an object containing the user's unique (auth.uid) and potentially other data about the user. This allows you to securely control data access on a per-user basis.

Friday, June 3, 2016

Make current user available through out the ionic2 application

Like every application which have login system in it you have a lot of features available for the user. like if login user is admin then navigation options will change. Along with these there are many situations where you need the current login user like comment feature. So i have pass or fetch from local storage every time i require current login user. I have a different approach login user should be a static variable which is available through out the application.

export class Singleton {
  private static _instance;
  public static get instance() {
    class current_user{
       public login_user: User; 
       public menu_option: Array<{title: string, component: any, icon: string}>;

       retrive_user_from_local_storage(){
        // code to set the current user from local storage.
      }

      populate_menu(){
      // code to populate the menu depending upon the login_user_type.
      }
   }
   if(!Singleton._instance) {
            Singleton._instance = new current_user();
        }

        return Singleton._instance;
    }
 }
}

Now i just have to import file the above file where i require the current user like

import {Singleton} from '../../lib/singleton';

export class BusinessDetail {
  
private singletonObject = Singleton.instance;
//rest code.
}





Friday, May 13, 2016

Cors issue and its relationship with http options verb (preflight check)

First lets understand cors:

A resource makes a cross-origin HTTP request when it requests a resource from a different domain than the one which the first resource itself serves. For example, an HTML page served from http://domain-a.com makes an <img> src request for http://domain-b.com/image.jpg. Many pages on the web today load resources like CSS stylesheets, images and scripts from separate domains.

Http verb OPTION:

The OPTIONS verb is a preflight request sent by some browsers to check the validity of cross origin requests. It pretty much checks with the server that the Origin(requester) is allowed to make the request for a specified resource. Also, depending on which headers are sent back by the server it lets the browser know which headers, methods, and resources the origin is allowed to request form the server.
The browser sends the OPTIONS request then if the server answers back with the correct headers (CORS headers) allowing the origin to make the request, you should see your POST request go through afterwards.
for more info go
There are multiple way we can fix the cors issue, a detail documentation is available here

Friday, May 6, 2016

ngModel in angular2



The punctuation in the binding syntax, [()], is a good clue to what's going on.

In a Property Binding, a value flows from the model to a target property on screen. We identify that target property by surrounding its name in brackets, []. This is a one-way data binding from the model to the view.

In an Event Binding, we flow the value from the target property on screen to the model. We identify that target property by surrounding its name in parentheses, (). This is a one-way data binding in the opposite direction from the view to the model.

No wonder Angular chose to combine the punctuation as [()] to signify a two-way data binding and a flow of data in both directions.

In fact, we can break the NgModel binding into its two separate modes as we do in this example of the "Name"

<input type="text" class="form-control" required
[ngModel]="model.name"
(ngModelChange)="model.name = $event" >
TODO: remove this: {{model.name}}

The Property Binding should feel familiar. The Event Binding might seem strange.

The ngModelChange is not an <input /> element event. It is actually an event property of the NgModel directive. When Angular sees a binding target in the form [(x)], it expects the x directive to have an x input property and an xChange output property.
The other oddity is the template expression, model.name = $event. We're used to seeing an $event object coming from a DOM event. The ngModelChange property doesn't produce a DOM event; it's an Angular EventEmitter property that returns the input box value when it fires — which is precisely what we should assign to the model's name property.

We almost always prefer [(ngModel)]. We might split the binding if we had to do something special in the event handling.

Monday, April 4, 2016

Data types in type script

For programs to be useful, we need to be able to work with some of the simplest units of data: numbers, strings, structures, boolean values, and the like. In TypeScript, we support much the same types as you would expected in JavaScript, with a convenient enumeration type thrown in to help things along.

Boolean

The most basic datatype is the simple true/false value, which JavaScript and TypeScript call a boolean value.
let isDone: boolean = false;

Number

As in JavaScript, all numbers in TypeScript are floating point values. These floating point numbers get the type number. In addition to hexadecimal and decimal literals, TypeScript also supports binary and octal literals introduced in ECMAScript 2015.
let decimal: number = 6;
let hex: number = 0xf00d;
let binary: number = 0b1010;
let octal: number = 0o744;

String

Another fundamental part of creating programs in JavaScript for webpages and servers alike is working with textual data. As in other languages, we use the type string to refer to these textual datatypes. Just like JavaScript, TypeScript also uses the double quote (") or single quote (') to surround string data.
let name: string = "bob";
name = 'smith';
You can also use template strings, which can span multiple lines and have embedded expressions. These strings are surrounded by the backtick/backquote (`) character, and embedded expressions are of the form ${ expr }
let name: string = `Gene`;
let age: number = 37;
let sentence: string = `Hello, my name is ${ name }.

I'll be ${ age + 1 } years old next month.`
This is equivalent to declaring sentence like so:
let sentence: string = "Hello, my name is " + name + ".\n\n" +
    "I'll be " + (age + 1) + " years old next month."

Array

TypeScript, like JavaScript, allows you to work with arrays of values. Array types can be written in one of two ways. In the first, you use the type of the elements followed by [] to denote an array of that element type:
let list: number[] = [1, 2, 3];
The second way uses a generic array type, Array:
let list: Array<number> = [1, 2, 3];

Tuple

Tuple types allow you to express an array where the type of a fixed number of elements is known, but need not be the same. For example, you may want to represent a value as a pair of a string and a number:
// Declare a tuple type
let x: [string, number];
// Initialize it
x = ['hello', 10]; // OK
// Initialize it incorrectly
x = [10, 'hello']; // Error
When accessing an element with a known index, the correct type is retrieved:
console.log(x[0].substr(1)); // OK
console.log(x[1].substr(1)); // Error, 'number' does not have 'substr'
When accessing an element outside the set of known indices, a union type is used instead:
x[3] = 'world'; // OK, string can be assigned to (string | number)

console.log(x[5].toString()); // OK, 'string' and 'number' both have toString

x[6] = true; // Error, boolean isn't (string | number)
Union types are an advanced topic that we’ll cover in a later chapter.

Enum

A helpful addition to the standard set of datatypes from JavaScript is the enum. As in languages like C#, an enum is a way of giving more friendly names to sets of numeric values.
enum Color {Red, Green, Blue};
let c: Color = Color.Green;
By default, enums begin numbering their members starting at 0. You can change this by manually setting the value of one of its members. For example, we can start the previous example at 1 instead of 0:
enum Color {Red = 1, Green, Blue};
let c: Color = Color.Green;
Or, even manually set all the values in the enum:
enum Color {Red = 1, Green = 2, Blue = 4};
let c: Color = Color.Green;
A handy feature of enums is that you can also go from a numeric value to the name of that value in the enum. For example, if we had the value 2 but weren’t sure what that mapped to in the Color enum above, we could look up the corresponding name:
enum Color {Red = 1, Green, Blue};
let colorName: string = Color[2];

alert(colorName);

Any

We may need to describe the type of variables that we do not know when we are writing an application. These values may come from dynamic content, e.g. from the user or a 3rd party library. In these cases, we want to opt-out of type-checking and let the values pass through compile-time checks. To do so, we label these with the any type:
let notSure: any = 4;
notSure = "maybe a string instead";
notSure = false; // okay, definitely a boolean
The any type is a powerful way to work with existing JavaScript, allowing you to gradually opt-in and opt-out of type-checking during compilation. You might expect Object to play a similar role, as it does in other languages. But variables of type Object only allow you to assign any value to them – you can’t call arbitrary methods on them, even ones that actually exist:
let notSure: any = 4;
notSure.ifItExists(); // okay, ifItExists might exist at runtime
notSure.toFixed(); // okay, toFixed exists (but the compiler doesn't check)

let prettySure: Object = 4;
prettySure.toFixed(); // Error: Property 'toFixed' doesn't exist on type 'Object'.
The any type is also handy if you know some part of the type, but perhaps not all of it. For example, you may have an array but the array has a mix of different types:
let list: any[] = [1, true, "free"];

list[1] = 100;

Void

void is a little like the opposite of any: the absence of having any type at all. You may commonly see this as the return type of functions that do not return a value:
function warnUser(): void {
    alert("This is my warning message");
}
Declaring variables of type void is not useful because you can only assign undefined or null to them:
let unusable: void = undefined;

Type assertions

Sometimes you’ll end up in a situation where you’ll know more about a value than TypeScript does. Usually this will happen when you know the type of some entity could be more specific than its current type.
Type assertions are a way to tell the compiler “trust me, I know what I’m doing.” A type assertion is like a type cast in other languages, but performs no special checking or restructuring of data. It has has no runtime impact, and is used purely by the compiler. TypeScript assumes that you, the programmer, have performed any special checks that you need.
Type assertions have two forms. One is the “angle-bracket” syntax:
let someValue: any = "this is a string";

let strLength: number = (<string>someValue).length;
And the other is the as-syntax:
let someValue: any = "this is a string";

let strLength: number = (someValue as string).length;
The two samples are equivalent. Using one over the other is mostly a choice of preference; however, when using TypeScript with JSX, only as-style assertions are allowed.

A note about let

You may’ve noticed that so far, we’ve been using the let keyword instead of JavaScript’s var keyword which you might be more familiar with. The let keyword is actually a newer JavaScript construct that TypeScript makes available. We’ll discuss the details later, but many common problems in JavaScript are alleviated by using let, so you should use it instead of var whenever possible.

Saturday, November 21, 2015

Introduction of FOOTERLABS fun club in HEADERLABS

I have no doubt to state that start-ups are best place to work because they develop a NEVER GIVE UP attitude in you. In start-ups every morning new challenges are waiting for you. At the end of day you don't realize how time passes.

After all these happenings, in the end of day your mind got tired and you require some refreshment for it. Some like music, reading but i personally like sports. So i talked with some of my colleagues to start a sports in the evening. I am stun by the response everyone says LETS DO IT. On the same day we finalize the everything and give the name FOOTERLABS(because game is all about the movement of foot).

First problem is which sports and where. we decided Badminton and in GMC (Municipal Corporation of Gurgoan) park in front of our office building. We put light, mark the ground and now we are playing for around 2 hrs and we all the completely refresh for more work.

We are planing to organize single and double player tournament every month to keep our motto up.

Sports are best thing to keep to stay fit, healthy, active. In last i would like to state that don't think too much and as nike logo says JUST DO IT.

Friday, October 30, 2015

Filepicker.io run the sucess function twice

I am using filepicker.io to upload the file in my rails application. What i am doing is first upload the file to s3 using filepicker.io, after successfully upload post the data to my server. i Am doing all these by binding a click event through jquery.

$('a.upload_file').off('click').on('click', function (event) {
     filepicker.setKey('MY FILEPICKER KEY');
     filepicker.pickAndStore({extensions: '.pdf'},
            {location: 'S3'},
            function (uploadedObjects) {
                // send request to server 
            },
            function (FPError) {
                console.log(FPError.toString());
            }
        );
    })
 
 
As in rails turbolink comes into picture which not request for javascript.
i will start calling the pickandstore function twice.
 
what i did wasremove the set key from the function it fix the issue. 

Tuesday, May 26, 2015

irb introduction

Interactive Ruby or irb is an interactive programming environment that comes with Ruby. 

Usage Syntax:

To invoke it, type irb at a shell or command prompt, and begin entering Ruby statements and expressions. Use exit or quit to exit irb.

$ irb[.rb] [options] [programfile] [arguments]

Here is a complete list of options:

-f                              Suppress reading of the file ~/.irbrc.
-m                             bc mode (load mathn library so fractions or matrix are available).
-d                              Set $DEBUG to true (same as ruby -d).
-r                               load-module Same as ruby -r.
-I                               path Specify $LOAD_PATH directory.
--inspect                   Use inspect for output (default except for bc mode).
--noinspect               Don't use inspect for output.
--readline                 Use Readline extension module.
--noreadline             Don't use Readline extension module.
--prompt                   prompt-mode (--prompt-mode prompt-mode) Switch prompt mode.

                                 Predefined prompt modes are default, simple, xmp, and inf-ruby.
--inf-ruby-mode         Use prompt appropriate for inf-ruby-mode on Emacs. Suppresses --readline.
--simple-prompt        Simple prompt mode.
--noprompt                No prompt mode.
--tracer                      Display trace for each execution of commands.
--back-trace-limit n    Display backtrace top n and tail n. The default value is 16.
--irb_debug n             Set internal debug level to n (not for popular use).
-v(--version).             Print the version of irb.




































Friday, April 24, 2015

Basics before writing a jquery plugin


Jquery Basics


Take a look at this code:  

$( "a" ).css( "color", "red" );

This is some pretty basic jQuery code, but do you know what's happening behind the scenes? Whenever you use the $ function to select elements,
it returns a jQuery object. This object contains all of the methods you've been using (.css(), .click(), etc.) and all of the elements that fit your selector.
The jQuery object gets these methods from the $.fn object. This object contains all of the jQuery object methods, and if we want to write our own methods, it will need to contain those as well.


Write your first jquery plugin


Let's say we want to create a plugin that makes text within a set of retrieved elements green. All we have to do is add a function called greenify to $.fn and it will be available just like any other jQuery object method.

$.fn.greenify = function() {

    this.css( "color", "green" );

};

$( "a" ).greenify(); // Makes all the links green.



Notice that to use .css(), another method, we use this, not $( this ).
This is because our greenify function is a part of the same object as .css().

for more detail refer JQUERY

Friday, February 6, 2015

Intercom.io with Rails

My rails project requirement to provide the support to end users, so that we can do the communication with end users in real time. I also wants to track the active users and slipping users and also want ask feedback.

So i decided to integrate intercom.io. It is paid service but i want to launch my site as soon as possible and track and communicate with my customers, take their inputs to improve my product.

Integration of intercom is just a matter of 2 mins job in rail. you just have to intercom-rails gem and thats it.

Friday, January 30, 2015

Upload file directly to amazone s3 bucket using html and javascript

My requirements is to upload the assets to s3 bucket. One approach is to upload file to my server and then to amazon s3, but my application deals in big file in that case it blocks my process which i don't want. Second approach i can upload directly to amazon s3 bucket in this case i can save my asset block.

I work on rails so code snippet reflects ruby but its an easy you can do in any language

Variables

AWS-BUCKET-NAME - name of the bucket in which you want to upload.
AWSAccessKeyId - Aws access key of your account.
PATH - where you want to upload file(its your logic to generate dynamic value, i used ruby SecureRandom.uuid).
REDIRECTPATH - where amazon sends the response with uploaded file path and bucket name.
Policy - it is base64 encoded policy i will explain later.
Signature - it is base64 encoded signature

HTML Code for form

AWS-BUCKET-NAME
.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
  PATH">
  AWSAccessKeyId">
 
  REDIRECTPATH">
  Policy
">
  Signature">
 
 

  File to upload to S3:
 
 

 

Policy - it a base64 encoded string which contain the policy. Policy just nothing but the cross verification of the form field value(other than AWSAccessKeyId, policy and signature fields). you 3 options starts_with, exact match and range

sample policy is
example(Its ruby code but you can easy understand it) :-
def generate_encoded_policy
policy_document = {expiration: "2029-01-01T00:00:00Z",
        conditions: [
        {bucket:
AWS-BUCKET-NAME},
        ["starts-with", "$key", key_base_name],
        {acl: "private"},
        {success_action_redirect:
REDIRECTPATH},
        ["starts-with", "$Content-Type", "application/pdf"],
        ["content-length-range", 0, 104857600]
    ]
    }.to_json

    Base64.encode64(policy_document).gsub("\n","")

end 

it is a ruby function which return me the BASE64 encoded string

Signature - It is also the base64 encoded signature
example:-
def generate_signature
       Base64.encode64(
        OpenSSL::HMAC.digest(
            OpenSSL::Digest::Digest.new('sha1'),
            AWSSECRETKEY, generate_encoded_policy)
    ).gsub("\n","")
  end


for more detail refer http://aws.amazon.com/articles/1434

Friday, December 19, 2014

Create service in ubuntu to run ruby script

My Project requirement to continuously run a ruby script to do some stuff. I achieved it with nohup. If the some exception comes in my script is stop so decide to run it as a service and if service stops it should start again. 

sudo touch /etc/init/service_name.conf

Add these line to the file

description "test service by sachin choudhary"
author "sachin choudhary "


# When to start the service
start on runlevel [2345]

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
respawn

# Essentially lets upstart know the process will detach itself to the background
# This option does not seem to be of great importance, so it does not need to be set.
#expect fork

# Specify working directory , where your script file
chdir /home/sachin/Desktop/service

# Specify the process/command to start, e.g.
exec /home/sachin/.rvm/rubies/ruby-2.1.5/bin/ruby test.rb


And you all done :-)

NOTE:- For Ruby guys if you are using rvm and your script might require some gems, then your required gems must be installed in rvm global set else your script not load them.

Friday, November 14, 2014

Do maximum use of ri

ri is a tool that ships with Ruby. It's a companion to rdoc, allowing you to 'display information about Ruby classes, modules, and methods' from your console.

It give benefits like:
  • More Accurate results :-
    type ri new
    It will return you the list of new methods in the installed.
  • Interactive response :-
    type ri -i
    it gives you the auto complete feature.
  • Gives you more details about the class.
    start ri -i
    type String
    It will show you the detail structure including parent class, modules and who all extend it.
 If you are using rvm you have to generate ri documentation first by
rvm docs generate all

Friday, September 5, 2014

Git working, staged and commit states

There are 3 different stages in git. Detail about each stage as follows :-
  • Working :- This is the stage where all the changed files persists.
    change a file and type git status command it will show you the file as unstaged.
  • Staged :- This is the stages where the files will be surely committed in the next commit. Change some files and type command git status it will show you files in unstaged area. now type git add --all. This command will change the area of the files from working to staged. you can see by typing command git status.
  • Commit :- This is the area where files are in committed state.

Friday, July 25, 2014

Why we have to apply self to call setter method for ruby class object

class Test
  attr_accessor :name

  def set_name
    name = "some name"
  end
end

obj = Test.new
obj.set_name
obj.name  #=> nil

Why? i am calling the setter method which is already defined by attr_accessor from the method. Here the preferences comes into picture. Inside a method local variable is given more preference then to call the method, Ruby interpreter treats name as local variable. If you apply self before the method name you are specifying the interpreter to call the method.

class Test
  attr_accessor :name

  def set_name
    self.name = "some name"
  end
end

obj = Test.new
obj.set_name
obj.name #=> "some name"

Friday, June 13, 2014

Download file from Amazon S3 without ruby-sdk

Today my project requirement is to download big file from Amazone S3 bucket. I am using the ruby gem (aws-sdk). This gem provide the read method for S3 object. The disadvantage of this method is it loads the entire file in memory, and you will run short of memory. My project deals in big files so this solution doesn't works for me.

After some google i found that Amazone also provide command line utility s3cmd for s3. You can setup your IAM user account by

s3cmd --configure

It will setup Amazon S3


For s3cmd options type

s3cmd --help

Make bucket
      s3cmd mb s3://BUCKET
  Remove bucket
      s3cmd rb s3://BUCKET
  List objects or buckets
      s3cmd ls [s3://BUCKET[/PREFIX]]
  List all object in all buckets
      s3cmd la
  Put file into bucket
      s3cmd put FILE [FILE...] s3://BUCKET[/PREFIX]
  Get file from bucket
      s3cmd get s3://BUCKET/OBJECT LOCAL_FILE
  Delete file from bucket
      s3cmd del s3://BUCKET/OBJECT
  Synchronize a directory tree to S3
      s3cmd sync LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR
  Disk usage by buckets
      s3cmd du [s3://BUCKET[/PREFIX]]
  Get various information about Buckets or Files
      s3cmd info s3://BUCKET[/OBJECT]
  Copy object
      s3cmd cp s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2]
  Move object
      s3cmd mv s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2]
  Modify Access control list for Bucket or Files
      s3cmd setacl s3://BUCKET[/OBJECT]
  Enable/disable bucket access logging
      s3cmd accesslog s3://BUCKET
  Sign arbitrary string using the secret key
      s3cmd sign STRING-TO-SIGN
  Fix invalid file names in a bucket
      s3cmd fixbucket s3://BUCKET[/PREFIX]
  Create Website from bucket
      s3cmd ws-create s3://BUCKET
  Delete Website
      s3cmd ws-delete s3://BUCKET
  Info about Website
      s3cmd ws-info s3://BUCKET
  List CloudFront distribution points
      s3cmd cflist
  Display CloudFront distribution point parameters
      s3cmd cfinfo [cf://DIST_ID]
  Create CloudFront distribution point
      s3cmd cfcreate s3://BUCKET
  Delete CloudFront distribution point
      s3cmd cfdelete cf://DIST_ID
  Change CloudFront distribution point parameters
      s3cmd cfmodify cf://DIST_ID
  Display CloudFront invalidation request(s) status
      s3cmd cfinvalinfo cf://DIST_ID[/INVAL_ID]