ezoic

Sunday, June 26, 2016

How to practically learn Python starting from zero: chapter one set up environment

Python is a computer programming language. It is concise and not difficult to learn. If you want to learn a programming language well, besides reading tutorials, you need to 1. practice (like some small problems in a book, or some projects) , because doing programming is like finishing a craft project, you can learn it almost only by doing some craft projects yourself. 2. read other ppl's code. You can have one github account and put your code their and read other ppl's code there.

To use Python, one needs to have a platform/ OS.  It can be linux, Mac, windows. My experience is that Linux is better or equal to Mac, and they are both better than windows. Mac itself has a linux  terminal which is a plus.

Why linux is better than Windows for Python?  When you are doing python programming, quite often, you need to install additional packages for your Python. If you do it on windows, it is usually some pain in ass especially when the installing package is not exe file, is a zip file, you need to download the file, put it into a suitable directory and go to cmd window etc. And it sometimes fails. But, if you have a linux system and you finish all the programming on your terminal, to install a python package is just a command line. If you do not have Linux, you can install one using the following method on your PC:

http://easyprog99.blogspot.com/2016/04/one-way-to-install-linux-on-your-pc.html

And then install Python on ubuntu:

http://heliumhq.com/docs/installing_python_2.7.5_on_ubuntu

Then install an editor, emacs, or vim on your ubuntu:

http://askubuntu.com/questions/297170/how-to-install-emacs-24-3-on-ubuntu


I think it will take less than 1 hour.

You can test it by writing a simple Python program:

type 'emacs hello.py' to open a file
type in a hello word program:


print 'Hello World!'

ctrl x, ctrl c to close the file, you will be asked if you need to save the change, type 'y'.

To run it, type 'python hello.py', then 'Hello World' will show on your linux screen



On windows, there are two IDE, I would recommend:

1. Anaconda. you can use Anaconda to install your Python packages.  And run your programming on Anaconda. Otherwise, you will face some pain.

http://easyprog99.blogspot.com/2016/04/how-to-install-python-zip-package-on.html


And under Anaconda, there is an IDE called Spyder. After you install Anaconda, you will see it on your computer. It has such logo:



One advantage of using Anaconda is that it usually won't cause problems when you try to install additional packages on your computer even when the firewall of your computer is on.

2. PyCharm.  PyCharm is an IDE developed by  JetBrains. That company has IDEs for C++, Java etc.


https://www.jetbrains.com/pycharm/download/#section=windows

PyCharm has two versions, professional and community versions. Community version is free. Professional version is not free.  But sometimes when the firewall of your computer is on, it will cause problems when installing additional packages on the PyCharm. 

Thursday, June 23, 2016

About this pointer in c++

this refers to the current object.
The keyword this identifies a special type of pointer. Suppose that you create an object named x of class A, and class A has a non-static member function f(). If you call the function x.f(), the keyword this in the body of f() stores the address of x.

http://stackoverflow.com/questions/16492736/what-is-the-this-pointer


Online IDE for different languages




http://www.tutorialspoint.com/compile_haskell_online.php


http://www.tutorialspoint.com/codingground.htm




Tuesday, June 21, 2016

This pointer in c++

geeks for geeks

http://www.geeksforgeeks.org/this-pointer-in-c/


What programming languages you need to learn

What programming languages you need to learn.

1. Learn one procedural language, like C

http://www.tutorialspoint.com/cprogramming/


2. Learn one OO language, like C++, Java, or even Python

http://www.tutorialspoint.com/cplusplus/cpp_classes_objects.htm

http://www.tutorialspoint.com/java/


http://www.tutorialspoint.com/python/

3. Learn one functional language like LISP, Haskell

https://en.wikipedia.org/wiki/Functional_programming

http://www.tutorialspoint.com/lisp/

http://learnyouahaskell.com/chapters



4. Learn one scientific research language like Matlab

http://www.tutorialspoint.com/matlab/



Basically programming languages can be divided into the above categories.


After you learn one from one  kind, it is easier to master a new one.


Tutorialspoint c++ tutorial is concise and good

http://www.tutorialspoint.com/cplusplus/

You can finish the chapters they list there quickly and get an impression of c++ language in a short time.

It is concise, can save you some time. 

They have c tutorials too:

http://www.tutorialspoint.com/cprogramming/




Friday, June 17, 2016

What you need to learn in order to become a programmer/programming analyst,chapter one

