Things I tend to forget


Safely Rebooting RimuHosting VPS (via API)

First, get the API keys from the control panel at https://rimuhosting.com/cp/apikeys.jsp
API Keys page

The documentation for the API can be found here

So to reboot, I use the following script:

#!/bin/bash 
APIKEY=00000000000000000000000000
VPSOID=0000000
VPSNAME=whatever
curl -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: rimuhosting apikey=$APIKEY" -X PUT -d '{"reboot_request": {"running_state": "RESTARTING"}}' https://rimuhosting.com/r/orders/order-$VPSOID-$VPSNAME/vps/running-state

That seems to be much safer than running: sudo reboot

Similar Posts:

    None Found




Using ePubLib for Android

I’m rewriting the Examine the Scriptures Daily android app. With the ESD files published as ePub files it’s easier to get the data now, and it will allow more languages to be supported without the hassle of converting from WTLib.

Here’s the code snippet I’m using to read the ePub book. The library I’m using is ePubLib, and I’m displaying the page in a standard WebView:

    // Load the book and get a specific date
    AssetManager assetManager = getAssets();
    try {
		// find InputStream for book
		InputStream epubInputStream = assetManager.open("es12_E.epub");
		// Load Book from inputStream
		this.book = (new EpubReader()).readEpub(epubInputStream);
		getSpecificdate("2012-12-1");
	} catch (IOException e) {
		Log.e("epublib", e.getMessage());
	}

    private void getSpecificdate(String day) { 
		Date d; 
		int dayOfMonth;
		int monthOfYear;
		Calendar cal = Calendar.getInstance();
		try {
			d = dateFormat.parse(day);
			cal.setTime(d);
			String hrefDate = hrefFormat.format(d).toUpperCase();
			dayOfMonth=cal.get(Calendar.DAY_OF_MONTH);
			monthOfYear=cal.get(Calendar.MONTH);
			hrefDate += (dayOfMonth==1) ? ".xhtml" : "-split"+dayOfMonth+".xhtml";
			hrefDate = dblzero.format(monthOfYear+4)+hrefDate.substring(2);
			
            // Here's the part you're looking for
			Resource r = this.book.getResources().getByHref(hrefDate);
			WebView wv = (WebView) findViewById(R.id.webView1);
			String data = new String( r.getData() );
			wv.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "utf-8", null);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
	}

Similar Posts:




Android Plugin for Eclipse Hanging

For a couple of weeks now I have been trying to get the Android Plugin for Eclipse to play nicely on my new 64bit Ubuntu 11.10.
It was always hanging without a good explanation. The only message I got was “Loading Data for Android 2.3.3” and it reaches 100% but stays there.

I thought it was related to the fact that I’m using the latest Indigo (3.7) eclipse, but that wasn’t it (I tried with earlier versions). I also thought it was because of the 64bit java I installed separately (not using apt). That wasn’t it either (the apt installed version didn’t work either). Stupid solutions, I know, but I had to try!

The solution was to rename the SDK directory and remove the _x64 from the end of that. After that, I set it in Windows -> Preferences -> Android -> SDK location and applied the changes and voila! It works now.

I’ll be fixing the ESD app based on some kind feedback from friends. And maybe work on other pending projects as well. Stay tuned.

Similar Posts: