Recovering from a SAXParseException error with no data loss

I was working on a book I’m writing in LibreOffice Writer. I am using the docx format for the book, as I plan to finish its formatting in Microsoft Word, not knowing that LibreOffice Writer has a tendency to corrupt docx files. After closing and opening the file again, I received the following error:

I extracted the docx file (which is just a zip file, on Windows you can rename it to something.zip to extract or, while Ubuntu Linux allows you to extract it without renaming it). Found the document.xml file and opened it in VIM. I used the following command to jump to position 791513 on line 2:

791513l

That is the position number followed by a lowercase L.

I don’t see any error there, so LibreOffice Writer is not telling the truth, the error is not there. I opened document.xml in Chromium, but it reported the same wrong error position. Since the error message I received was saying the “w:cstheme” attribute was redefined, I decided to use regular expressions to search for it. I spent a stressful hour trying to learn VIM’s ridiculous regular expression syntax, but couldn’t figure it out.

In the end, I decided to use egrep instead. I ran the following command on the command line, which looks for a “w:cstheme” attribute that is not separated by a forward slash from antoher “w:cstheme” attribute, meaning it will find tags that have duplicate “w:cstheme” attributes, which is the error that LibreOffice Writer is reporting:

egrep "w:cstheme[^/]*w:cstheme" document.xml

And voila! It highlighted the error:

I copied the highlighted text (using ctrl+shift+c), opened document.xml again in VIM, and pasted the text in VIM’s seach bar (first press forward slash to open the search bar, then ctrl+shift+v to paste):

Pressing enter twice, it jumped right to the line and position (“column”) where the error was, which was actually position 817157:

If you understand html/xml, you will see the issue. To correct it, change this:

<w:rFonts w:eastAsia="Times New Roman" w:cs="Times New Roman" w:cstheme="majorBidi" w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cstheme="majorBidi"/>

To this, removing one of the unnecessary ‘w:cstheme=”majorbidi”‘ attributes:
<w:rFonts w:eastAsia="Times New Roman" w:cs="Times New Roman" w:cstheme="majorBidi" w:ascii="Times New Roman" w:hAnsi="Times New Roman" />

I searched again for the error in VIM, to make sure there were no repeated errors. I fixed multiple other occurrences of the error until I couldn’t find any more. Now, when opening the document.xml in Chromium, no error was reported:

This was a good sign. I made the mistake of compressing the parent folder of the document, renaming it to docx, and trying to open it. LibreOffice Writer said the document was corrupted and offered to fix it. It tried but failed. After a long time, I realized my error. I shouldn’t have compressed the parent folder, I should have compressed the files and folders inside the parent folder directly, as follows:

Above I have selected the files and folders that make up the docx document. I then right-clicked it and chose “Compress”, and chose the “zip” option. Below is the compressed file:

Next, I renamed the file to “occupy.docx_FILES.docx”:

Then I opened the file in LibreOffice Writer, and it worked!

To prevent this in the future, I will save the file in the ODF Text Document format (.odt), which is the native format used by LibreOffice that supposed doesn’t suffer from this issue. Once the book is done, I will then save it as docx for use in Microsoft Word.

Addressing the Muslim migrant crime crisis in Europe

Not a day passes except that news of more rapes, murders and assaults by Europe’s new multi-million-strong Muslim migrant population comes out. Europe’s politically correct mainstream media is doing its best to pretend the problem doesn’t exist, which is only infuriating the local population.

In Berlin, 12% of migrants are criminal suspects, while only 3% of the local population are. Berlin’s Senate has launched an investigation into why migrants are responsible for such a disproportionate amount of crime.

Today, Germany is where it was in the late 1920’s. A culture of political correctness is enforced by media that are almost entirely owned and operated by the lender class (banks and their lobbyists, i.e. usurers). They think of their local populations as ignorant, worthless and racist peasants that need to be lied to every hour of every single day in case they get the wrong ideas into their heads. In such an atmosphere, it is unlikely that the Berlin Senate’s investigation will lead to anything, besides more useless liberal projects intended to satisfy their own politically correct prejudices without really addressing the problem.

The problem with Europe’s migrants is not that they are Muslim. Zionist news sources like Breitbart (which is still better than the crypto-Zionist New York Times and their ilk) cannot stop pointing out that these migrants are Muslim, and that it is the fact that they are Muslim that is responsible for their criminality.

