Showing posts with label humour. Show all posts
Showing posts with label humour. Show all posts

Saturday, March 16, 2019

What did Al Gore Ythm say to Data St. Ructure?

By Vasudev Ram

What did Al Gore Ythm say to Data St. Ructure?

When we mate, we'll create a Pro G. Ramma!


- Vasudev Ram - Online Python training and consulting

Hit the ground running with my vi quickstart tutorial, vetted by two Windows system administrator friends.

Jump to posts: Python * DLang * xtopdf

Interested in a Python, SQL or Linux course?

Get WP Engine, powerful managed WordPress hosting.

Subscribe to my blog (jugad2.blogspot.com) by email

My ActiveState Code recipes


Follow me on:

* Gumroad  * LinkedIn

  * Twitter

Do you create online products? Get Convertkit:

Email marketing for digital product creators


Saturday, December 29, 2018

The Zen of Python is well sed :)





- By Vasudev Ram - Online Python training / SQL training / Linux training

$ python -c "import this" | sed -n "4,4p;15,16p"
Explicit is better than implicit.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.


- Vasudev Ram - Online Python training and consulting

I conduct online courses on Python programming, Unix / Linux commands and shell scripting and SQL programming and database design, with course material and personal coaching sessions.

The course details and testimonials are here.

Contact me for details of course content, terms and schedule.

Or if you're a self-starter, check out my Python programming course by email.

Try FreshBooks: Create and send professional looking invoices in less than 30 seconds.

Learning Linux? Hit the ground running with my vi quickstart tutorial.

Sell your digital products via DPD: Digital Publishing for Ebooks and Downloads.

Posts about: Python * DLang * xtopdf

My ActiveState Code recipes

Follow me on:


Saturday, March 11, 2017

Analyse this Python code snippet

By Vasudev Ram

Hi reader [1],

Analyze the snippet of Python code below. See what you make of it.

I will discuss it in my next post.

>>> a = 1
>>> lis = [a, 2 ]
>>> lis
[1, 2]
>>> lis = [a, 2 ,
... "abc", False ]
>>>
>>> lis
[1, 2, 'abc', False]
>>> a
1
>>> b = 3
>>> lis
[1, 2, 'abc', False]
>>> a = b
>>> a
3
>>> lis
[1, 2, 'abc', False]
>>> lis = [a, 2 ]
>>> lis
[3, 2]
>>>

[1] This product is suitable for Pythonistas aged 1 to 2 (approximately). For those of higher age, the dose may have no effect :)

- Vasudev Ram - Online Python training and consulting

Are you a blogger with some traffic? Get Convertkit:

Email marketing for professional bloggers

Get updates (via Gumroad) on my forthcoming apps and content.

Jump to posts: Python * DLang * xtopdf

Subscribe to my blog by email

My ActiveState Code recipes

Follow me on: LinkedIn * Twitter



Friday, February 17, 2017

import this as comic # THE ZEN OF PYTHON ILLUSTRATED

By Vasudev Ram

I'm blogging this as a special case. That's the only way to do it ... [1]

Saw this via Twitter. Nice one:

THE ZEN OF PYTHON ILLUSTRATED

[1] :)

- Vasudev Ram - Online Python training and consulting

Get updates (via Gumroad) on my forthcoming apps and content.

Jump to posts: Python * DLang * xtopdf

Subscribe to my blog by email

My ActiveState Code recipes

Follow me on: LinkedIn * Twitter

Managed WordPress Hosting by FlyWheel



Friday, February 10, 2017

Nice one: Problem exists between keyboard and chair

By Vasudev Ram


Good one by Andy Brice (blogger at SuccessfulSoftware.net and founder of Perfect Table Plan and HyperPlan):

Problem exists between keyboard and chair

As a person who has done a good amount of both software development and troubleshooting, and as a user too, the different viewpoints resonate with me (as they still say in Silicon Valley :).

