Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Monday, November 22, 2010

Build Your Own Backup System on Linode

I have recently finished moving couple of our virtual servers instances from Slicehost to Linode, and I'm quite happy with them so far. Very flexible with their Web interface, decent support and about two times less expensive than Slicehost (which adds up pretty quickly if you run multiple instances). One more good thing is that you can actually build _your own_ backup subsystem using their API and allocated storage space, without paying anything extra (while you can still pay to use pre-built one :). E.g. here is a quick Ruby script that, run weekly, creates a copy of a disk. You need to keep enough of free space though, however, this wasn't an issue for me (I had about twice as much free for every instance).

 

require 'rubygems'

require 'linode'

 

api_key = 'SecretKeyGoesHere'

linode_id = 12345

disk_id = 67890

backup_disk_id = 0

backup_label = 'weekly'

 

l = Linode.new(:api_key =>; api_key)

 

# 1. Find the backup named 'XXX' and remove it first

result = l.linode.disk.list(:LinodeId => linode_id)

result.each do |i|

    backup_disk_id = i.diskid if i.label == backup_label

end

p "Backup disk named #{backup_label} # #{backup_disk_id}"

 

# 2. Remove old backup

remove_job = l.linode.disk.delete(:LinodeId => linode_id, :DiskId => backup_disk_id) if backup_disk_id != 0

p "Remove job status: #{remove_job}"

 

# 3. Duplicate disk

duplicate_job = l.linode.disk.duplicate(:LinodeId => linode_id, :DiskId => disk_id)

p "Duplicate job status: #{duplicate_job}"

 

# 4. Rename duplicated disk as 'XXX'

rename_job = l.linode.disk.update(:LinodeId => linode_id, :DiskId => duplicate_job.diskid, :Label => backup_label)

p "Rename job status: #{rename_job}"

 

P.S. I am so pissed off with broken markdown support at Posterous, that I am ready to give up and move my blog away from it.

# Posted via email from opportunity__cost

Friday, April 23, 2010

AJAX Applications Crawlable

An easy guide from Google on how to make AJAX crawlable. Enough said.

# Posted via web from opportunity__cost

Monday, May 25, 2009

Cracking the GMAT

So, the GMAT story continues. I'm constantly failing to keep up with a stable and a fixed schedule for my GMAT. I would say nothing saying that I'm getting mad on myself because of not being able to keep it the way I want.

However, too many things are happening around, a lot of things need to be done at my job, I need to invest a fair amount of time for the Founder Institute program, plus a number of other things that still need my time and input.

Did I say that I'm married and have a handsome son, who also seeks my time? He doesn't get enough as well. (Hopefully, it helps him to respect it.)

Well, one should say that the right time planning would be an answer, however, I always was good enough with scheduling my time, so it's more about something else.

Whatever, down the road with Cracking the GMAT 2009, and I'm still pretty concerned about the value of it. I already saw the number of sample questions in the end of the book, however, I was actually looking for the hardcore cracking tips and tricks, more on the theory side. 50 pages more, and I'm still reading about pretty basic algebra problems with the list of hints that don't really make much sense to me.

I'm especially frustrated with a very often mentioning so called "scratching" and "plugging in" things. As I've been told, the GMAT takers are pretty limited with amount of scratch paper, and even when they're given it, you have to manage the available space on the paper wisely — we won't be given an extra paper, as well as we don't have anything to erase, but our own fingers and shirt-sleeves. So why should we learn to scratch a lot, when we need to train the brain instead?

From the other side, why are the book authors are idolizing "plugging in" so much? Well, this technique can save you if you have problems thinking in x, y and z, but you should better train how to do this. I could hardly find any example which is a proper usage for "plugging in". The most of these cases were fairly easy to solve with making up an equation. (And I am not the brightest guy in math!)

So I'm pretty disappointed and starting to look for other books.

Tuesday, February 10, 2009

Dashboard widgets

I'm giving a quick look at the Mac OS X Dashboard widgets. I knew that they're pretty much HTML + CSS + JavaScript piece of code, with some features on the top, but never worked with them before.

However, even while the world goes into cloud, I like the dashboard widgets and found them to be pretty useful for many types of tasks. Anyway, until the computer is not the browser (it might be so, someday, though), there is a market for desktop software.

As it comes out, you can start doing them pretty easy by using Dashcode. It's still in beta, but gave me a pretty solid impression and made them process very clear for me.

