Client-server pattern

This pattern consists of two parties; a server and multiple clients. The server component will provide services to multiple client components. Clients request services from the server and the server provides relevant services to those clients. Furthermore, the server continues to listen to client requests.

Usage
Online applications such as email, document sharing and banking.

Python and requirements.txt

Why requirements.txt?

Any application typically has a set of dependencies that are required for that application to work. The requirements file is a way to specify and install specific set of package dependencies at once.

Format for requirements file:

requests==1.2.0
Flask==0.10.1

Method 1:

$ pip freeze > requirements.txt

Use pip’s freeze command to generate a requirements.txt file for your project: If you save this in requirements.txt, then you can pip install -r requirements.txt.

Method 2:

Use pipreqs – pipreqs used to generate requirements.txt file for any project based on imports

Why not pip freeze ?
pip freeze saves all packages in the environment including those that you don’t use in your current project. (if you don’t have virtualenv)
pip freeze only saves the packages that are installed with pip install in your environment.
sometimes you just need to create requirements.txt for a new project without installing modules.

How to use?

$ pip install pipreqs

$ pipreqs /path/to/project

for additional options see https://github.com/bndr/pipreqs

 

Google Code Prettify and WordPress plugin

Google Code Prettify enable syntax highlight to source code in HTML page. In WordPress you can use Simple Code Highlighter plugin.

To use the Google Code Prettify plugin, place your code within a <pre> text block, and then specify the class of the block as “prettyprint”.  To do this, switch to Text mode within the WordPress editor.

You can use pre tag and class=”prettyprint” attribute to your code

// your code here

Here are some examples:

Default

Many
lines
of
code

Default with line numbers

Many
lines
of
code

Java

class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Prints the string to the console.
    }
}

Python

class SchoolMember:
    '''Represents any school member.'''
    def __init__(self, name, age):
        self.name = name
        self.age = age
        print('(Initialized SchoolMember: {})'.format(self.name))

    def tell(self):
        '''Tell my details.'''
        print('Name:"{}" Age:"{}"'.format(self.name, self.age), end=" ")


class Teacher(SchoolMember):
    '''Represents a teacher.'''
    def __init__(self, name, age, salary):
        SchoolMember.__init__(self, name, age)
        self.salary = salary
        print('(Initialized Teacher: {})'.format(self.name))

    def tell(self):
        SchoolMember.tell(self)
        print('Salary: "{:d}"'.format(self.salary))


class Student(SchoolMember):
    '''Represents a student.'''
    def __init__(self, name, age, marks):
        SchoolMember.__init__(self, name, age)
        self.marks = marks
        print('(Initialized Student: {})'.format(self.name))

    def tell(self):
        SchoolMember.tell(self)
        print('Marks: "{:d}"'.format(self.marks))

t = Teacher('Mrs. Shrividya', 40, 30000)
s = Student('Swaroop', 25, 75)

# prints a blank line
print()

members = [t, s]
for member in members:
    # Works for both Teachers and Students
    member.tell()

Node.js

var http = require('http');

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World!');
}).listen(8080);

Git and Github with 3 simple rules

Before I go ahead and discuss the three simple rules for mastering Git and Github, please consider completing the following tasks:

And now, without much further ado, the three simple rules to master Git and Github while learning how to code…

  • Rule #1: Create a Git repository for every new project
  • Rule #2: Create a new branch for every new feature
  • Rule #3: Use Pull Requests to merge code to Master

Even if you are working on small and simple projects, and even if you are working alone, following those three rules every time you code will make you a Git and GitHub master user very quickly.

Rule #1: Create a Git repository for every new project
This first rule is quite straightforward, but making a habit out of it is very important. Every time you start working on something new — your portfolio, a learning project, a solution to a coding challenge, and so on — you should create a new Git repository and push it to GitHub.

Having a dedicated repo is the first step to being able to use version control for every line of code you write. Using version control is how you will work once you join a company and start working on real-world projects. Learn this early and make it a habit.

Quick Note: if using the terminal becomes a hassle and makes you less likely to use Git for all your projects, consider using the Github Desktop app.

Rule #2: Create a new branch for every new feature
Let’s say you are working on your portfolio and you want to build a new “Contact me” section/component. Create a dedicated branch for this new feature, give it a meaningful name (e.g. contact-me-section), and commit all the code to that specific branch.

If you don’t know what branches are, go back to the Github Flow reading that I recommended before.

Working with branches allows you and your team members to work on different features in a parallel way while keeping the specific code for each feature isolated from the rest. This makes it harder for unstable code to get merged into the main code base.

Even if you are the only person on your team, getting used to using feature branches will make the Github Flow process a breeze once you join a real job.

Rule #3: Use Pull Requests to merge code to Master
Every repository starts with a master branch by default. You should never push changes directly to the master branch. Instead, you should use feature branches as described above, and open a new Pull Request to merge the feature branch code with the master branch code.

In a real job, someone will look at your Pull Request and do a code review before approving it. GitHub will even run automated tests to your code and let you know if there is an issue with it. You will also be notified if there is any merge conflict between your code and the code in the master branch. This can happen, for example, if another developer pushed a change to the master branch that affects a file that you also modified.