This is complete nonsense, as can be shown by a few simple mental exercises. Do you really think that Nigeria’s Christian population is any less criminal than Nigeria’s Muslim population? And do you think that letting one million Filipino Christians into Germany would lead to any better results than letting one million Filipino Muslims into the country? And do you think that Indian Hindus are any better than Indian Muslims? And what about Malaysian Muslims, these people who are too peaceful, too prosperous, too law-abiding and too intelligent for their existence to be acknowledged by anti-Muslims demagogues?

Germany has had hundreds of thousands of Muslim Turks living there peacefully for the most part. Argentina has 500,000 Muslims that never make the news. Japan has 100,000.

The problem is not Islam, but genetics. Generalizing about Malaysian Muslims using crimes committed by Afghans or Tunisians is as naive as generalizing about Norwegians using crimes committed by Mexicans, with Norwegians and Mexicans both being overwhelmingly Christian.

Europe, similar to Japan, Malaysia, Iran and Turkey, has gone through a thousand years of evolutionary selection for peacefulness and respect for the law. In Europe, just 150 years ago, criminals were being hanged at an industrial scale, sometimes for minor crimes. Japan’s law enforcement was similarly vicious. The effect was that most genetic traits that lead to criminality were wiped out of the gene pool, resulting in populations that are extremely peaceful and law-abiding, and high in IQ, as respect for the law and IQ go hand in hand, and low IQ and crime go hand in hand.

It is not Islam that is the problem. America’s African-American population are overwhelmingly Christian. And yet their crime statistics have nothing to do with those of the local white Christians. African-Americans make up 12% of the United States population but are responsible for 32.5% of all rapes, 34% of all assaults, 54% of all robberies and 49% of all murders. Is it fair to blame Christianity for this?

The Bell Curve, perhaps the greatest scientific book of the 20th century (on par with Darwin’s Origin of Species), written by the professors Richard Herrnstein and Charles Murray, takes a deep and unpolitically-correct look at the basis for high black criminality, and it is shown beyond reasonable doubt that it is IQ that is responsible before anything else. And since IQ has a strong hereditary component (probably at least 60% or 70% heritable), what their results indicate is that crime is first and foremost an issue of genetics. People of a certain set of genes are more likely to be criminal than others.

Of course, it is unfair and inhumane to use these statistics to derive conclusions about individual black people. If 15% of blacks are criminal, that means the majority, the 85%, is not criminal. And similarly for migrants, if 12% are criminal, it means 88% are not. Black and migrant criminals are the loud minorities that taint the reputation of the whole.

The problem is not that all migrants are criminal. It is that there are more criminals among the ranks of migrants (12% of them) than there are among the ranks of the German (or Swedish, etc.) populations (3%). The majority of migrants and Germans are law-abiding. It is just that migrants have many more criminals among them.

Scientific fraudsters like Stephen Jay Gould (Jewish) and the criminally incompetent “intelligence researcher” Diane Halpern (Jewish) (who manages to write an entire book on intelligence without once mentioning g, the central variable that the whole science of intelligence research is dedicated to), have managed to throw the findings of the Bell Curve down some sort of Orwellian memory hole, aided by Jewish organizations like the New York Times, who pretend to be leaders of American enlightenment thinking while working to enforce their various narrow-minded prejudices on an unwary intelligentsia, continuing the sanctified tradition of Franz Boas (Jewish), ignoring science and attacking scientists for the greater good. They believe that whites acknowledging any genetic basis to intelligence (or anything else that puts whites in a good light) = Nazism = Auschwitz.

It is, however, perfectly fine in their opinions to acknowledge genetic bases for illnesses. And if you mention that Ashkenazi Jews have genetically-mediated high intelligence, they won’t complain. And if you mention that white men have a genetic tendency to be monsters, or that men have a stupidity gene, then they will celebrate it like the discovery of the century and plaster it all over their media. And if you ask whether the finding also applies to black men, they will change the subject. Their job, whether intentionally or unintentionally carried out, is to protect the “bounds on public discourse” by ensuring that no one strays too far from the party line to examine truths that may, in some distant future, be used to discriminate against Jews.

The Solution

There is no quick and easy solution for curing the criminality of a crime-prone population, as America’s experience with blacks and Scotch-Irish whites has shown. It takes hundreds of years of law-enforcement for crime-prone genes to be slowly weeded out of the gene pool. By imprisoning a murderer for 30 or 40 years, their chances of procreating are severely reduced, so that their genes are cast out of the gene pool, and law-abiding genes grow to make up nearly the entirety of the population, as they have done in Western Europe and Japan.

