One-click copy paste

Previously I’ve created an AutoIt script to enable one-click copy paste but unfortunately I lost it in my old blog. By request I’ve created a new, and in my opinion even better than the previous one.

Source

To use it, simply select some text, press the hotkey and press the hotkey again to start pasting. By default, the hotkey is F4. Below is the source (I leave it up to you to install AutoIt).

Save this as an .au3 file and you should be able to run it by double-clicking on it (a good idea is to drop it in the auto-start folder if you don’t want to start it manually each time you start). It is possible to compile the .au3 file to a standalone executable that doesn’t require AutoIt to be installed, I haven’t done so as anti-virus and anti-spyware generally blocks it and you’d have to jump trough hoops to enable it.

Download

Here is a direct download for the .au3 file if you don’t want to copy/paste the source code above.

Download “One-click copy paste” OneClickCopyPaste.au3 – Downloaded 1019 times – 1 KB

What I’ve learned during GSoC and phpBB

During this summer I’ve been working on an REST API for phpBB as part of my Google Summer of Code project. I’ve learned a lot about a lot of things during the summer and I’ve surely had one of the best summers in a while! I wanna give out a thanks to the phpBB team, and summarize what I’ve learned and done during the summer.

What I’ve learned

I’ve learned a lot about the open source world which I hadn’t really entered before. Mainly in this regard I’ve learned more about Git and how to do proper pull requests and such (also a lot about rebasing, branching and other useful things I’ve never had done before). I’ve gotten more used to read others code and understand their code as well as modifying it. I’ve also got to pickup the phpBB coding guidelines and it has helped a lot to improve my code.

Another thing I’ve learned (but still need to delve deeper into) is Symfony, composer and dependency injection. Prior to GSoC I had barely used any of them. I managed to use what I learned in other projects almost instantly as I got a new job as a part time web developer at a local company, and we use a lot of these things there (but using Laravel instead of Symfony).

I’ve learned a bit about cryptography and hashing, to use for authenticating the API. To be clear I’m still confused with all of this and probably have to take another look at it later, but I definitely know more about it now than I did before.

I’ve learned a lot about various design practices, and new stuff like repositories, entities and so on, which was new to me. This too has helped me at my new job as we use these kinds of things a lot.

Thanks

I want to thank the phpBB team for accepting my proposal, it has been one of the greatest summer in a long time for me. I’ve learned a lot of useful stuff and I’ve met a lot of new people in the process. I would also like to say thanks for the generous invite to the hackathon in Montreal, it was really fun and I would do it again if I ever get the chance in the future.

A last word

It seems like I’ve given up on the project but I sure haven’t, just that I’ve been busy with some courses at college as well as that I got a new part time web development job taking away my time. I’m still thinking about the API and still planning the next steps, and I promise to finish what I’ve started. I’m currently planning and preparing for my final thesis work this spring, but I probably have some free time now and then when I can devote myself to the API again, don’t worry :).

Canon EOS 1100D

I’ve always liked to take pictures but I only had a digital camera that took worse pictures than my old Samsung Galaxy S2 and my new S4. One thing that I hate is crappy image quality. A phone camera is okay if you want to take a couple of pictures of something interesting you found in your everyday life, as it might be cumbersome to always bring a bigger camera. But when traveling you might want something to take better pictures in mind. Even thought you can get decent pictures from a phone camera in the right conditions, I didn’t trust my S4 to take memorable pictures on my trip to Canada, because knowing myself I would get annoyed by blurry images in the future (thinking back to when I used my mothers rather meh 3mp digital camera on a vacation some 6 years ago when the camera just wouldn’t take a picture of an interesting sign I wanted to save).

I’ve been thinking for a while about getting a dslr but haven’t due to them being quite expensive and it would probably just sit on a shelf anyway. But then my mother mentioned she saw a discounted Canon EOS 1100D at a store. Seemed like a good deal so I went to check up some reviews on it. I figured it’s a good dslr for beginners like me that finds taking pictures fun but may not spend very much time taking pictures. The price makes it a rather good purchase for taking pictures on a vacation.

I haven’t used a dslr before buying this one so I’m still learning a lot of new stuff but so far I’m pretty happy with my purchase. Here’s some pictures I took right after the purchase.

GSoC, phpBB API and hackathon in Canada!

The results from GSoC (Google Summer of Code) has been out for almost 2 weeks now but I haven’t had time to write about it yet. I was one of the six that get to work for phpBB and I’m really excited to do this! As I’ve mentioned earlier I tried to apply to phpBB with the API last year but didn’t have any luck back then but this year I was lucky to be selected.

What I’m gonna do this summer is to create a REST API for phpBB. It would allow developers to create various applications that can interact with phpBB in an easy way. Examples could be mobile applications, desktop applications and more. If you wanna check out my proposal, it’s publicly available here. I think it’s gonna be a lot of fun creating this and I hope it turns out awesome.

