How to end subscription when Amazon AWS EC2 free tier has expired.
I just got an email saying that I had been charged 1$ for services Iâd been using during July, although I thought I had stopped using any services on AWS long ago, and became a bit surprised. When googling how to end my subscription for Amazon AWS EC2 I didnât get any results. So I decided to write what needed to be done in a blog post.
Looking at the bill, it says:
Then I clicked the EC2 icon, and got this overview showing resources:
I supposed the Volumes was the culprit here, so I just clicked âVolumesâ and got into this page:
I selected the volume by clicking the little box in the left column, and then when to the âActionsâ menu and chose âDetach Volumeâ and then clicking âyesâ in the popup asking if Iâm sure.
I then chose âDetached Volumesâ in the dropdown menu, and the volume showed up in âavailableâ state. I select it again, and this time I chose âDelete Volumeâ in the âActionsâ menu, and clicked âYes, deleteâ in the popup.
Now when going back to the EC2 overview, the resources show 0 Volumes (this took a minute or so to get updated though).
Now Iâm presuming my credit card will not be charged in the future.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Qualityâ Free Actions
Free to watch ⢠No registration required ⢠HD streaming
Installation of fcgiwrap:
If you are on Debian you might just need to do:
$ apt-get install fcgiwrap
For RHEL/CentOS/etc there is no rpm ready. Instead, do the following:
$ cd /usr/local/src/
$ git clone git://github.com/gnosek/fcgiwrap.git
$ cd fcgiwrap
$ yum install fcgi-devel make automake autoconf
$ autoreconf -i
$ ./configure
$ make
$ make install
Running fcgiwrap with supervisord:
Instead of manually starting fcgiwrap, it is a good idea to have some monitor software to start it. Here is how to do it with âsupervisordâ.
(Install with âyum install supervisorâ. Start with âservice supervisord startâ)
Next check where fcgiwrap was installed:
$ which fcgiwrap
/usr/local/sbin/fcgiwrap
Now create a file git_fcgiwrap.ini in /etc/supervisord.d/ with the following content:
Yahoo provides an excellent tool for composing your own customized RSS feed by combining RSS feeds available on the Internet. You can apply filters if you e.g. are interested in a certain topic, and sort the articles in the order you want. You can even create an RSS feed from a normal html page, which doesn't supply an RSS feed. Actually I just discovered Yahoo Pipes, and it provides more features than I would have dreamt of, all packaged in an easy-to-use drag-n-drop web GUI.Â
I put together a feed that collects english speaking news for all over the world, and filters them to produce only items containing the words 'sweden', 'stockholm' and 'swedish'. In this way I've created a feed that should publish any english news about Sweden, available here: http://pipes.yahoo.com/pipes/pipe.info?_id=fb0dc72671348bbc72009ad9c1ee157d
Next thing to do, is to automatically publish the news to a Tumblr blog. In order to publish automatically, you need a linux server. I got mine from here. Next you need to log in to the linux server, and install the tools 'catfeed', 'ypipe' and 'tumblr-cli'. This is done using the following command:
pip install catfeed ypipe tumblr-cli
In order to be able to post to tumblr using tumblr-cli, you need to generate keys. See this post for further instructions: http://www.klofver.eu/post/39789325684/tumblr-command-line-interface-tumblr-cli
But this pipe will only live as long as you are logged in to your Linux server, and you probably want it to go on forever. Then start it with e.g. 'screen' or 'nohup'.
With screen you create a persistent shell screen, which you can attach to/detach from.
Show which screens you have running by doing:
screen -ls
Create a new screen named 'yahoo-to-tumblr-pipe' by doing:
Detach from the screen by doing 'ctrl-a d'. You are now detached and may safely log out from the console, with the screen living further. To reattach to the screen, do:
screen -r yahoo-to-tumblr-pipe
And here is the Tumblr blog that receives the feed: stopsweden.tumblr.com
Note:
Only new posts will appear on the blog. If you want some older articles to be posted, change the argument '-b0' to e.g. '-b10'. You might also note that the yahoo pipe contains a lot of posts which aren't published on the Tumblr blog, while there are posts on the Tumblr blog which aren't available in the feed. This is because a feed normally only contains about 40 posts. This means that on a site with a faster news flow, a post will sooner disappear from the feed, pushed away by newer posts, while posts from sites with a slower news flow will remain although the posts are older.
In the following example, we would expect the same behaviour, since 'grep o' should match both words, however, both 'Hello' and 'world' will be printed simultaneously after 5 seconds. This is because of buffering:
python -c "import time; print 'Hello'; time.sleep(5); print 'world'" | grep o
Hello
World
To prevent it, you can call python with '-u'Â (or use PYTHONUNBUFFERED=Y environment variable), which runs python unbuffered:
$ python -uc "import time; print 'Hello'; time.sleep(5); print 'world'" | grep o
Hello
world
You can also control flushing of output from within the script, like this:
$ python -c "import time,sys; print 'Hello'; sys.stdout.flush(); time.sleep(5); print 'world'" | grep o
Hello
world
 If you want to set stdout to be unbuffered from within the code, without doing flush all the time, do this:
$ python -c "import time,sys,os; sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0); print 'Hello'; time.sleep(5); print 'world'" | grep o
Hello
world
It might also depend on the command you are piping to whether output gets buffered:
This does not work since the tail is not applied until the output is finished, thus when EOF is received.
If you are using 'py2exe', you can package your application to be run unbuffered by adding the unbuffered option in setup.py:
options={"py2exe":{"unbuffered": True}}
Unbuffered output is probably something you want in most command-line utilities. But what should you do if you need to use an existing command which isn't unbuffered, and you don't want to modify it? There is a command named 'unbuffer' which takes care of this. The 'unbuffer' command is part of 'expect'.
You can use it like this:
$ unbuffer python -c "import time; print 'Hello'; time.sleep(5); print 'world'" | grep o
Hello
world
You may want to create a process which reads from a fifo forever, and to which you could just write whatever input you would like. You probably tried doing this:
However, this doesn't work completely. "Hello world!" will be printed on [tty1], but the command 'cat /tmp/testfifo' will exit since EOF is received.
Here is a trick to prevent this. Use 'tail -f':
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Qualityâ Free Actions
Free to watch ⢠No registration required ⢠HD streaming
Get your own Linux server, available anywhere anytime
Linux has proven very well for such purposes, and SSH clients are available for all operating systems, so you don't need a Linux computer in order to get your own virtual Linux server. On the server you can run whatever you can think up, web servers, Git repositories, backup services and more. As you learn more, you will think up more and more use for it.
You can try a similar service as Linode for free using the Amazon EC2 free usage tier, however, their service seems to have been made by masters of business, making it very hard to navigate, and their price plans and vocabulary is very hard to grasp. As an example, here are all the services Amazon says I am signed up for, which are shown when logging in:
Amazon CloudFormation
Amazon CloudFront
Amazon CloudSearch
Amazon CloudWatch
Amazon DynamoDB
Amazon Elastic Compute Cloud (EC2)
Amazon Elastic MapReduce
Amazon ElastiCache
Amazon Glacier
Amazon Mechanical Turk
Amazon Relational Database Service (RDS)
Amazon Route 53
Amazon Simple Email Service (SES)
Amazon Simple Notification Service (SNS)
Amazon Simple Queue Service (SQS)
Amazon Simple Storage Service (S3)
Amazon Simple Workflow Service (SWF)
Amazon SimpleDB
Amazon Virtual Private Cloud (VPC)
Auto Scaling
AWS Data Pipeline
AWS Direct Connect
AWS Elastic Beanstalk
AWS Import/Export
AWS Storage Gateway
Elastic Block Store (EBS)
Elastic Load Balancing
Product Advertising API
Quite a list. When navigating their pages I might find what I am looking for, but then later I never find it back again. Its a feverish feeling, and still, after getting things up and running, using the server feels slow. I guess it makes more sense in a corporation where you get paid for the time spent with it, but otherwise it feels a bit frustrating.
I did finally succeed to create a free usage tier virtual server at Amazon, but I experienced unbearable lag (latency) when using the Amazon service (when trying from Canada) in comparison with Linode (On Linode it was unnoticeable). Now I tried it again from Sweden, and it felt better. When comparing ping times Amazon node answered in 114ms while Linode answered in 35ms, so Linode was still 3 times faster. When starting X applications, Linode feels much faster, but otherwise I didn't notice much difference.
With the Amazon free tier, the first 12 months are free under certain conditions (such as up to 750 machine hours a month) and above this it will cost. You need to register your credit card, and when googling the matter, you can see that a lot of people have ended up charged, when they thought they where using the free service. If something went wrong and a process spins away, it could be costly. It felt hard to survey what it would cost, and in the end it seemed to me that it will be less expensive with Linode, which costs $19.95 per month. Linode just feels solid and like it should be, and I've never had anything to complain about during my time of running a virtual Centos 6 server.
As a bonus, Linode now and then upgrades the service, and you get more performance for the same money, e.g. 14 December 2012 the storage increased by 20%.
Conclusion:
If you absolutely want a free node, go with Amazon EC2 as it is the only alternative. If you find the complexity stimulating, you might also prefer Amazon, but otherwise I recommend Linode. It is totally worth the monthly fee.
To sign up for Amazon AWS EC2, go here
To sign up for Linode, sign up here
Now, whenever you have made changes, you can backup/version control your blog, by just running 'tumblr-cli-backup --git example.tumblr.com'.
This could easily be scripted to make a daily backup of your blog.
First you will need to create an nRelate account, which is done here: https://partners.nrelate.com/registration/
Now log in using your new account, and choose Install->Tumblr
Enter your site's URL, e.g. 'http://example.tumblr.com/', and submit.
Now you will asked where to place the related posts. I chose 'Posts Only', and got presented with the necessary HTML/CSS/JavaScript, and an instruction where to put it.
Follow the instructions, surf to a post of your blog, and related posts should now appear.
To change style and other properties, go to 'Manage Settings'->'Tumblr', where you can choose thumbnail size, number of posts and much more. For the settings to take effect after you have saved them, you need to push 'Reindex Blog'. This takes a lot of time depending on the size of your blog (+10 minutes for mine).
You can see how the different styles look here:
https://partners.nrelate.com/wp-content/themes/partners-main/images/style-gallery.html
After trying them out, I decided to use the Default style, which should now appear below...
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Qualityâ Free Actions
Free to watch ⢠No registration required ⢠HD streaming
In this post I will describe how to distribute a Python package so that it will be installable from PyPI (Python Package Index).
Prerequisites:
A new Google Code project (or any other project hosting service). Create one here: http://code.google.com/
A PyPI account. Get one here: http://pypi.python.org/
Some Python code that you want to package.
Most important when preparing a Python package for distribution is to create the setup.py. This is the setup.py I used for tumblr-cli:
(If you want to see how it relates to the code structure, look here: http://code.google.com/p/tumblr-cli/source/browse?repo=default)
Most of the above variable names are self-explanatory. The 'url' is the homepage of the project. As you can see, I am hosting my project on Google Code. The 'download_url' points to the actual package, which I uploaded on the project homepage at Google Code.
To generate a package to upload, just run:
python setup.py sdist
After uploading the package to Google Code, you will want to register it at PyPI. This is simply done by running:
python setup.py register
Now it can be installed from PyPI with this command:
pip install tumblr-cli
(The "pip" command name may vary, on my system it is called "pip-python")
Post to Tumblr from Zim Desktop Wiki with tumblr-cli
All good software (at least editors) has a way of calling an external command for external functions. So has Zim, my favorite tool for making drafts and organizing thoughts and ideas. Zim is available for all common platforms (Windows, Linux, Mac) and can be found here:
http://zim-wiki.org/downloads.html
I have got a Tumblr button in my Zim for publishing posts directly to Tumblr:
In order for posting to Tumblr from Zim, you need to install 'tumblr-cli', a python package available on PyPI.
First follow the instructions on this blog post, to install and authorize posting to your blog:
http://www.klofver.eu/post/39789325684/tumblr-command-line-interface-tumblr-cli
You now need to add the Tumblr button in Zim, which is done by going to 'Tools'->'Custom Tools', clicking '+' and entering:
Name: Tumblr Draft
Description: Uploads the page to the Tumblr drafts
Command: tumblr-cli-zim-tool example.tumblr.com %d %n
Icon: <choose an icon>
Check 'Show icon in toolbar' and click 'OK'.
See the picture to get the idea:
Since I am using python-virtualenv, the command I use looks slightly different, i.e:
/home/chrisk/virtualenvs/my_virtual_env/bin/python /home/chrisk/virtualenvs/my_virtual_env/bin/tumblr-cli-zim-tool www.klofver.eu %d %n
You should now be able to publish drafts from Zim. If you want to make them public directly, add this argument '--param state=published' to the command.
Or choose a state from these: published, draft, queue, private
More parameters are specified here:
Finally I got a first version of tumblr-cli ready. The CLI currently only supports posting of text, and by default the posts will be published as drafts.
On a properly set up system, you should now be able to run the following command in order to install tumblr-cli:
pip install tumblr-cli
You will now be able to run the command. Try '--help' first:
         [--title TITLE] [--param KEY=VAL] [--forceauth]
         [--config FILE] [--pdb]
Tumblr Command Line Interface
optional arguments:
 -h, --help     show this help message and exit
 --blog BLOG    The blog to act on. E.g staff.tumblr.com or www.klofver.eu
 --authorize    Authorize to blog
 --post_text FILE  Post a text file to your blog
 --title TITLE   The title to be used in posts
 --param KEY=VAL  Extra parameter. See valid parameters and values here:
          http://www.tumblr.com/api_docs
 --forceauth    Reauthorize to blog even if there already is a valid
          access token.
 --config FILE   Configuration file
 --pdb       Puts you in pdb mode if any exceptions are raised.
To be able to make use of the command you first need to register an application, which is done here: Â
http://www.tumblr.com/oauth/register
You will then get a consumer key and secret, which you will need when authorizing to a blog. For authorizing to a blog, run the following command and follow the instructions like this:
$ tumblr-cli --blog=www.klofver.eu --authorize
No value for consumer.key found.
What is the value for consumer.key? 8kafk9NNM5RpaLFxc3PM59Ef0JCmMLGKM
No value for consumer.secret found.
What is the value for consumer.secret? ZECx3UH0JIsASxeSIk1r5vkrtKY9peblgS
What is the oauth_verifier? Rq1ZQwjLECZ8kafk9NNM5RpaLFxc
After setting all the necessary values and fetching the oauth_verifier, you should now be authorized to make changes to the blog. Try posting a new draft using the following command:
Just created a new Python Project on Google Code named tumblr-cli. Intention is to make a command-line tool for publishing posts on Tumblr.Â
The initial setup of a new Google Code project was all straight forward, except for choosing a license (which can be a jungle). I went for GPLv2. I choose Git for version control. The instructions for checking out the repository was pretty good. Just go to the "source" tab and follow the option 2 alternative, creating a ~/.netrc file , adding code.google.com and then giving it the right permissions as follows:
How to set up a dual screen layout automatically on linux
If you are having a laptop as your main computer, sometimes you may still want to use it as a desktop computer, using an external monitor and keyboard. Then you'll want to treat the external monitor as the main screen, and use the laptop monitor as an extra screen. Since I always put my laptop to the right of my monitor, I've set it up to automatically set the monitor as the main screen, and the laptop as secondary to the right of it, when attaching my monitor. When detaching, the laptop immediately becomes the main screen, and all applications are still visible. Now I can come and go freely, without any screen layout problems. This is how it is accomplished:
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Qualityâ Free Actions
Free to watch ⢠No registration required ⢠HD streaming
This could have been a really interesting alternative, if it had worked. Unfortunately the result ended up very strange for me.
I uploaded a piece of code like this:
https://gist.github.com/4423995
And tried embedding it like this:
And the result looks like this (A scrollbar for every line):
Trying a similar service, pastebin.com, was more successful:
But either way its a bit tedious for adding small code snippets, such as oneliners etc. Instead I tried Google's Prettify, following the instructions from this post:
http://ghoti143.tumblr.com/post/1412901908/google-code-prettify-tumblr-love
But unfortunately I didn't have much success with that one either. Code seemed to disappear, and just some got presented in the blog post. Probably it had to do with escaping of angle brackets, as the post mentions this. But having to escape those also interrupts the work flow, so I abandoned this method as well.
I tried a couple of more similar methods, but apart from not being easy to use, they also were making the page load a bit too slow. So instead I settled with just making a CCS style for code snippets using a fixed width font. Unfortunately indenting doesn't work well. So I think I'll use pastebin.com for longer scripts, and use the CSS style for shorter code snippets.
To use it, just surround the code with the following tags: <div class="code_snippet"></div> in your blog post (In HTML editor mode). You can see the result above, as this code are using the "code_snippet" class.
I still think there should be better ways to accomplish this. There are a lot of browser addons for Tumblr, and also desktop applications, but so far I haven't found a reasonable editor where I can include properly indented and presented code snippets. May be it is possible to accomplish through the Tumblr API? If I get time, I think I'll have a look.
Give me a hint in the comments if you have found better ways for dealing with this.
Adding social sharing buttons to a website is quite easy. Facebook, Google, Twitter, etc all got code generators for generating their buttons. However, they differ a bit in size and form, and just putting them side by side looks a bit sketchy. To make them uniform, add the following CSS:
<!-- My CSS -->
<style type="text/css" media="screen">
div .g-plusone, .twitter, .fb-like {
font-size: 1px;
display: inline-block;
float: middle;
}
div .fb_reset {
display: inline;
}
</style>
To add the buttons, make sure your <html> tag looks like this <html xmlns:fb="http://ogp.me/ns/fb#">, and add the following where the buttons should appear (I put it right before the tags "{block:IfDisqusShortname}{block:IndexPage}"):
<section class=âcaption groupâ>
<div class=âcont content_sourceâ>
<div style=âfont-family: âTimes New Romanâ,Times,serif; font-size: 8pt; color:rgb(0,0,0);â>
Feel free to like this article if you had any joy of it.<br>
</div>
<div class=âfb-likeâ data-href=â{permalink}â data-send=âfalseâ data-layout=âbutton_countâ data-width=â450â data-show-faces=âtrueâ></div>
<!â Place this tag where you want the +1 button to render. â>
<div class=âg-plusoneâ data-size=âmediumâ data-href=â{permalink}â></div>
<!â Place this tag after the last +1 button tag. â>
<script type=âtext/javascriptâ>
(function() {
var po = document.createElement(âscriptâ); po.type = âtext/javascriptâ; po.async = true;
po.src = âhttps://apis.google.com/js/plusone.jsâ;
var s = document.getElementsByTagName(âscriptâ)[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<div class=âtwitterâ>
<a href=âhttps://twitter.com/shareâ data-url=â{permalink}â class=âtwitter-share-buttonâ>Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=â//platform.twitter.com/widgets.jsâ;fjs.parentNode.insertBefore(js,fjs);}}(document,âscriptâ,âtwitter-wjsâ);</script>
</div>
</div>
</section>