Another good one on similar lines: the best debugging tool is the one between your ears.

Another one (I've heard it attributed to the Pennsylvania Dutch):

We get too soon old and too late schmart

- Vasudev Ram - Online Python training and consulting

Get updates (via Gumroad) on my forthcoming apps and content.

Jump to posts: Python * DLang * xtopdf

Subscribe to my blog by email

My ActiveState Code recipes

Follow me on: LinkedIn * Twitter

Managed WordPress Hosting by FlyWheel



Monday, January 23, 2017

To log or not to log, that is the question

By Vasudev Ram


Hamlet image attribution

I was teaching some students about debugging print statements, so thought of doing a Google search for them.

Here is the search:

https://www.google.com/search?q=debugging+print+statements

Viewed a few of the search results. One, from the site softwareengineering.stackexchange.com, had an interesting discussion about the pros and cons of debugging print statements vs. logging vs. using a debugger:

Is printing to console/stdout a good debugging strategy?

And there are other interesting results of the search.

The title of this post is, of course, a word play on the famous quote:

To be, or not to be

from the play Hamlet by Shakespeare.

And the image at the top is of the actor Edwin Booth playing Hamlet.

- Vasudev Ram - Online Python training and consulting

Get updates (via Gumroad) on my forthcoming apps and content.

Jump to posts: Python * DLang * xtopdf

Subscribe to my blog by email

My ActiveState Code recipes

Follow me on: LinkedIn * Twitter

Managed WordPress Hosting by FlyWheel



Saturday, September 24, 2016

A TCP joke

By Vasudev Ram


Nice one: A TCP joke.

If you didn't recv it from the link above:

(Click image to enlarge)


- Vasudev Ram - Online Python training and consulting

Get updates on my software products / ebooks / courses.

Jump to posts: Python   DLang   xtopdf

Subscribe to my blog by email

My ActiveState recipes

Managed WordPress Hosting by FlyWheel



Thursday, September 8, 2016

"Please don't assume Lisp is only useful for Animation and Graphics, AI, Bioinformatics, B2B and E-Commerce, Data Mining, ...


By Vasudev Ram


"Please don't assume Lisp is only useful for Animation and Graphics,


AI, Bioinformatics, B2B and E-Commerce,


Data Mining, EDA/Semiconductor applications,


Expert Systems, Finance,


Intelligent Agents, Knowledge Management, Mechanical CAD, Modeling and Simulation, Natural Language, Optimization, Research, Risk Analysis, Scheduling, Telecom,


and Web Authoring just because these are the only things they happened to list." --Kent Pitman

One could say somewhat the same about Python ...

Image attributions:

Utah teapot

Shopping cart icon

Semiconductor

Dollar

Telecom

- Vasudev Ram - Online Python training and consulting

Get updates on my software products / ebooks / courses.

Jump to posts: Python   DLang   xtopdf

Subscribe to my blog by email

My ActiveState recipes



Sunday, April 17, 2016

A simple joke bot in Python

By Vasudev Ram


Image attribution: Vasudev Ram

Following a chain of thoughts, including about bots and jokes, I had the idea of writing a simple joke bot in Python. Here it is, in file joke_bot.py:
from __future__ import print_function
import sys
import os
from random import randint

'''
A joke bot in Python.
v1.0.
Author: Vasudev Ram
Copyright 2016 Vasudev Ram - http://jugad2.blogspot.com 
'''

jokes = [
    '''
    Q: Why did the chicken cross the road?
    A: To get to the other side.
    ''',
    '''
    Q: What is black, white and red all over?
    A: A newspaper.
    ''',
    '''
    Q: What time is it when an elephant sits on your fence?
    A: Time to build a new fence.
    ''',
    '''
    Q: How many elephants will fit into a Mini?
    A: Four: Two in the front, two in the back.
    Q: How many giraffes will fit into a Mini?
    A: None. It's full of elephants.
    ''',
    '''
    Q: What do elephants have that nothing else has?
    A: Baby elephants.
    ''',
    '''
    Knock Knock.
    Who's there?
    Apple.
    Apple Who?
    Apple-y ever after.
    ''',
    '''
    Knock Knock.
    Who's there?
    Amos.
    Amos Who?
    A mosquite bit me.
    Knock Knock.
    Who's there?
    Andy.
    Andy Who?
    Andy's still biting me!
    ''',
    '''
    Knock Knock.
    Who's there?
    Orange.
    Orange Who?
    Orange you going to the party?
    ''',
]

lj = len(jokes)

def tell_a_joke():
    i = randint(0, lj - 1)
    print("Here is a joke for you:")
    print(jokes[i])

def clear_screen():
    # For Windows.
    os.system('cls')
    # For Unix/Linux.
    #os.system('clear')
    # Add clear screen support for 
    # other OS's here if needed.

def main():
    clear_screen()
    print('\nPython Joke Bot v1.0 activated.\n')
    ans = ''
    while ans != 'n':
        tell_a_joke()
        ans = raw_input('Tell another one? [YyNn]: ')
        ans = ans.strip().lower()
        clear_screen()
    print('See you next Funday.')

main()
Run it with:
python joke_bot.py
Sample output:
Python Joke Bot v1.0 activated.

Here is a joke for you:

    Knock Knock.
    Who's there?
    Apple.
    Apple Who?
    Apple-y ever after.

Tell another one? [YyNn]: y

Here is a joke for you:

    Q: How many elephants will fit into a Mini?
    A: Four: Two in the front, two in the back.
    Q: How many giraffes will fit into a Mini?
    A: None. It's full of elephants.

Tell another one? [YyNn]:

Here is a joke for you:

    Knock Knock.
    Who's there?
    Amos.
    Amos Who?
    A mosquite bit me.
    Knock Knock.
    Who's there?
    Andy.
    Andy Who?
    Andy's still biting me!
Here is a joke for you:

    Knock Knock.
    Who's there?
    Amos.
    Amos Who?
    A mosquite bit me.
    Knock Knock.
    Who's there?
    Andy.
    Andy Who?
    Andy's still biting me!

Tell another one? [YyNn]:

Here is a joke for you:

    Q: What time is it when an elephant sits on your fence?
    A: Time to build a new fence.

Tell another one? [YyNn]:

Here is a joke for you:

    Knock Knock.
    Who's there?
    Apple.
    Apple Who?
    Apple-y ever after.

Tell another one? [YyNn]: n

See you next Funday.

A point about the program: it's obviously quite simple. I was almost not going to post about it because of that, but then realized that this, as well as some other small programs I've written in the past and plan to write in the future, though small now, can still illustrate a few points about programming (at least for beginners, including me, a perpetual beginner :).

And, more importantly, it can be built upon incrementally over time, in multiple versions, to illustrate various other programming language and library features. E.g. I can modify/enhance this program to read the jokes from a flat or structured file (such as JSON or XML), a key-value store like BSD DB (supported by the Python stdlib), SQLite (ditto), etc.

See you next Funday :)

