27 December, 2015

View a Json Object in the console

At least in Google Chrome this works like a charm:

var xhr = new XMLHttpRequest();
responseObject = JSON.parse(xhr.responseText);
var openFile = "weather.json"; // sample file



The Json Object in a Chrome Console

26 December, 2015

Intrduction to the Philips HUE API

The first impressions using the app from Philips was nice. But even better: there are tons of apps out there. Even better: you can hack your own interface using the fine API from Philips. Here are some starting points:

You can program Philips Hue via the Json based API and methods like GET, POST and PUT. The bridge has a nice API interface on:


Here you'll get a testing GUI to use when experimenting with the API methods.

Experiment with JavaScript and Json

Copypasted a json sample from W3 Schools, and console.logged the result. Surprisingly the console got the json object.

console.log result
From this I should be able to figure out how to write the content to the screen.

Python: Idle session

Python 2.7.9 (default, Apr  2 2015, 15:33:21)
[GCC 4.9.2] on linux2

>>> import requests
>>> import json

>>> taend = json.dumps({"on":False})

>>> r = requests.put("http://192.168.0.xxx/api/your-secret-code/groups/0/action", data=taend)

All lamps went out out, so a success it was.

Bash Experiment

curl -X PUT -d "{\"on\":true}" http://192.168.0.xxx/api/your-secret-code/groups/0/action

Since it's possible to use curl in PHP the same thing must be possible in PHP.

25 December, 2015

Philips HUE

So how do you discover the IP of your device. On linux the answer is arp-scan (if it's not on your system apt-get install it):

Using arp-scan --interface=wlan0 I got:

192.168.*.** *************** (Unknown)
192.168.*.11 00:17:88:20:e8:6e Philips Lighting BV
192.168.*.** *************** (Unknown)

So now I know my IP.

17 December, 2015

The Librarian

Visited the librarian. She recommended these urls:

Lo and Behold! My BibTex compiler works ...

A (oh horror!) .docx file in Libre Office

In order to make a literature review I need to compile a MySQL table in the BibTex format.

Now I've got a file, that looks pretty much like a BibTex formatted file. It's compiled from a MySQL database and the output is formatted by PHP.

In the php code this loop will format the output:

while($row = $result->fetch_assoc()){
    $books[] = "\n@". $row['Type'] 
     ."{" . strtoupper( substr($row['Author'], 0,4)) 
     . "_" . $row['Year']
     . ",\n Author={" . $row['Author'] . "},\n"
     . "Title={" . $row['Title'] . "},\n"
     . "Publisher={" . $row['Where'] . "},\n"
     . "Year=" . $row['Year'] . "}\n";

I made a simple markdown file and compiled it with pandoc. The result was a .docx file.

Here is the output from the database formatted via PHP:

Publisher={Hans Reitzels Forlag},

etc. etc. etc. etc. etc.

The markdown contains a reference to a book in the BibTex file:


Finally the markdown is compiled via pandoc thus:

# pandoc --bibliography=libri.bib test.md -o test.docx

The image above is a screendump from the docx-file in Libre Office. I only refered to Aristoteles, and that's the only work in the list of sources.

Ergo: Q.E.D.

That is: this is just a toolbox. The next step is literature research for the WordPress and Open Source CMS Research Project @ Business Academy Aarhus. And perhaps: come up with title with > x-factor.

16 December, 2015

WordPress and open source CMS research

I have to make a litterature review about open source CMS with focus on WordPress.

Yesterday and today I made a BibTex compiler for WordPress. I have to make a litterature review. By now I'm inspired by Umberto Eco's cardboard file cards. However, nowadays I think that a MySQL database is better suited for the storage.

Here is the system:

  • https://github.com/asathoor/libri
Today the final pieces came together. The database has all entries from my bibtex file. Via PHP I can convert the MySQL data to a bibtex format. Here's the trick:

while($row = $result->fetch_assoc()){     print "\n@Book{" . strtoupper( substr($row['Author'], 0,4)) . "_" . $row['Year']     . ",\n Author={" . $row['Author'] . "},\n"     . "Title={" . $row['Title'] . "},\n"     . "Publisher={" . $row['Where'] . "},\n"     . "Year=" . $row['Year'] . "}\n";   }

Some formatting may be done via SQL, here's a sample from my Github repo:

SELECT '@Book{' as 'Book',

concat(left(`Author`,3),`Year`,',') as 'slug',
concat('Author={{' , `Author`, '}},') as 'Author',
concat('Title={{' ,`Title`, '}},') as 'Title',

FROM `libri`

So the environment for developing the project is almost there. 

06 December, 2015

Brute force attacks on WordPress

It seems that sinister powers are lurking around one of my webpages. There are 501351 attempts to log in - in just one month. I guess the picture is quite normal for attacks on WordPress sites. So don't have a user called Admin - and make sure, that your password is hard to crack.