Tag Archives: snippet

Using MySQL + xargs to restore a Mydumper backup

Split the restore, first the schema, then the data:


dump# ls my_database.* | grep schema | xargs -I % -n 1 bash -c "mysql anotherDB < %"
dump# ls my_database.* | grep -v schema | xargs -I % -n 1 bash -c "mysql anotherDB < %"

Skip restoring data for a few tables:


dump# ls my_database.* | egrep -v 'tbl_a|tbl_b|tbl_c' | grep -v schema | xargs -I % -n 1 bash -c "mysql anotherDB < %"

Reference: http://www.dctrwatson.com/2010/07/using-mydumper-to-parallel-dumpimport-fromto-mysql/

Similar Posts:

Tagged ,

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:

Tagged , , , , , ,