Furthermore, I’ve been invited to phpBBs hackathon in Montreal, Canada in July! The event is between July 10 – 14, but I’ve decided to stay a bit longer until July 19 to sightsee a bit and meet up with a friend of mine. It’s gonna be a lot of fun, I’ve only been on a smaller hackathon before that I hosted myself. It will be my first trip outside Europe, I think it’s gonna be awesome.

Open source – Start contributing early

I’ve come to a realization that I suck at contributing to open source projects. It’s not like I dislike contributing to open source or believe I suck at coding, but that I just don’t know what to contribute, how to do it and feeling insecure about my code and solutions. I became interested in programming in 2007 and since then I’ve only coded alone on my own projects. I never contributed to open source projects because the thought never crossed my mind.

It wasn’t until last year when my friend Callum Macrae showed me GSoC (Google Summer of Code) that I (slowly) started to contribute to open source projects. The goal of GSoC is to submit a proposal of how you would make any of the registered open source projects better, and if you are chosen by the open source organization, you’ll implement your proposal during the summer and you get paid by Google for doing so. Last year I submitted a proposal to phpBB to create an API, but I didn’t get chosen (looking back at that proposal I realize how bad that proposal was so it wasn’t a surprise I wasn’t chosen).

To increase ones chance to get selected you’d have to contribute to the project beforehand. I checked the bug tracker for things I could fix but come to a realization: I have no idea what I am doing. As I’ve only worked alone for so long I always knew what bugs there were in my projects and how to solve them, but this wasn’t the case anymore. I checked bug report after bug report but I wasn’t secure enough to fix any of them. Fortunately I found a couple of rather easy ones to get a hang of the open source workflow of phpBB. Here was my next problem: how exactly do I submit my patch? phpBB uses GitHub, and I’ve used git and GitHub before but only for my own use. I read some instructions on the phpBB wiki and asked Callum as he contributes to phpBB as well, and sure enough, just fork the repo, branch from the correct develop branch, fix whatever bug you were about to fix, commit that to your own repo and submit a pull request. Easy enough.

Or not. No one had ever reviewed my code before. No one had ever commented on it. This had led me to become very insecure about my code and I was worried what others would think about my solutions and my coding style. I was unsure what I would put as my commit message, and sometimes even afraid to send the pull request. I managed to fix some four or so small bugs but after my proposal was rejected I got a bit bored with contributing and forgot about it and went back doing my own stuff instead.

This year I’ve tried again with GSoC and phpBB with same idea but a much better proposal than last year and I’m in the same position and I’m trying to get used contributing again. I still have issues with insecurity and how I should solve things the best way, but I’m trying my best to overcome these obstacles and get more active contributing to various open source projects.

The message I want to send is to start as early as possible with contributing to open source projects. Even if you don’t know enough programming yet, check the bug tracker occasionally, try to understand parts of the projects code and when you find a bug report that seems easy enough for your skill level, don’t be afraid to fix it! I believe by contributing to open source projects, you’ll learn to be a better team member and you get valuable feedback on your work. It’s a crucial skill and you really need it later in life when you are working in teams at whatever job you get.

I know for one that currently I’m not the best at working in teams. I’m doing ok with groups of 2 – 3 persons, but when working in large groups I have a hard time making myself useful for the rest of the team. I do wish I’ve started contributing to open source projects earlier in my life so I would be more prepared at it when starting college, but I guess it’s better late than never am I right?

My take on Windows 8

Last week I had some days of free time so I decided to upgrade my Windows 7 computer to Windows 8. I had received a free copy from Dreamspark premium (trough my university) so I thought: Why not? I had some problems with my old SSD being too small (an OCZ Vertex 2 60GB) and filled up a lot even though I tried keeping most software and data on my HDD (some stuff required to be installed or install components on C:, like visual studio). After taking the wrong bus and traveled for 4 hours (that’s another story), I managed to buy a SanDisk Extreme 120GB SSD. I live in a town with few hardware stores and that was the best I could get my hands on without ordering something online and waiting for it to shop.

My current system spec are:

  • CPU: Intel i7 950 3.06GHz
  • Motherboard: Gigabyte GA-X58A-UD3R
  • RAM: Corsair XMS3 Vengeance DDR3 PC12800/1600MHz CL9 3×4 (12)GB
  • GPU: Kfa2 GTX 570 1280MB
  • SSD: SanDisk Extreme SSD 120GB (550MB/s read, 510MB/s write)

(I kept the OCZ  Vertex 2 60GB and the 250GB HDD)

Windows 8 Installation

The installation went really smooth. Nothing different really from the Windows 7 installation, just a lot faster but maybe that’s because the new SSD. It was done in some 10 – 15 minutes (I thought it would take longer, so I had planned to clean my apartment for once when I’m without a computer, but I guess that’s for another time).

The post-install was really smooth. Everything worked perfectly from the start and most of the drivers were automatically installed trough Windows Update. The only thing I had to install myself was the (awful) Logitech Gaming Software to be able to configure the macro buttons on my keyboard, mouse and headset.

After that was done, I had to install my software again but it wasn’t something special about that, just the same stuff you do on every os.

The new UI

