Friday, July 15, 2016
Round a number to nearest 100 using python
Use round function
Example
>>> round(12351.221212,-2)
12400.0
>>>round(12349.221212,-2)
12300.0
Wednesday, July 13, 2016
Steps to Learn Python Programming
- Download the Anaconda distribution of Python for your platform - Linux, Mac, or Windows.
- Work your way through Learn Python the Hard Way on the web. This will take you perhaps 6 weeks.
- At this point you are competent to code, but not yet design
- Read and work the problems in chapters 1–14 of “Introduction to Algorithms” by Cormen as if your career depends on it. Because it does. This may take you 6 months.
- Read either “Fluent Python” or “Python for Data Analysis” to learn idiomatic programming.
- Learn another language, perhaps Java or Go or Swift. Implement a project in this language.
- Read “Design Patterns” or “Head First Design Patterns” to learn reusable aspects of program design. Make flash cards and test yourself.
Friday, July 8, 2016
Fork Bomb-Dangerous
:(){ :|: & };: – Fork Bomb
The following line is a simple-looking, but dangerous, bash function:
:(){ :|: & };:
This short line defines a shell function that creates new copies of itself. The process continually replicates itself, and its copies continually replicate themselves, quickly taking up all your CPU time and memory. This can cause your computer to freeze. It’s basically a denial-of-service attack.
The Lesson: Bash functions are powerful, even very short ones.
Git Origin,Upstream
The wiki is talking from a forked repo point of view. You have access to pull and push from origin, which will be your fork of the main diaspora repo. To pull in changes from this main repo, you add a remote, "upstream" in your local repo, pointing to this original and pull from it.
So "origin" is a clone of your fork repo, from which you push and pull. "Upstream" is a name for the main repo, from where you pull and keep a clone of your fork updated, but you don't have push access to it.
Wednesday, July 6, 2016
Linux Commands
1. rm Command-Remove File or Directory
rm -r folder_name-Delete Folder
rm -rf folder_name-Recursive deletion,force delete
2. SCP Command-Used to copy file between hosts
scp -i ~/.ssh/fpem.pem -r source destination
3. SSH Command-For login into a remote mechine
4. lscpu Command-Get CPU/System Information
lscpu
rm -r folder_name-Delete Folder
rm -rf folder_name-Recursive deletion,force delete
2. SCP Command-Used to copy file between hosts
scp -i ~/.ssh/fpem.pem -r source destination
3. SSH Command-For login into a remote mechine
ssh -i ~/.ssh/pem_file.pem ubuntu@host_system_name
4. lscpu Command-Get CPU/System Information
lscpu
5. Get Memory Information
cat /proc/meminfo
6. Get Memory/CPU Information
top
7. Rename a File
mv old_file_name new_file_name
8. Extract tar File
tar -xvf tar_file_name.tar
cat /proc/meminfo
6. Get Memory/CPU Information
top
7. Rename a File
mv old_file_name new_file_name
8. Extract tar File
tar -xvf tar_file_name.tar
Subscribe to:
Posts (Atom)