After your code has been reviewed, tested, and approved, your reviewer will give you thumbs up for you to merge the Pull Request, or they will directly merge your pull request.

Even if you are working alone, get used to creating Pull Requests as a way to merge your changes to the master branch. This, by the way, is the basic workflow used by almost every open source project. If you ever contribute to one (you should!), understanding this three rules will make it really easy for you to get your contribution accepted without any problem.

If you are still confused, just start slow and keep the three rules in mind. Don’t try to think about “How” to do things yet and focus on “What” to do and “Why” it’s important for now.

Once the “What” and the “Why” are clear, you can figure out the “How” when the times comes to do things. Once you have repeated this process 2–3 times, it will become really easy and natural for you.

Managing Multiple Java Versions on Mac

Apple announced to remove Java Preferences app from Mac OS X http://support.apple.com/kb/HT5493. Let’s try to fix it. Generally, java applications will use the JAVA_HOME environment variable to pick a JDK.

To set to JDK 6

export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)

To set JDK 7

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)

To set JDK 8

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

Created aliases for my zsh

alias setjdk16='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)'
alias setjdk17='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
alias setjdk18='export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)'

You can also read Managing Multiple Java Versions on Mac using Jenv

Quais as vantagens do Wireless 5 GHz?

A tecnologia de conexão AC é o assunto do momento quando falamos em redes sem fio, mas neste artigo iremos focar na consolidação da frequência de 5GHz como uma tendência para os próximos anos. Para entender seus benefícios e suas desvantagens precisamos diferenciá-la da frequência mais comum nos dias de hoje.

A principal diferença entre as frequências sem fio de 2,4 GHz e 5 GHz diz respeito ao número de dispositivos por frequência. A 2,4 GHz sofre mais interferência que a 5 GHz. Isso ocorre por dois motivos: primeiro porque o velho padrão 11g utiliza apenas a frequência de 2,4 GHz, e esse é o padrão mais utilizado em escala global. Além disso, a 2,4 GHz tem menos opções de canal – apenas três – enquanto a 5 GHz apresenta 23 canais sem sobreposição. O segundo motivo é que muitos outros aparelhos “roubam” a frequência 2,4 GHz, como os fornos micro-ondas e telefones sem fio. Esses dispositivos criam um ruído que diminui ainda mais a velocidade das redes sem fio.

Matéria completa:
https://canaltech.com.br/telecom/quais-as-vantagens-do-wireless-5ghz-43799/

IBM Technical Rock Star

Hi Everyone

I want to share an award that I received. I was recognized as IBM Technical Rock Star.
IBM Technical Rock Star for Cloud Program invited IBMers with technical skills to subscribe, challenge and share their technical skills, and win prizes. The competing projects could vary from building apps, using social networking or doing a meetup for any of the IBM Cloud solutions in the program. The overall goal was to encourage widespread, worldwide adoption of IBM Cloud, SoftLayer, IBM Bluemix and its services like Data Services and DevOps, Linux on Power SDK, and Cloudant.

I was recognized as IBM Technical Rock Star twice. I received the second place in September and the third place in December.

The final of Technical Rock Star for Cloud Program results had very impressive numbers:

14.014 Social Profiles
286 Articles published
634 Meetup

I recored a presentation where I answered some questions about the Technical Rock Star program.

You can see presentation file  here [1] and the video  here [2] as well.

A tech guy as me to be recognized as Technical Rock Star is awesome [3].
I’m feeling like Rock Star.

Thank you

 

References

[1] http://www.slideshare.net/KleberCarvalho/ibm-trsklebercarvalhov3

[2] https://www.youtube.com/watch?v=ojvKQtbwfx8

[3] http://www.klebercarvalho.com/blog/2014/10/27/technical-rock-star/

Technical Rock Star

I have a proud to announce that I received a recognition as Technical Rock Star award for Cloud Computing.

 

The technical expertise that you shared this month is making an impact on the lives of developers around the world!! Your technical contributions encouraged developers to learn more, improve their skills, and achieve their goals faster.
You ROCKED it!! Expertise like yours shows that IBMers are superstars. This Gold Second Place Album is to recognize your achievement. Please print the attached certificate and share it with great pride.
We want to make sure you are seen as the expert that you are, by all IBMers, so please expect to be contacted by the Technical Rock Star team to capture your success story.
Thank you for participating in this month’s program. You are playing a critical role in the transformation of IBM! I encourage you to keep participating in this year long program! YOU make a difference.  WE SALUTE YOU!!!

The challenge was reach and engagement on social media to enhance and promote IBM’s Cloud thought leadership and get the word out about Cloud, IBM Bluemix and its services like Data Services.

Through my social networks (Twitter, Google+, Linkedin, Stack Overflow, my personal blog etc), I’ve shared resources that I’m reading such as webinars, blogs, tutorial, code samples, videos, books, papers, articles regarding Cloud computing. I tried share my experiences and insights to Developers, Architects Engineers and students.

Rather than receiving the award, I’m really very proud to receive the congratulations of several people at IBM that I admire.
They took a minute from the busy day to wish congrats to me. I appreciate it from the bottom of my heart.

A tech guy as me to be recognized as Technical Rock Star is awesome.
I’m feeling like Rock Star.

Thank you so much.