The new thing, as probably everyone know by now, is the new UI. When I see people talking about Windows 8, it is mainly about of how awful, bad and table-centered the new UI is. I disagree with this. Ever since I got Windows 8 I’ve had much more fun using my computer than before. Sure, it takes a bit of time to figure stuff out, but once you do it’s really easy to use.

The metro interface

The new UI

A lot seems to be annoyed with the missing start button in Windows 8, but in reality, metro is the new start button and it does pretty much what the old start button does. It lists all your installed programs, but it also displays apps and widgets. You can still start typing to open the application you are looking for, no need to look trough all tiles for the app you wanted.

The hover bars

The left hover bar

The left hover bar

The hover bars are the bars that popup when you hover the left or right part of the screen. The left one contains the start button and all running windows store applications, and normally desktop (desktop applications are still in the taskbar when in desktop mode). It’s pretty straightforward. The right bar contains functions like a search button, settings, sharing and such.

A problem I’ve discovered is that it can be rather hard to open the bars if you have multiple screens as me. Luckily my main screen is 1080px high while my secondary is only 1024px high so I get some space in the top-right corner where the mouse cannot travel to the other screen, but if it were screens with identical resolution it would be rather hard to get the menu open.

The right hover bar

The right hover bar

Windows App Store

I think it’s decent but it needs some work. The first thing I had issue with was: how do I search? The search button is placed in the right hover bar and I know it’s meant to be the same location for each app, it’s nothing you remember easily. Then add in the difficulty to open it if you have a second screen on the right side. Win+F seems to open file search and from there you can select to search in the app store and such you don’t have to hover the bar, but still cumbersome.

The windows store

The windows store

Next issue was a setting “Find it easier to find apps in my preferred language” that was on by default. A more accurate name for that setting is “Exclude all apps not in my language”. There was just a dozen apps in Swedish and I was confused why I couldn’t find stuff.

Other than that, there isn’t much to say really.

The plex app

The plex app

Conclusion

In my opinion Windows 8 was a worthwhile upgrade from Windows 7. It’s fairly easy and fun to use and there are a lot of new possibilities. I might just even try creating a few apps, it looks interesting so I have to decide on what I should create.

BitPoint, a simple bitcoin betting game

The front page of BitPoint

The front page of BitPoint

I’ve been working on a small project last week, I call it BitPoint. It’s a pretty straight forward gambling game paid by bitcoins. A short summary of bitcoins for those who do not know: It’s a online, decentralized cryptocurrency that can be used to buy stuff from other bitcoin users. It can be exchanged to other currency by trading with other users (and by the time writing this 1BTC is worth USD20). If you want to know more, check the link above.

How it worksYou start of by buying a point in the field (by clicking anywhere). Each point costs a small amount of BTC (the cost per next point increases for each point, if first point costs 0.005btc, next point will cost 0.005+0.005btc). The bitcoins from each point is added to the jackpot. Each day at midnight UTC a random point is selected on the field with a certain radius. Every point inside this radius is a winner and will split 70% of the jackpot amongst them. 20% of the jackpot goes to the next round and 10% to me (the jackpot number on the front page already takes this into account and that is the actual amount that will be split!). If no one wins, 100% of the jackpot goes to the next round.

So why don’t you go check it out!

Python: Getting the title of windows, getting their processes and their commandlines using ctypes and win32

My latest assignment for Commie was to create a plugin for xchat to list running encoding processes in the staff IRC channel. You can write plugins in a few various languages and me knowing a little bit of Python I chose to do it that way.

The problem I was facing was to find all windows of x264, fetch their titles (which included how far the encoding was, time remaining etc), and output each title to the channel when a user would say “.encoding”.  Easy enough, I thought, I’ll just fetch all processes and check if “x264” is in the title. I found some methods and code snippets using pywin32 (win32gui, included in pywin32). Unfortunately, xchat only supports Python 2.6 (which is a rather old version of Python) and the windows installer for pywin32 for Python 2.6 is broken and I didn’t manage to compile from source either, so I had to find an alternate way of doing it without any libraries.

Luckily, I found a way of getting all windows titles using ctypes (which is included in Python by default) and the win32 API (thanks to this blog post). It worked really well and from there I managed to easily get the titles I wanted and send them to the IRC channel. Unfortunately, the titles didn’t contain what was encoding, so it would be pretty useless to know that something is 50% done.

Looking around a bit, I managed to find a way to get what was being encoded. The commandline of the process that started the encoding included the directory name of what was encoding. Now I needed to somehow fetch the commandline, but I only had a window and not a process. Having the window I obviously had the window handle. By reading some documentation I found the GetWindowThreadProcessId, which returns a process id from a window handle. Now that I have that, how do I easily get the CommandLine? The easiest way I could figure out was to use WMIC, a commandline interface to WMI (a type of query language to fetch various stuff from the OS, something in the lines of that). From this on it was only some formatting left to do. Below is the full code. Hopefully others can use it to understand how it works, as I had some troubles searching for the right way to do this (all thought it may be a rare thing to do).