- Vasudev Ram - Online Python training and consulting

Signup to hear about my new products and services.

My Python posts     Subscribe to my blog by email

My ActiveState recipes


Monday, December 21, 2015

Microsoft to acquire Linux ...

... skills. :-)

So says:

<a href="https://mobile.twitter.com/linuxfoundation/status/678665931434815490">The Linux Foundation</a>

- Vasudev Ram
jugad2.blogspot.com

Sunday, July 12, 2015

Cut the crap! An absolutely essential tool for writers

By Vasudev Ram


KEEP CALM

AND

BE CONCISE




Like anyone else, every now and then I hear people use redundant words words or phrases. Hey, I do it myself sometimes, but am trying to do less of it.

So one day recently, thinking about ways to help with this issue, I came up with the idea for this program, called "Cut the crap!".

You feed it a redundant word or phrase, and if it "knows" it, it spits out the concise (unredundant? dundant? :-) version. Think a Strunk-and-White-like Python bot.

So, here's the Python code for cut_the_crap.py, an absolutely essential tool for writers. The phrases and words are hardcoded as of now, in this first version, but you can easily modify the program to read them from any persistent store (such as a file or database), along with the concise substitutes:
# cut_the_crap.py
# Author: Vasudev Ram
# Purpose: Given a redundant word or phrase, emits a concise synonym.
# See Strunk and White, et al.

