Category Archives: Uncategorized

python

Python Maths

So I have been doing algebra and I was asked to solve some equations. But I got stuck on two of them. I employed the help of Python to find my answer.

My first problem was  16 - 2x = 19 - 5x. I needed to find x. I had a fair idea that the answer would be x = 1 but I wanted to make sure, so I asked my computer with this script:

>>> x = 0
>>> while True:
...     outa = 16 -2*x
...     outb = 19 -5*x
...     if(outa == outb):
...             print x
...     x += 1
... 
1
^CTraceback (most recent call last):
  File "<stdin>", line 4, in <module>
KeyboardInterrupt

As you can see, I was right, the answer was 1 (or more precisely x = 1).

My second problem was 3(x + 2) = 2(x - 5). Now, I had no idea what this was going to be, so I asked Python yet again with this script:

>>> x = 0
>>> while True:
...     outa = 3*(x+2)
...     outb = 2*(x-5)
...     if(outa == outb):
...             print x
...     x += 1
... 
^CTraceback (most recent call last):
  File "<stdin>", line 2, in <module>
KeyboardInterrupt

Uhh, that didn’t work. The script had been running for about while and still hadn’t told me anything! I tried again, except modified the script to use negative numbers instead of positive numbers:

>>> x = 0
>>> while True:
...     outa = 3*(x+2)
...     outb = 2*(x-5)
...     if(outa == outb):
...             print x
...     x -= 1
... 
-16
^CTraceback (most recent call last):
  File "<stdin>", line 2, in <module>
KeyboardInterrupt

There it is! x = -16.

I had been told Python can be a handy pocket calculator but I didn’t know it could be this handy!

Microsoft Attacking Google With Scroogled Campaign

So, some of you may have seen Microsoft’s video on YouTube attacking Google.

I don’t like Google or Microsoft and persionally I find this whole thing disgusting. In these videos on YouTube (of all services for Microsoft to post and attack video about Google, it was YouTube) Microsoft goes on about how Google spies on your emails, and gives app developers information about horrible things like your age and your home town.

One of the ads are posted below. It portrays Google spying on your mail so it can place an advert around it. It then shows Microsoft (Outlook) doing the polar opposite.

This is pathetic.

Scroogled.com is a page that is obviously owned by Microsoft (It says so in the footer but the tacky metro theme is apparent from the start).

I don’t like Microsoft or Google. I don’t like Google because they do spy on you, even if it is automated. I don’t like Microsoft because I’m sure they do the same.

Microsoft makes money by selling an overly priced operating system that hardly ever works correctly.

Google makes money by giving people a free service they can use but showing people ads. When someone clicks on an ad Google makes money. So obviously Google would want to show the most relevant ads to people. It means people are more likely to click (this makes Google happy), and people are more likely to be interested in something that is targeted for what they are writing about (this makes the people that are paying Google to show their ad happy).

Now, If you are like me and don’t like Microsoft or Google, there is good news!

With these services and programs you can log out of Google and shut down Windows for good. For a search engine Duck Duck Go is completely anonymous (and unaffected by Heartbleed).

I haven’t found a good email service yet, I use my hosting for email.

For an operating system you have many options. Ubuntu is what I use on my computer and I love it. Kubuntu is the same as Ubuntu but using a KDE desktop environment, for people that like the integration of Mac OSX you might like Kubuntu. I myself am actually thinking about using Kubuntu on my laptop. If your computer is not very powerful, would run Windows XP but not 7 then you will want Lubuntu. Lubuntu is a light version of Ubuntu perfect for low power computers. Finally there is Elementary OS, this OS looks similar to Mac OSX. It is simple elegant and does what it should.

All of these systems are Linux, Ubuntu is based of a system called Debian, Debian is based of Linux. Kubuntu, Lubuntu and Elementary are all based off Ubuntu. So they all work similarly.

Its up to you to decide what would work best for you.

Personal note: I was rather angry at my findings about what Microsoft has been up to, but now after remembering Linux and recommending some distributions, all that went away!

Twitter card on your your website

Example of twitter card

Floating head guy’s tweet

You know those little descriptions underneath a tweet that you get sometimes? There is a name for those, they are called Twitter cards! To get a twitter card you must first add the Twitter code to your website or blog.

It’s not quite as easy as that though, you need to send your website to Twitter for approval. You can’t just bung a few Twitter meta tags and expect it to show up on a tweet!

Twitter card code

Here comes the code. Twitter cards use meta tags to get the information, if you go to the Twitter cards dev page, you can set up your card there. You need to sign into Twitter though, and it doesn’t work in Firefox, it works in webkit based browsers like Safari, Chromium, or if you are very desperate Google Chrome.

After selecting a card type, enter your information (not everything is required) into the fields down the side. After entering your information, scroll down to the bottom and click “Update Preview”. Below the preview will be the code you need to paste into your <head> tag.

If you are not interested in adding a Twitter card to WordPress, scroll down to the heading “Verifying your site”.

How add a Twitter card to WordPress

I’m thinking you won’t want to go to the Twitter card web page every time you write a blog, there is a great SEO plugin that has Twitter card functionality! Its the Yoast SEO plugin.

These cards have a “website Twitter account” field and a “author Twitter account” field. The website account is the Twitter account for the website, the author account is the Twitter account of the author. Both accounts get a credit on the card.

To set up the website’s Twitter account, go to the SEO menu on the sidebar of the WordPress backend. Then go to Social. Scroll near the bottom. Make sure the checkbox labelled “” is checked. In the box below it, type the website’s Twitter username (without the @) and click “Save Settings”.

Each author should have their own WordPress login for the blog. In their profile will be two places where they can enter their Twitter username, tell them to enter it into both (again without the @).

The title of the Twitter card will be the title of the post, and the description will be the same as the meta description. The image shown will be the featured image. If you have posts without a featured image, you may want to set a default image in the “SEO -> Social” menu.

Verifying your site

So, now that we have got the Twitter code on our site, we can submit it to Twitter. To do that go back to the Twitter cards dev page and click “Validate and apply”.

There will be a box where you can enter a URL – DO NOT just enter your domain, it must be a page with the Twitter card on it. For example, a blog post. If you enter a URL without a Twitter card on it, the validator will say, no card found here…

After entering your URL and clicking “Go!” you should get a preview of the card (if you are using a webkit browser). Next all you need to do is click “Request Approval”. Twitter will then ask you for some contact, and website information. Fill out the boxes and send off your approval.

It can take Twitter a few days to get back to you, so take a rest. You will be emailed after Twitter look at your website!

I used this method, if you want to test it, tweet this blog post!