Chapter one: basics

This article is for those who want to change their direction on work. Those whose major was CS in undergraduate can skip the article.

You need to have some project experience, like some app you finish etc. It can be what you program yourself. And there are some paid projects on upwrok.com. You can try. They will probably ask you during interview.

 If your major is not CS/SE, and you plan to be a SWE. You need to learn basic algorithms, data structures, 1-2 programming languages, software engineering, database, operation system.

I listed the basic requirements below:

1. Algorithms and data structures:
you need to learn the features of all kinds of data structures, time and space complexity, places to use it, including map, list, tree, stack, queue.  A lot of companies like asking questions about hash, like expected complexity, collision, separate chaining, arraylist and linkedlist.

The complexity of all kinds of sorting algorithms, can write down the code for all kinds of sorting algorithms. Other algorithms include recursion, DP etc, you also need to learn. There are a lot of online course. After you finish them, you can drill through the leetcode. And then you can handle most of companies' interviews.

2. Programming languages
Java, C#, C++, python, javascript. You must learn one of them. And know the concepts and feature of objected oriented programming.

For Java, you need to learn, Abstraction, Encapsulation, Polymorphism, Inheritance. Interface and abstract class. Garbage collection. Multithreaded program, program synchronization,Exception handling

3. Software Engineering

Need to know design pattern, lifecycle, testing

4. Database
Can write basic SQL query. Understand the relational database. Schema, table, view, trigger. Normalization, denormalization, 3NF, BCNF, different joins, transactions, different isolation levels.

5. Operating system

Understand the basic concepts of Operating system.

difference between process and thread. Scheduler, paging, socket, what is deadlock, concurrency control, multi-threading, synchronization, DMA

6. Network

Not so many questions. TCP  and UDP. when you click a website, what happens.

7. Linux

Linux basic commands. git/svn etc.

How to connect Azure blob to Power BI

Connect data from Azure blob to Power BI is not that easy.  It takes some steps to get the real data there.

I will illustrate it with some pics:

1. Open a Power BI desktop, click get data=>MS Azure Blob Storage



2. It will lead you to a prompt, then put your storage name there:

3. click the storage you want to load, then click edit:


4. filter the table you want to load by clicking the drop-down:


5. left click the double-arrow besides the "Content":

5. Then the content of your data will show, click  "Close & Apply"  on the left upper corner:

6. You will go back to Power BI, click the grid icon,and your data will show. And then, you can analyze the data. 


I am using the newest version of Power BI here.

Thursday, June 16, 2016

Some fun tools on Mac/PC

There are some fun tools on Mac/PC which can help you on your studies, life and research.


1. Evernote:

https://evernote.com/

To download :

https://evernote.com/download/


It helps you to make notes of the papers you read etc. Here is a tutorial:


https://www.youtube.com/watch?v=fFFcOcKQG-Q




2. Type Setting tool

MS word, Latex

Latex is a science Type setting tool. You can type in complicated math formula using it.

To use it, you can download MikTex:

http://miktex.org/download


After installing it, you can type in some text to generate math formula:





 After press the green button, it will generate a Math formula PDF:







Here is a tutorial for it:

https://www.tug.org/twg/mactex/tutorials/ltxprimer-1.0.pdf


3.  Text read software:

Sometimes when we try to open some files with certain extension, and no such software installed, we need to use text read software like below:

Notepad++

https://notepad-plus-plus.org/


TextPad

https://www.textpad.com/

The above two are mainly for PC

For Mac, there are more:

http://formac.informer.com/textpad

TextWrangler etc. 

4. FastStone

http://www.faststone.org/

Can do the image capture etc

not free

5. UltraEdit

http://www.ultraedit.com/downloads/ultraedit_download.html

Good editor for excel, different programming etc

not free

6.  Atom

https://atom.io/

Free programming scripts editor, runner etc. 
















Monday, June 13, 2016

One article to summarize programming language, I hope so

One article to summarize programming language:

1. What is programming language:

Programming language is some command people write to let computer do something, like calculations etc. It can be complicated.

2. What basic things you need to know about a programming language

Since programming language is doing calculations, you need to know how a programming language does plus, minus, multiply, divide etc. And how it presents data which is called data structures. For example data structure of python has, list, tuple, dictionary (hash table for python). The mostly used data structure from me is dictionary, hash table.

Hash table is important. If you learn it, you can do some complicated data analysis.