from string import lower
from random import randint

d = {
    'at this point in time':
    ['now', 'at present', 'at the moment', 'at this moment', 
    'currently', 'now', 'presently', 'right now'],
    'absolutely complete': ['complete'],
    'absolutely essential': ['essential', 'indispensable'],
    'actual experience': ['past experience', 'experience'],
    'as to whether': ['whether'],
    'try out': ['try']
}

def cut_the_crap(word):
    if word in d:
        words = d[word]
        i = randint(0, len(words) - 1)
        return words[i]
    else:
        return ""
        
def get_the_word():
    crap_word = raw_input("Enter your word (or type 'exit'): ")
    return crap_word

def main():
    word = get_the_word()
    while lower(word) != 'exit':
        right_word = cut_the_crap(word)
        if right_word != "":
            print "Cut the crap! Say:", right_word
        print
        word = get_the_word()
    print "Bye."

if __name__ == '__main__':
    main()
And here is a sample run, entering a few redundant words and phrases:
$ py cut_the_crap.py
Enter your word (or type 'exit'): at this point in time
Cut the crap! Say: at the moment

Enter your word (or type 'exit'): at this point in time
Cut the crap! Say: right now

Enter your word (or type 'exit'): at this point in time
Cut the crap! Say: now

Enter your word (or type 'exit'): as to whether
Cut the crap! Say: whether

Enter your word (or type 'exit'): absolutely essential
Cut the crap! Say: indispensable

Enter your word (or type 'exit'): absolutely essential
Cut the crap! Say: essential

Enter your word (or type 'exit'): try out
Cut the crap! Say: try

Enter your word (or type 'exit'): exit
Bye.
- Enjoy.

- Vasudev Ram - Online Python training and programming

Dancing Bison Enterprises

Signup to hear about new products or services that I create.

Posts about Python  Posts about xtopdf

Contact Page

Friday, April 10, 2015

A four line Python quine

By Vasudev Ram




Something that happened today made me think of writing a quine, in Python.

A four line Python quine;
how's that for a rhyme?
# Not so good.

A four line Python quine;
Yes, this one is mine.
# Ah, better.

A four line Python quine;
Sure, this too is mine.
# So-so.

A four line Python quine;
Can you stretch that to nine?
# It may not be worth my time.

A four line Python quine;
Hello, sir, rise and shine!

Of course, since the quine prints itself (by definition) when run, I don't need to show the code separately from the output:
$ python quine.py
import sys
with open(sys.argv[0]) as program:
    for line in program:
        sys.stdout.write(line)
Let's check that it works right:
$ python quine.py > pq.py
$ fc /l quine.py pq.py
Comparing files quine.py and PQ.PY
FC: no differences encountered
The quine could be shortened to:
import sys
with open(sys.argv[0]) as p:
    for l in p:
        sys.stdout.write(l)
I'm sure someone can come up with a shorter quine; is it thine? but this was my first time writing one, and I had fun :)

- Enjoy.

- Vasudev Ram - Online Python training and programming

Dancing Bison Enterprises

Signup to hear about new products or services from me.

Posts about Python  Posts about xtopdf

Contact Page

Wednesday, November 26, 2014

A first Python one-liner

By Vasudev Ram