Here are a number of steps Europeans can take to fight back against the migrant crime wave. I use Germany as an example, but it applies similarly to other countries suffering from the crisis:

  1. Instate a very strong anti-crime regime where a single proven criminal offense is sufficient to deport a migrant. In this way the worst specimens can be removed from Europe, so that the 88% non-criminal migrant population grows to make up closer to 97%, in line with Europe’s native population.
  2. Double or triple police presence wherever large migrant populations reside, and wherever large numbers of the local population gather, especially near city centers, and in bus and train stations.
  3. If the government can’t be bothered to protect the population, the people can create civil protection units. These would be groups of 5 men or more, wearing a particular uniform, and wearing bodycams. They would respond to migrant crime, and if the corrupt legal system tries to attack them for defending the local population, the bodycam footage can be used as evidence to show that they were acting in the interest of the people.
  4. If deportation can’t be done because the women in charge have bleeding hearts for these rapists and murderers, long criminal sentences should be instated (20 years or more) to significantly reduce the ability of these criminals to commit crimes on the one hand, and to reduce their ability to procreate on the other hand (by shutting them up with people of the same sex, making procreation quite hard).
  5. A number of language and other courses could be provided freely to adult males of working age. Those who fail to take them, or fail to pass successfully, would be deported. If they cannot pass a few simple courses, or think they shouldn’t have to, they do not have the intelligence and the self-control to contribute in any way to the German civilization and would be a net cost on German society.
  6. German women should warned to be double as cautious of being raped and assaulted as they were before the migrant crisis. The Middle East ensures the safety of its women through a system of chivalry where males (including strangers) are ready to protect them in case of assault. German society has no experience dealing with a young male population that thinks it’s OK to assault and rape given the chance, a young male population that is only kept in check in the Middle East through the presence of other, usually older, males. German women, therefore, for the time being should use the protection provided by German males wherever they can, for example by not going out alone anywhere where they could be assaulted.
    It’s true that they “shouldn’t” have to do any of this, that they should be free to act as before. But this is not before. It’s their lives that are at stake; feminist bravado would only lead to more lives being lost and more women traumatized. Until the migrant crisis is somehow solved, women should take necessary measures to protect and defend themselves.

Of course, the best solution would have been for the migrants not to be there to begin with. If the US (and its European allies), at the behest of its Zionist neocons, hadn’t destroyed Afghanistan, Iraq and Syria to ensure Israel’s status as the regional superpower, and if the CIA hadn’t spent billions funding terrorist groups to ensure perpetual war in the region, there wouldn’t be so many people wanting to leave.

There will, however, always be some economic migrants wanting to go from a less prosperous to a more prosperous state.

Charting the Strauss-Howe Generational Theory in 2017

Below is a chart (click it to zoom) that shows the seasonality of Anglo-American history since the end of the Middle Ages, according to the Strauss-Howe Generational Theory (as described in their 1997 book The Fourth Turning).

Below is the inner circles zoomed in (for those who don’t want to click the above chart to zoom in):

The “saeculum” is the word that Strauss-Howe use for each circle of the chart above, four seasons together make one saeculum. A saeculum is generally the length of one human life time, and its regularity has been noted since ancient times. We are currently living at the end of the saeculum that started in 1943, and which will probably end sometime between 2025 and 2035.

Below is the part of the chart that is most relevant to 2017. Many world leaders feel that we are approaching a major war. Countries are preparing for war, with Russia and China at the forefront, and Japan starting its own re-militarization program. According to the Strauss-Howe theory, 2017 is equivalent to 1933 (when Hitler got in charge and started rebuilding Germany’s army), 1854 (when the prospect of an American Civil War felt more and more imminent), and 1779 (the middle of the American Revolutionary War against Britain, and the year of the French Revolution). Needless to say, right now we are living in very interesting times.

[I updated these charts in 2018.]

Fixing jagged/aliased text on KDP/createSpace paperback covers

Upon publishing my new book, Object-Oriented PHP Best Practices, as an Amazon paperback, I was dismayed to see how ugly the cover looked on their site:

I had provided the book’s cover as a PDF saved from Photoshop. I realized that the issue was that Amazon’s software had trouble properly rasterizing the text in the PDF. For this reason, I went back to Photoshop, went to Layer -> Flatten Image to rasterize the image, then saved that as a separate PSD file (since you will lose all layers in the image, making the cover’s text impossible to edit in the future), and then from there saved it as a PDF. I uploaded the new cover to KDP, and a day or two later, I checked the paperback’s page and was happy to see that it looks good now:

Setting the default search path for Catfish File Search

The Problem

It was surprisingly difficult to find out how to set a default search path for Catfish. On the command line, you can simply do this to always make Catfish search from the root directory:

alias catfish='/usr/bin/catfish --path=\/'

But adding this line to your ~/.bashrc file will not affect the default search path for Catfish unless you launch it from the command line. What I wanted was to be able to click on the Catfish icon on the Unity launcher and have it launch in my root directory (so that it would search all my hard drives). Typically for a Linux program, Catfish’s settings do not offer a way to set this.

The Solution

The solution is to open up the file /usr/share/applications/catfish.desktop as root, for example by typing this on the command line:

gksudo gedit /usr/share/applications/catfish.desktop

Once the file opens up, change the Exec line near the bottom as follows, adding a --path=/some_path/ to the end of the line. Below, I’ve only put a forward slash as a path, meaning I want catfish to search everything, including all mounted hard drives.

Now, when I click the Catfish icon on the Unity launcher, the default search path is “File System”, which is how the program refers to the root directory.

When will the average flagship smartphone have a 5000 mAh battery? Probably around 2029

From 2007 to 2016, the iPhone’s battery grew from 1400 mAh in the first iPhone to 1960 mAh in the iPhone 7 (ignoring the new plus size iPhones). The energy density of lithium ion batteries grows at an exponential rate (5-8% a year), doubling every ten years, according to Tesla’s J.B. Straubel. The iPhone’s battery density growth is lagging this trend probably due to the continuous push for thinner phones.

Using Microsoft Excel’s exponential regression functionality, the following chart forecasts future iPhone battery sizes based on the available historical data, predicting that the small (non-plus) iPhone’s battery capacity will reach 5000 mAh around the year 2036:

Moving on to the more interesting new plus-sized iPhones, Excel cannot do an accurate automatic exponential regression due to the fact that there isn’t enough historical data available on the plus-sized iPhones. By examining the above chart and manually doing the regression using a second series, I found that Excel assumed an approximate rate of growth of 3.81%, and an approximate rate of growth of the rate of growth of 0.09%. Using these same rates on current iPhone Plus battery sizes, we get the following chart:

As it can be seen, around 2024 the iPhone Plus battery size reaches 4000 mAh, and around 2029 it reaches 5000 mAh. If the trend toward ever thinner phones slows, then the 5000 mAh smartphone battery might be achieved at an earlier date. I am hopeful that at least one large manufacturer is brave enough to bet on much larger batteries as a selling point, instead of following Apple’s lead in making things thinner and thinner.

When will smartphones have 1 terabyte of storage? Probably around 2021

While I’m no fan of Apple, the iPhone has so far been the leader in performance and storage. The internal storage of Apple’s latest and greatest iPhone provides a good benchmark for the current level of storage of the entire smartphone industry. When an iPhone with a new level of storage comes out, every manufacturer plays catch-up with Apple releases a flagship phone of similar storage.

Here is a chart that shows the trend in iPhone in internal storage. It extrapolates the trend into the future to predict when the iPhone will likely have one terabyte of internal storage (blue is historical storage levels, orange is predicted, and the dotted line is the trendline):

The chart assumes an exponential trend, since storage density and prices have followed an exponential increase and reduction trend.

I assumed that from 2018 through 2020, the iPhone will stay at 512 GB, similar to how it remained at 64 GB from 2011 through 2013. It is possible that instead of this, the iPhone will stay at 256 GB from 2017 through 2019. This will not significantly affect the historical trend.

Here is the same chart with the forecast extended to 2030. The trendline predicts an internal storage of 5 terabytes in 2027 and 10 terabytes in 2029.

I know that 10 terabytes in a smartphone may seem unnecessarily high. But historical trends show that every age can find good (and frivolous) uses for all the storage it can get.

Below is a table of every iPhone release date, device name, highest offered storage and battery capacity:

Release Date
Device Storage (GB)
Battery (mAh)
June 29, 2007 iPhone 1 16 1400
July 11, 2008 iPhone 3G 16 1150
June 19 2009 iPhone 3GS 32 1219
June 24, 2010 iPhone 4 32 1420
October 14, 2011 iPhone 4S 64 1432
September 21, 2012 iPhone 5 64 1440
September 20, 2013 iPhone 5S 64 1560
September 19, 2014 iPhone 6 128 1810
September 25, 2015 iPhone 6S 128 1715
September 16, 2016 iPhone 7 256 1960

How to search a document on Linux while ignoring diacritics (harakat/accents)

The Problem

Most applications are not smart enough to ignore accents when searching through the text of a document. Here is a screenshot of LibreOffice 5.2 failing at finding the word Arabic word “bsm” because I didn’t type in every single diacritic:

This is an especially serious problem when searching through Arabic text because the usage of diacritics is totally inconsistent as they are not strictly necessary. Different levels of diacritics are added according to the level of user-friendliness that is desired by the document creator.

Firefox is equally miserable at searching Arabic text:

The Solution

The solution is to open the document in a WebKit-based web browser, which has sensible handling of diacritics. Below is a screenshot of the open source Midori browser succeeding at finding and highlighting the Arabic word I was searching for even though I didn’t type in the diacritics:

Other WebKit browsers include Chromium and Chrome, both by Google. I would rather use a non-Google browser personally, so Midori is my preferred option.

If your document is not in the HTML format (the format that browsers use), you can use LibreOffice or Microsoft Word (etc.) to save it as HTML.

Fixing washed out colors in Ubuntu 16.10

How I improved the colors and brightness/contrast and the appearance of fonts on my Ubuntu 16.10 PC monitor

After moving to Ubuntu from Windows, one thing that has been constantly annoying me was the washed out/stark colors on my monitor and ugly-looking fonts in Firefox. I have spent hours fiddling with my monitor’s settings, color profiles on the Color tool, and various random font-related hacks using the terminal to no benefit.

Today I finally found the solution. It was to connect my monitor to my PC using a DVI cable instead of HDMI. Apparently there is an issue with communication between the Linux Kernel and most (if not all) monitors when they use HDMI and DisplayPort, at least this is what I understood from this discussion on Kernel.org.

One other possible solution is using this command (replace HDMI1 with the name of your display as given by the command /usr/bin/xrandr -q --prop | grep ' connected'):

xrandr --output HDMI1 --set "Broadcast RGB" "Full"

When trying the above, I kept getting this error:

BadName (named color or font does not exist)

Not wanting to spend the rest of my day troubleshooting this error, I took the brute-force approach of using a DVI cable that I fortunately had lying around in a closet.

How I solved “jQuery Ajax Uncaught TypeError: Cannot read property ‘type’ of undefined”

A solution for an error occurring during a jQuery $.ajax request.

I was using this common jQuery Ajax pattern on a page I am working:

    $(function () {
        $(document).on('click', '.create-domain .submit', function (e) {
            e.preventDefault();

            var data = {
                domain_description: $('.create-domain .domain-description-textarea')
        }

            $.ajax({
                type: 'post',
                url: '/process/something.php',
                data: data,
                error: function (data) {
                    console.debug(data);
                },
                success: function (response) {
                   //stuff
                }
            });
        });

But on clicking the submit element, I kept getting this cryptic error:

Uncaught TypeError: Cannot read property 'type' of undefined
    at r.handle (jquery-2.2.4.min.js:3)
    at e (jquery-2.2.4.min.js:4)
    at Gb (jquery-2.2.4.min.js:4)
    at Gb (jquery-2.2.4.min.js:4)
    at Gb (jquery-2.2.4.min.js:4)
    at Gb (jquery-2.2.4.min.js:4)
    at Function.n.param (jquery-2.2.4.min.js:4)
    at Function.ajax (jquery-2.2.4.min.js:4)
    at HTMLButtonElement. (something.php:575)
    at HTMLDocument.dispatch (jquery-2.2.4.min.js:3)
    at HTMLDocument.r.handle (jquery-2.2.4.min.js:3)

The problem was that in the data variable, I was including an HTML element (a textarea) inside the data variable, instead of including the textarea‘s content. Thus the corrected code is (notice the .val() at the end):

            var data = {
                domain_description: $('.create-domain .domain-description-textarea').val(),
        }

Hopefully this will help a few people, helping making the world economy more efficient by 1*10-12% (saving the world economy $107 USD over the next year).

Page 6 of 8
1 2 3 4 5 6 7 8