https://en.wikipedia.org/wiki/Hash_table

Basically hash table associates some keys with some values.  When your data has a key, and it has a vector of values, and you need to use the vector of values on calculations, and still keep the association between the keys and the vectors of values, you need to use hash table.




Another thing about programming is the loop.

For example, if you want to traverse a list in python to do some calculations, and the list is very long, you need to use loops. An example:

a=[1,2,5,3,4,6,7,8]
b=[2,3,5,6,7,8,9,9]
for i in range(len(a)):
      t=a[i]/b[i]
      print t





3. How people complicate a programming language and  simplify it.


When programming language tries to evolve, and ppl invent a thing, called objective oriented programming (OOP). Maybe different ppl have different opinions on this. But I try to simplify the definition.


In OOP, there is a concept called "class". It is the central of OOP.

In python a class is a collection of functions.  And every time, when you write some script, you put all the functions you need into one bucket  called "class". And in future, when you need to call a function within the class, you directly call it without re-write or something. In that way, your script will be simplified and shortened.

Here is a page about class in Python

http://learnpythonthehardway.org/book/ex40.html

Other language has the similar thing, like PHP.

In PHP, people has class and arrow and double colon. They are some things that you need to learn to be advanced on PHP.  Arrow and double colon are some things for class in PHP.

Here is the difference between arrow and double colon:

http://stackoverflow.com/questions/3961456/difference-between-double-colon-and-arrow-operators-in-php

Quote, the most important lines in the article:


:: is for static elements while -> is for instance elements.

static methods can be called directly from an instance in the same way that you would call "instance" method: $obj->hello()






Good sites for SQL

site to format your SQL script:
 

http://sqlformat.org/

site to ask and get more experience on SQL: 

https://www.reddit.com/r/SQL/




How to learn SQL quickly

How to learn SQL quickly?

SQL is an easy database language to pull data from database, and make calculations etc.  on it. It has many editions, MySQL, Netezza, Oracle. Big data's hive is a form of SQL too. If you write a resume, just mention SQL, do not write something like MySQL, Netezza etc. It does not seem professional if you write so.All of the different SQL languages have slight difference on syntax, but in general, they are the same. If you master one SQL language, you will learn other SQL languages quickly.

It is called structured query language:

https://en.wikipedia.org/wiki/SQL


To learn it, you can learn some tutorials and practice on it. Here are two good tutorials:

http://www.w3schools.com/sql/

http://www.tutorialspoint.com/sql/sql_tutorial.pdf

And then, you can practice it, you can practice online, like the following. And you do not need to install anything further on your computer:


http://sqlfiddle.com/

https://www.sqlteaching.com/



Or, you are into computer, you can install  MySQL on your computer. It is free. I write down how to install MySQL on windows ( most complicated one), Mac, and Linux (easiest one, but you need to have Linux installed):

http://easyprog99.blogspot.com/2014/07/how-i-get-mysql-on-mac.html

http://easyprog99.blogspot.com/2016/06/how-to-install-mysql-workbench-on.html

http://easyprog99.blogspot.com/2016/01/how-to-install-mysql-on-linux.html


And then you can practice and learn SQL step by step:

1. You need to create some tables, using the following query:

http://dev.mysql.com/doc/refman/5.7/en/create-table.html

2.  You need to insert some data into the tables, using the insert, values query manually:

http://dev.mysql.com/doc/refman/5.7/en/insert.html



3. If you use Linux, you can insert data into tables by using infile, load:

http://dev.mysql.com/doc/refman/5.7/en/load-data.html



4. Try different types of queries: join, where, having, group by, drop, delete etc.


And if you are into computer and want to install Linux ( it is more convenient to use than windows, mac), here is a link:

http://easyprog99.blogspot.com/2016/04/one-way-to-install-linux-on-your-pc.html


Some usual SQL interview questions:

1. What's the difference between right, left, full join?
2. Relationship between having, group by, where? How to use having?

Here is an article for this question:

http://www.w3schools.com/sql/sql_having.asp


3. Some date functions on SQL


4. A SQL question on an onsite job interview:

We have the following data:

date           sales
09/01/2011      110
12/01/2011      100
01/03/2011      120
03/08/2011     200

We need to get the following report from the data:
                         Day 
Month      mon    tues    wed    thurs fri sat sun
jan           sales  sales   sales   ...
feb    ...
march  ...
...    ...

Write SQL query for this. 