Literally, it takes only few steps to produce sample widget. More then that, you can also test it right within the Dashcode environment. I was prepared for overriding the dashboard into debug mode and placing widgets on the desktop for further development, but using Dashcode makes it much easier. (I'm still going to place some widgets on the Desktop anyway.)

The only thing that Dashcode doesn't make very easy, is how to get the link to the actual widget package. I found it to reside within the project's folder, but it looks like this is something I could just click and get from the menu bar.

Now I'm going to keep the designers and developers busy with nice picture and functionality, so I can continue playing with the widget.

Tuesday, June 3, 2008

Downgrade from Visa to XP on Sony VAIO

A friend of mine got stuck trying to downgrade his pretty new Sony VAIO VGN-TZ150N from Vista (it sucks!) to XP. While I was able to to find all drivers for him (they're available for free at esupport.sony.com), he couldn't get through the "blue screen of death" when trying to boot from the Windows XP Pro installation CD. Neither did I. Finally, it worked out to be impossible to install the WIndows XP Pro, unless you're using a bundled installation CD that comes with SP2 already.

It took a huge portion of the day, but finally, I got the CD and the installation went fine. Installing all drivers took the rest of the day, but now everything works flawlessly and much faster (Vista sucks!).

Alternatively, you can always order a Windows XP Recovery CD from Sony at https://www.qdirect.net/Sony/VistaDG.aspx (well, not actually always but before the 6/30/2008) and look for a free shipping promotional code at http://www.sony.com/business/downgrade (at the moment of writing this post it's Q93R7). However, a lot of customers report this to take a lot of time, if ever happens.

Tuesday, May 20, 2008

iPhone pseudo-GPS code (iLoJack)

This is an iPhone pseudo-GPS. The one that I called iLoJack. You can download it here at http://prokhorenko.us/white/iphonegps.zip.

Yes, it works. ;) There were some issues, but I'll give you a chance to discover them and fix yourself. ;)

I've developed a simple wrapper to run the Erica Sadun's findme-muchbetter to get the location of the phone and send it to Twitter. Also, it uses Erica's pingwifi, however, I didn't find this to be useful for myself (and my iPhone).

Your iPhone has got to be jailbroken and should be running a decent software update. I don't remember which one is the absolute requirement, but as far as I can recall 1.1.3+ was okay. If you are not sure what all this mean, you should better stay away. I don't think you can screw something up with my application, but you definately can end up with full restore. ;)

It's a pretty smart wrapper (with the most of constants left at the top of the script), but you've got to be tech savvy and kind of geeky, too. It knows how to use proxy. So, it'd be helpful if you're using T-Zones and don't want to pay any penny more. ;)

I didn't have any spare minute to provide an Installer.app wrap for it. There were few guys that volunteered to do this, however, I'm not aware of any repository that carries such an application. I also included a small code that allows your iPhone to wake up from the sleeping in specific period of time. (No source code for it, but I will include it upon request. Just leave me a comment here.)

The archive has a .plist file that you need to use for starting the keeper.sh when the iPhone boots up. Everything else would be done by keeper.sh and twee.sh. Make sure that you adjust them for your situation. They are pretty simple, but you still need to understand at least something about /bin/sh. ;)

Here are some notes on installation:
  1. Make sure you have BSD subsystem installed.
  2. Upload all files to your iPhone to some directory.
  3. Use Terminal.app from computer or directly from iPhone.
  4. Change to the directory where you uploaded files.
  5. Run cp -v ./com.qwe3.twee.plist /System/Library/LaunchDaemons/com.qwe3.twee.plist
  6. Run cp -v ./findme-muchbetter /var/root
  7. Run cp -v ./pingwifi /var/root
  8. Run cp -v ./twee.sh /var/root
  9. Run cp -v ./keeper.sh /var/root
  10. Check /var/root/twee.sh for your proxy settings (if you are using T-Zones you may want to use the proxy for curl) and for your Twitter username and password.
  11. Check /var/root/keeper.sh for timing. I found 20 minutes to be good enough. When the phone is sleeping, the updates are coming every 30 minutes (keeping in mind that you set your Mail.app be checked every 15 minutes). When the phone is up, the updates are coming every 20 minutes. You can find the best numbers for yourself.
  12. Launch keeper launchctl load -w /System/Library/LaunchDaemons/com.qwe3.twee.plist
Feel free to use the code or to share it with anyone. If you want to use it for commercial application, drop me a line and I think I can get a written license for you (but you still need to come up with a deal with Erica for her code).