Data Science, Machine Learning, Natural Language Processing, Text Analysis, Recommendation Engine, R, Python
Wednesday, 23 August 2017
How to Enable Automatic Firmware Updates for Your Wink Hub
Geek Trivia: When You See New Growth Rising Out Of An Old Tree Stump, You’re Seeing A?
Tuesday, 22 August 2017
How to Find You Wi-Fi Connected Roomba When It Gets Lost
Is Now a Good Time to Buy an Oculus Rift or HTC Vive?
How to Build Your Own NES or SNES Classic with a Raspberry Pi and RetroPie
The Best Tools for Editing Pictures on Chromebooks
What Is a Macro Lens in Photography?
Talk Python to Me: #126 Kubernetes for Pythonistas
This is great, until you end up with 5 different types of containers, each of them scaled out, and you need to get them to work together, discover each other and upgrade together. That's where Kubernetes comes it.
Today you'll meet Kelsey Hightower, a developer advocate on Google's cloud platform.
Gocept Weblog: Zope preparing to enter Python 3 wonderland
Once upon the time there was an earl named Zope II. His prophets told him that around the year 2020 suddenly his peaceful country will be devastated: They proclaim that with the “sunset” of Python 2 as stable pillar of his country, insecurity and pain will invade his borders and hurt everyone living within. There seemed only one possible move forward to escape the disaster: Flee to the Python 3 wonderland, the source of peace and prosperity.
This was not as easy as one might think. Earl Zope II was already an old man. He was in the stable age where changes are no longer easy to achieve and he had many courtiers in his staff which he needed all the day.
The immigration authority of the Python 3 wonderland was very picky about the persons which requested permission to settle down. Many “updates” for Zope II and his staff where required to so they eventually became “compatible” with the new country. Earl Zope II was even forced to change his name to Zope IV to show hat he was ready for Python 3 wonderland.
After much work with the immigration authorities it seemed to be possible for earl Zope IV to enter; only some – but important – formalities were needed before he could be allowed to settle down and call himself a citizen of the Python 3 wonderland.
This is where the tale gets real: We need your help to release a beta version of Zope 4. The hard work seems to be done; but some polish and testing is still required to reach this goal.
We invite you to the Zope 4 Phoenix Sprint to help raising Zope 4 from the ashes! From Wednesday, 13th until Friday, 15th of September 2017 we sprint at the gocept office in Halle (Saale), Germany towards the beta release.
Possible sprint topics could be:
- Work on issues and pull requests regarding the beta release.
- Make RestrictedPython beta ready.
- Work on a Bootstrap of the Zope management interface (ZMI)
- Port CMF components to Python 3 to test Zope 4 for possible issues
- Work on Plone to make it ready for Zope 4
- Try out migration strategies for ZODB content to Python 3.
- Improve the documentation.
You are heartily invited to join us for the honour of earl Zope IV.
Daniel Bader: What Are Python Generators?
What Are Python Generators?
Generators are a tricky subject in Python. With this tutorial you’ll make the leap from class-based iterators to using generator functions and the “yield” statement in no time.If you’ve ever implemented a class-based iterator from scratch in Python, you know that this endeavour requires writing quite a bit of boilerplate code.
And yet, iterators are so useful in Python: They allow you to write pretty for-in loops and help you make your code more Pythonic and efficient.
As a (proud) “lazy” Python developer, I don’t like tedious and repetitive work. And so, I often found myself wondering:
If there only was a more convenient way to write these Python iterators in the first place…Surprise, there is! Once again, Python helps us out with some syntactic sugar to make writing iterators easier.
In this tutorial you’ll see how to write Python iterators faster and with less code using generators and the
yield keyword.Ready? Let’s go!
Python Generators 101 – The Basics
Let’s start by looking again at theRepeater example that I previously used to introduce the idea of iterators. It implemented a class-based iterator cycling through an infinite sequence of values.This is what the class looked like in its second (simplified) version:
class Repeater: def __init__(self, value): self.value = value def __iter__(self): return self def __next__(self): return self.value
This is where Python’s generators enter the scene. If I rewrite this iterator class as a generator, it looks like this:
def repeater(value): while True: yield value
Not bad, eh? As you can see, generators look like regular functions but instead of using the
return statement, they use yield to pass data back to the caller.Will this new generator implementation still work the same way as our class-based iterator did? Let’s bust out the for-in loop test to find out:
>>> for x in repeater('Hi'): ... print(x) 'Hi' 'Hi' 'Hi' 'Hi' 'Hi' ...
Repeater class did.(Remember to hit Ctrl+C if you want out of the infinite loop in an interpreter session.)
Now, how do these generators work? They look like normal functions, but their behavior is quite different. For starters, calling a generator function doesn’t even run the function. It merely creates and returns a generator object:
>>> repeater('Hey') <generator object repeater at 0x107bcdbf8>
next() is called on the generator object:>>> generator_obj = repeater('Hey') >>> next(generator_obj) 'Hey'
repeater function again, it looks like the yield keyword in there somehow stops this generator function in mid-execution and then resumes it at a later point in time:def repeater(value): while True: yield value
return statement is invoked inside a function, it permanently passes control back to the caller of the function. When a yield is invoked, it also passes control back to the caller of the function—but it only does so temporarily.Whereas a
return statement disposes of a function’s local state, a yield statement suspends the function and retains its local state.In practical terms, this means local variables and the execution state of the generator function are only stashed away temporarily and not thrown out completely.
Execution can be resumed at any time by calling
next() on the generator:>>> iterator = repeater('Hi') >>> next(iterator) 'Hi' >>> next(iterator) 'Hi' >>> next(iterator) 'Hi'
You’ll find that for most types of iterators, writing a generator function will be easier and more readable than defining a long-winded class-based iterator.
Python Generators That Stop Generating
In this tutorial we started out by writing an infinite generator once again. By now you’re probably wondering how to write a generator that stops producing values after a while, instead of going on and on forever.Remember, in our class-based iterator we were able to signal the end of iteration by manually raising a
StopIteration exception. Because generators are fully compatible with class-based iterators, that’s still what happens behind the scenes.Thankfully, as programmers we get to work with a nicer interface this time around. Generators stop generating values as soon as control flow returns from the generator function by any means other than a
yield statement. This means you no longer have to worry about raising StopIteration at all!Here’s an example:
def repeat_three_times(value): yield value yield value yield value
yield statements. If a yield temporarily suspends execution of the function and passes back a value to the caller, what will happen when we reach the end of this generator?Let’s find out:
>>> for x in repeat_three_times('Hey there'): ... print(x) 'Hey there' 'Hey there' 'Hey there'
StopIteration exception when execution reached the end of the function.But to be sure, let’s confirm that with another experiment:
>>> iterator = repeat_three_times('Hey there') >>> next(iterator) 'Hey there' >>> next(iterator) 'Hey there' >>> next(iterator) 'Hey there' >>> next(iterator) StopIteration >>> next(iterator) StopIteration
StopIteration to signal that it has no more values to provide.Let’s come back to another example from my Python iterators tutorials. The
BoundedIterator class implemented an iterator that would only repeat a value a set number of times:class BoundedRepeater: def __init__(self, value, max_repeats): self.value = value self.max_repeats = max_repeats self.count = 0 def __iter__(self): return self def __next__(self): if self.count >= self.max_repeats: raise StopIteration self.count += 1 return self.value
BoundedRepeater class as a generator function. Here’s my first take on it:def bounded_repeater(value, max_repeats): count = 0 while True: if count >= max_repeats: return count += 1 yield value
while loop in this function a little unwieldy. I wanted to demonstrate how invoking a return statement from a generator causes iteration to stop with a StopIteration exception. We’ll soon clean up and simplify this generator function some more, but first let’s try out what we’ve got so far:>>> for x in bounded_repeater('Hi', 4): ... print(x) 'Hi' 'Hi' 'Hi' 'Hi'
yield statement to pass back values until it finally hits the return statement and iteration stops.Like I promised you, we can further simplify this generator. We’ll take advantage of the fact that Python adds an implicit
return None statement to the end of every function. This is what our final implementation looks like:def bounded_repeater(value, max_repeats): for i in range(max_repeats): yield value
BoundedRepeater class to a three-line generator-based implementation providing the same functionality.That’s a 75% reduction in the number of lines of code—not too shabby!
Generator functions are a great feature in Python, and you shouldn’t hesitate to use them in your own programs.
As you just saw, generators help you “abstract away” most of the boilerplate code otherwise needed when writing class-based iterators. Generators can make your life as a Pythonista much easier and allow you to write cleaner, shorter, and more maintainable iterators.
Python Generators – A Quick Summary
- Generator functions are syntactic sugar for writing objects that support the iterator protocol. Generators abstract away much of the boilerplate code needed when writing class-based iterators.
- The
yieldstatement allows you to temporarily suspend execution of a generator function and to pass back values from it. - Generators start raising
StopIterationexceptions after control flow leaves the generator function by any means other than ayieldstatement.
Announcing Open Jam, a game jam created with open source in mind
After more than a year of participating in game jams as Team Scripta, we wanted to host one that promotes open source games and game creation tools. That's why we're teaming up with Opensource.com to bring you Open Jam, a game jam dedicated to doing just that.
read more
Astroplan Python library makes astronomy research planning easier
For some people, the darkness of the recent eclipse set off a light bulb. As millions of people saw the sun blotted out by the moon, many of them realized they're interested in astronomy more generally. Those people are in luck. A Python library called Astroplan can help them plan their observations.
read more
4 open principles for building a better startup
If you're launching a company, you might believe you shouldn't have to deal with issues like personnel development and company culture. After all, as a startup you're only concerned with the development and rapid evolution of your own product and services, right?
This kind of thinking is short-term thinking. Successful startups develop organizations with long-term strategies in mind. Startups really should think about—and prepare the groundwork for—their own company culture from beginning, so they can scale it over time as they grow.
read more
How many of your games run on Linux?
Gamer? Check. Linux user? Check.
For years, one of the top excuses I heard from friends who would otherwise have switched to Linux long ago is that they just couldn't give up their Windows-only games. I can empathize. I was a dual-booter for years for exactly this reason, and it made making the switch harder for me. After all, once I'm booted into one operating system, the temptation is to stay there rather than rebooting once gameplay is over.
Today, the landscape is far different. It's much easier than it used to be for a gamer to be a Linux user, and vice versa.
read more
The Best New Features in Android 8.0 Oreo, Available Now
How to Skip the Wait and Upgrade Your Pixel or Nexus to Android Oreo Now
How to Randomize Your Hue Lights for Extra Vacation Security
Are Smart Locks Secure?
Geek Trivia: The First Companion Character Link Has In Any Of The Legend Of Zelda Games Is?
Monday, 21 August 2017
How to Middle Click on a Laptop Touchpad
How to Make Phone Calls With Your Google Home
What Is “SmartScreen” and Why Is It Running on My PC?
How to Customize Your Command Prompt’s Color Scheme With Microsoft’s ColorTool
How to Leave a Facebook Group
Why You Should Replace Windows’ Default Image Viewer With IrfanView
Geek Trivia: The Smallest Fox Species In The World Is The?
Thursday, 25 July 2013
Installing SSH2 Extension for PHP on CentOS 5
http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -i rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
yum install gcc php-devel php-pear libssh2 libssh2-devel
pecl install -f ssh2
touch /etc/php.d/ssh2.ini
echo extension=ssh2.so > /etc/php.d/ssh2.ini
/etc/init.d/httpd restart
php -m | grep ssh2
Monday, 30 April 2012
Procedure To Increase Swap File Under Linux
Type the following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288 - if=/dev/zero : Read from /dev/zero file. /dev/zero is a special file in that provides as many null characters to build storage file called /swapfile1.
- of=/swapfile1 : Read from /dev/zero write stoage file to /swapfile1.
- bs=1024 : Read and write 1024 BYTES bytes at a time.
- count=524288 : Copy only 523288 BLOCKS input blocks.
# mkswap /swapfile1Setup correct file permission for security reasons, enter:
# chown root:root /swapfile1
# chmod 0600 /swapfile1# swapon /swapfile1 To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using a text editor such as vi:
# vi /etc/fstabAppend the following line:
/swapfile1 swap swap defaults 0 0Save and close the file. Next time Linux comes up after reboot, it enables the new swap file for you automatically.
Simply use the free command for Verify:
$ free -m Wednesday, 7 March 2012
Learning about SS7 and SIGTRAN protocols...
M3UA - Provides Network Routing between SS7 signaling nodes identified by Point Codes
SCCP - Provides Network Routing between SS7 signaling end points identified based on Global Titles (phone numbers can be used here)
TCAP - Manages end to end transactions between two nodes including time outs when peers don't respond
MAP - Presentation layer defining message formats and parameters for specific GSM / UMTS services e.g. Forward SMS
INAP/CAP - Similar to MAP except for IN or CAMEL services
IS-41 - Similar to MAP except an ANSI variant
Wednesday, 14 December 2011
Dump table and database to a file in MySQL
mysqldump -d -h HOST -u USER -p PASSWORD DBNAME > dumpfile.sql
For Table Backup : -
mysqldump -d -h HOST -u USER -p PASSWORD DBNAME TABLENAME > table.sql
For Only Table Structure :-
mysqldump -d -h HOST -u USER -p PASSWORD DBNAME TABLENAME –no-data > table.sql
You Can Restore Dump as Below : -
mysql > source /path/SQLfile