5. Youtube has video play log like this:
Video ID, time
vid1 t1
vid2 t2
… …
The log is super large.
Find out the top 10 played videos on youtube in a given week.


6.A bank has this access log:
IP address, time
ip1 t1
ip2 t2
… …

If one ip accessed K times within m seconds, it may be an attack.
Given the log, identify all IPs that may cause attack.

7. Given some sessions and users data, try to find out, which session has the highest number of users:

2009-7-12 14:01','2009-7-12 15:01'
2,'2009-7-12 14:30','2009-7-12 14:45'
3,'2009-7-12 14:47','2009-7-12 15:30'
4,'2009-7-12 13:01','2009-7-12 17:01'
5,'2009-7-12 14:15','2009-7-12 18:01'
6,'2009-7-12 11:01','2009-7-12 19:01'
1,'2009-7-12 16:07','2009-7-12 19:01'

 



















How to install MySQL workbench on windows

How to install MySQL workbench  on windows. Here is an video on youtube:

https://www.youtube.com/watch?v=iP1wOSsKjW8


Here is a post I wrote before, not very detailed:


http://easyprog99.blogspot.com/2014/07/how-i-get-mysql-workbench-wook.html


And here is a more  instruction from me:


Go to  the the following webpage:

https://dev.mysql.com/downloads/workbench/

And download the MSI installer, and execute it. You can download the MSI without sign-up, just click "No thanks...." on the bottom of the page.

And you will get the MySQL workbench:



But if you do not download MySQL server, it won't work, it will show the following error:












And to let it run, you need to have MySQL server. You can get MySQL server from the MySQL installer, and install the MySQL server from the following MySQL installer. You need to follow several steps from there:

http://dev.mysql.com/downloads/windows/installer/5.6.html


And then you can configure your MySQL server from there. You need to follow several steps.  And run MySQL workbench to run some code there:






Installing MySQL on windows is more complicated than installing MySQL on Mac and Linux. You need to follow more steps to get it work.And on all of the installation, you need to set up the password.To me the simplest way, and least troublesome way to install MySQL is to install it on Linux. But usually ppl use Windows and Mac more.




Tuesday, June 7, 2016

Places to find freelance, part-time programming/data-related jobs

There are several places for programmers/data analysts etc to find freelance, part-time jobs:




https://authenticjobs.com/

One of the most official ones. But  jobs are usually for programmers, like PHP programmers.

Jobs are posted on their webpage.


https://www.upwork.com/




You can sign-up, and get an account there, then you can search for jobs, and apply to the jobs. The rates are usually not so high. I was told the applicants sometimes argued with their employers about the rates.  But good place to practice for some small money. And some of the jobs are difficult.


https://www.freelancer.com/

Similar to upwork.com. 


https://www.fiverr.com/

5 dollars for each small job. You can sign-up and get a profile, and you can see your profile' clicks, views etc from the backend. 




http://www.r-bloggers.com/

Places to finds all kinds of data-related jobs, freelance, part-time, full-time. I applied once, no results. 



http://craigslist.org/


Good place to find all kinds of local jobs, freelance, part-time, full-time. 



Monday, June 6, 2016

A possible search algorithm

One of my tasks at work is to match one set of strings to another set of strings. Some of the strings in one set is similar to the strings in another set.

I used the string matching method to do this. Calculate the similarity score  between one string and each string in another set using Levenshtein algorithm, and sort the similarity scores,  the string  with the highest score with be assigned as the match to the original string.

Here is the wiki page for the Levenshtein algorithm:

https://en.wikipedia.org/wiki/Levenshtein_distance



Here is part of the code.

The whole code is very long. We used some other searching logic to refine the search.

 We deployed it to a web service.

Similarly, google used some searching algorithm. This method can possibly be a searching algorithm. 


if level2=='UNK' and level3=='unk' and level1!='unk':
      ee={}
      level=level1
      for e in range(len(feature)):
        d2=float(Levenshtein.ratio(str(level),feature[e][len(feature[e])-1]))
        ee[str(feature[e][2].strip())]=d2
      my_list=sorted(ee.items(),key=lambda x:x[1],reverse=True)[:5]
      match=selection(my_list,avails_dic)
      if logging_level>5:
          print "returned value : % s" % match
      step2=time.strftime("%x %X")

      tdelta = datetime.datetime.strptime(step2, FMT) - datetime.datetime.strptime(step1, FMT)
      if logging_level>4:
           print "first  step ending time   is:"+step2
           print "first  step used time is %s:" % tdelta
      return match