1. Install Python 2.7 (if you don't have it already).

2. Run this at the command line:

python -c "print ''.join(list(reversed('!dlrow olleH')))"

- Vasudev Ram - Dancing Bison Enterprises

Contact Page

Sunday, December 29, 2013

#FiveWordTechHorrors - a trending Twitter hashtag

By Vasudev Ram



Saw this trending Twitter hashtag after I posted this tweet:

Internal reprogrammability - Martin Fowler: martinfowler.com/bliki/Internal… #programming

and then, out of curiosity, clicked on the #programming hashtag in it, to see some other tweets with that hashtag.

Was interested to see, as a result of the click, some tweets by various people, some well-known, with another hashtag, #FiveWordTechHorrors.

So I thought up one of my own:

The production server is down. #FiveWordTechHorrors.

because it reminded of a command given in haste by a colleague of mine, way back, on the root console of a UNIX server, in a factory with many people using that server for work:

You just typed init 0. #FiveWordTechHorrors

(He typed it without informing the users in advance, and as root :-)

And here is another one:

Your application crashed. Reinstall Windows. #FiveWordTechHorrors

Here is a Mashable story about FiveWordTechHorrors.

Apropos, this Google search for the term origin of Twitter hashtag is interesting.

Happy New Year to my readers.


- Vasudev Ram - Dancing Bison Enterprises

Contact Page


O'Reilly 50% Ebook Deal of the Day


Friday, December 20, 2013

Outsourcing ...

By Vasudev Ram



- Vasudev Ram - Dancing Bison Enterprises



Contact Page


Friday, December 6, 2013

Saturday, November 9, 2013

Do we need some Web Haiku?

By Vasudev Ram

Gentle readers of mine blog,

Via a chain of thoughts, I remembered about Windows haiku, which I had first come across several years ago.

The event that triggered the chain was getting this message on my PC:

"Google Drive has stopped working".

That led me to search for web haiku. A quick scan of the Google results for the term web haiku did not seem to give relevant results, at least on the first page.

So I thought we may need some web haiku, to rival or better Windows haiku.

What thinketh ye?

Leave thine kinde thoughts in the comments.

--- "On a clear day you can see the blue screen of death."
- Vasudev Ram

Go forth and tilt at windmills.



Contact

Tuesday, August 27, 2013

Slashdot interviews Guido van Rossum, Python creator


By Vasudev Ram

Slashdot recently interviewed Guido van Rossum, the creator of Python.

Just saw it via this tweet by the BDFL himself.

The interviews includes topics like what he did at Google, what he is doing at Dropbox, and other things:

Slashdot interviews Guido

Here are a few gems from the interview, IMO of course :-)

[ Guido: I'm not a fan of religiously taking some idea to the extreme, and I try to be pragmatic in my design choices (but not *too* pragmatic, see the start of this sentence :-). I value readability and usefulness for real code. There are some places where map() and filter() make sense, and for other places Python has list comprehensions. I ended up hating reduce() because it was almost exclusively used (a) to implement sum(), or (b) to write unreadable code. So we added builtin sum() at the same time we demoted reduce() from a builtin to something in functools (which is a dumping ground for stuff I don't really care about :-).

...

Multi-line lambdas
by NeverWorker1

One of the most common complaints about Python is the limitations of its lambdas, namely being one line only without the ability to do assignments. Obviously, Python's whitespace treatment is a major part of that (and, IIRC, I've read comments from you to that effect). I've spent quite a bit of time thinking about possible syntax for a multi-line lambda, and the best I've come up with is trying to shoehorn some unused (or little used) symbol into a C-style curly brace, but that's messy at best. Is there a better way, and do you see this functionality ever being added?

Guido: Really? I almost never hear that complaint except from people who submit questions to Slashdot interviews. :-)

...

Have the prospects of Python in any way improved since you grew a beard? To what degree does language success correlate to beard length?

Guido: It is absolutely essential. Just look at Perl's fate -- Larry Wall is just too clean-shaven. :-)

]

- Vasudev Ram - Dancing Bison Enterprises

Contact me