Friday, June 3, 2016

How to set up eclipse kepler ( for c++) IDE on windows, illustrating with pics

I tried to use windows emacs to build some c++ program, but when the c++ program has input, it will not work. So I tried a free c++ IDE , called eclipse.

Eclipse is a free IDE for many languages. 

First download eclipse c++ IDE zipped file from here:

http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/kepler/SR2/eclipse-cpp-kepler-SR2-win32-x86_64.zip


And save it to a directory on your computer, and unzip it.


And click eclipse.exe in the eclipse folder, and you can see your eclipse.

The eclipse interface looks like this:



To create a new project, go to file=>new etc:






After writing a project, go to  project=>build project:




 When I first built my project, there was an error, "make" not found in PATH. If you have such error, and you use MinGW, go to "bin" folder under MinGW, rename the mingw32-make.exe to make.exe.

And when I ran my first project, there was an error, "Launch failed, binary not found". If you have such an error, right click your project, go to properties=>c/c++ build => setting=> binary parsers=>check PE windows parser.


Then, it will work.












What programmers can do to write better code

What programmers can do to write better code



https://www.infoq.com/news/2016/06/programmers-write-better-code




A quick introduction to c++

A quick introduction to c++:



http://homes.cs.washington.edu/~tom/c++example/c++.pdf


c++ example code

c++ example code:

http://www.inference.phy.cam.ac.uk/teaching/comput/C++/examples/index.shtml


http://www.cppsamples.com/

http://fahad-cprogramming.blogspot.com/p/c-simple-examples.html


http://www.cprogramming.com/snippets/


https://example-code.com/cpp/default.asp


http://www.cs.indiana.edu/~sabry/teaching/intro/fa96/code/












An online IDE


An online IDE, it is a little bit slow.

https://www.codechef.com/ide


Thursday, June 2, 2016

I found a fun thing on windows

I used windows at beginning as an OS. And then I used Mac and Linux consequently. And then I started to using windows on my work on my second job.

I really found some fun things from windows this time. Like the windows TextPad etc. And my co-workers freely copy things from windows picture to emails etc. It is good.

Then I started to study all the IDE on windows. I found Atom.

But because my working computer has firewall, I can not install the package script on my Atom in my working computer. So, I can not run c++/c programs smoothly on Atom.

I tried to figured out some good free c++ IDE on windows. And I found this page:

http://www.wtfdiary.com/2012/08/8-best-and-free-ide-for-c-and-c.html




They are good, but I feel they are not something I was looking for. It is rare. And it is a fun thing.

And I found Win emacs, it is something I was looking for. I am showing you how win emacs works:


1. Download win emacs from this page:

https://sourceforge.net/projects/emacsbinw64/

2. unzip the zipped file to a folder, and in the sub folder "bin", click "runemacs.exe"



3. Then, you will see this tool:






3. click "tools" on the top:






4. click "shell command":



Then, you can write script using the command "emacs hello.py" etc to write and run script.

5. to write and run different scripts:

  1. 1. to write and run python script: 
        type emacs xx.py, write script and , using python xx.py to run it
  1. 2. to write and run c++ script:
       type emacs xx.cpp, write script and, using "g++ xx.cpp -o file4" to compile the script , and just type file4 to run it.

      and in order to run cpp script, you need to install mingw and add it to path:

     https://atom.io/packages/gpp-compiler
  1. 3 to write and run perl script:
 type emacs xx.pl to write script, to run it, type xx.pl directly.






Wednesday, June 1, 2016

Run an AWK file in Atom

Run an AWK file in Atom.

First write a .sh file, having AWK in it,  and save it. Then run it.


Configured MySQL on Atom, but failed to run it.

To configure MySQL on Atom, first put mysql.exe under a simply-named directory under C:\\






And then, configured it under Atom:





Write a SQL file on Atom, and run it. Access denied.






How to configure sh on Atom

How to configure sh etc on Atom.

First I download the win-sh file from here:

https://sourceforge.net/projects/win-bash/files/shell-complete/latest/


I unzipped it to a folder and save it under C:\\

There are a bunch of  exe files:







And then, I configured it in Atom:





And I run an .sh file in Atom:






looking for a man

 I am a mid aged woman. I live in southern california.  I was born in 1980. I do not have any kid. no compliacted dating.  I am looking for ...