Pentachronological #0012 — 10 sex appeal tips by your friendly neighborhood ghost

Пентахронология (Pentachronological) — Талмуд

(ибо назвать Библией было бы слишком неинтересно)

ДЕЙСТВУЮЩИЕ ЛИЦА (в порядке появления):

ЛУИЗА, бывший врач
ЕВГЕНИЙ, рекетир-адвокат-милиционер
ГАМЛЕТ, привидение, друг Луизы
ВАСЯ, бывший главврач
ПОЕТ, поэт-диссидент, телемит-герметик-теософ

МЕСТО ДЕЙСТВИЯ: Середина 90-х, Город, заброшенная психбольница. 1http://www.romeo-juliet-club.ru/shakespeare/romeojuliet_pasternak1.html#Пастернак 2 Как все начиналось

Read more...

Updated Fiamma “Add link” bookmarklet (now there are _two_ of them!)

Now I have a bookmarklet that gets triggered when I’m on a page I want to bookmark. It window.open()’s to the wiki page named after the page title and passes two parameters to the template: the title and the URI of the page. The template gets preloaded1More here: https://www.mediawiki.org/wiki/Manual:Creating_pages_with_preloaded_text .

javascript:window.open('http://pchr8.net/f/index.php?title='+encodeURIComponent(document.title)+'&action=edit&preload=Template:NewLink&preloadparams[]='+encodeURIComponent(location.href)+'&preloadparams[]='+encodeURIComponent(document.title))

The template itself looks pretty trivial. (Note to self: Templates are case sensitive?!)

Then we get a page with an URI and a title. I fill the additional values like this:

http://ronburk.blogspot.de/2009/09/commas-depend-on-linebreaks.html
Ron Burk: Commas Depend on Linebreaks
6


language, linguistics, internet, style, etiquette, mildly interesting

Language
Style

Then I run the bookmarklet, which transform it to the following:

{{B|#124;#124;
http://ronburk.blogspot.de/2009/09/commas-depend-on-linebreaks.html

|#124;#124;Ron Burk: Commas Depend on Linebreaks
|#124;#124;6
|#124;#124;5
}}
{{#set:
k=language, linguistics, internet, style, etiquette, mildly interesting
|#124;#124;+sep=, }}

[[Category: Language]]
[[Category: Style]]

Then I could add something, and then save it.

The new bookmarklet now understands an unlimited number of keywords and categories.

The updated bookmarklet:

var lines = '';
var lines = $('#wpTextbox1').val().split('\n'); 
for (i=0; i<7; i++) {
if (typeof lines[i] == 'undefined') {lines[i]='';}
}
 
if (!ValidURL(lines[0])) {alert(lines[0]+" doesn't look like a valid URL.")};
if (lines[1]=='') {lines[1]=lines[0]};
if (lines[2]=='') {lines[2]='5'};
if (lines[3]=='') {lines[3]='5'};
 
if (parseInt(lines[2]) > 10 |#124;#124;|#124;#124; parseInt(lines[2])<0 |#124;#124;|#124;#124; isNaN(lines[2])) {
alert(lines[2]+'is not a valid value, setting to default 5');
lines[2]='5';
}
 
if (parseInt(lines[3]) > 10 |#124;#124;|#124;#124; parseInt(lines[3])<0 |#124;#124;|#124;#124; isNaN(lines[3])) {
alert(lines[3]+'is not a valid value, setting to default 5');
lines[3]='5';
}

var keywords="\n{{#set:\n";
keywords+="k=";
keywords+=lines[5]; 
keywords+="\n|#124;#124;+sep=, }}\n";

var categories="\n";
for (i=0; i<lines.length-7; i++){
 categories+="[[Category: ";
 categories+=lines[i+7];
 categories+="]]\n";
}

var text="{{B|#124;#124;\n"+lines[0]+"\n|#124;#124;"+lines[1]+"\n|#124;#124;"+lines[2]+"\n|#124;#124;"+lines[3];
if (lines[4]!='') text+="\n|#124;#124;"+lines[4];
text+="\n}}";
text+=keywords;
text+=categories;
 
var field = document.getElementById('wpTextbox1');
var textArray = field.value.split("\n");
textArray.splice(0, lines.length);
textArray[0] = text;
field.value = textArray.join("\n");


function ValidURL(str) {
var pattern = new RegExp('^(https?:\\/\\/)?'+
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|#124;#124;'+
'((\\d{1,3}\\.){3}\\d{1,3}))'+
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+
'(\\?[;&a-z\\d%_.~+=-]*)?'+
'(\\#[-a-z\\d_]*)?$','i');
return pattern.test(str);
}

Todo:

Make it check for bad characters (think “ #124;#124;”, which mediawiki doesn’t like in names and parameters, and everything else here: https://www.mediawiki.org/wiki/Manual:Page_title; make it do something for empty titles, so I don’t get redirected to the main page; put together all of this and upload it to github?

The final bookmarklet looks like this, in one line to make it easy to copypaste:

{% highlight javascript %} javascript:var lines = ‘’; var lines = $(‘#wpTextbox1’).val().split(‘\n’); for (i=0; i<7; i++) { if (typeof lines[i] == ‘undefined’) {lines[i]=’’;} } if (!ValidURL(lines[0])) {alert(lines[0]+” doesn’t look like a valid URL.”)}; if (lines[1]==’’) {lines[1]=lines[0]}; if (lines[2]==’’) {lines[2]=’5’}; if (lines[3]==’’) {lines[3]=’5’}; if (parseInt(lines[2]) > 10 |#124;#124;|#124;#124; parseInt(lines[2])<0 |#124;#124;|#124;#124; isNaN(lines[2])) { alert(lines[2]+’is not a valid value, setting to default 5’); lines[2]=’5’; } if (parseInt(lines[3]) > 10 |#124;#124;|#124;#124; parseInt(lines[3])<0 |#124;#124;|#124;#124; isNaN(lines[3])) { alert(lines[3]+’is not a valid value, setting to default 5’); lines[3]=’5’; } var keywords=”\n{{#set:\n”; keywords+=”k=”; keywords+=lines[5]; keywords+=”\n|#124;#124;+sep=, }}\n”; var categories=”\n”; for (i=0; i<lines.length-7; i++){ categories+=”[[Category: “; categories+=lines[i+7]; categories+=”]]\n”; } var text=”{{B|#124;#124;\n”+lines[0]+”\n|#124;#124;”+lines[1]+”\n|#124;#124;”+lines[2]+”\n|#124;#124;”+lines[3]; if (lines[4]!=’’) text+=”\n|#124;#124;”+lines[4]; text+=”\n}}”; text+=keywords; text+=categories; var field = document.getElementById(‘wpTextbox1’); var textArray = field.value.split(“\n”); textArray.splice(0, lines.length); textArray[0] = text; field.value = textArray.join(“\n”); function ValidURL(str) { var pattern = new RegExp(‘^(https?:\/\/)?’+ ‘(((a-z\d)\.?)+[a-z]{2,}|#124;#124;’+ ‘((\d{1,3}\.){3}\d{1,3}))’+ ‘(\:\d+)?(\/[-a-z\d%_.~+])’+ ‘(\?[;&a-z\d%_.~+=-])?’+ ‘(\#[-a-z\d_]*)?$’,’i’); return pattern.test(str); } {% endhighlight %}

Unrelated to the above:

Apparently, after N years of studying programming and tweaking/optimizing whatever incarnation of my workspace, I’m getting it. Like, you can really solve your own problems by writing your own code?! Wow!

What happens next? I’m gonna go around writing extensions and stuff? How was the quote: “Be a man, write your own drivers!”

Regardless, this small and dead-simple bookmarklet that solves my own problems has done much more for my motivation than anything else I’ve ever tried in the last couple of years.

Wohoo!

(Y)

Footnotes   [ + ]


Pentachronological 11 | Это мне напоминает анекдот, который я слышал в Латвии в 1967 году

Semantic Mediawiki for personal knowledge management, using templates and a custom userscript

Here I’ll try to document my current setup for links management, which is slowly starting to take form.

Как мы пришли к такой жизни

Since the social bookmarking site Delicious (old links page) is seriously falling apart (which is very sad, I liked it almost as much as I liked Google Reader) I started looking for other alternatives. For some time, I used WordPress LinkLibrary plugin until I felt the hard category system lacked flexibility (you can see on the “Links” page of this blog how cluttered and repetitive it is), I needed _tags _and more ways to organize the links and, possibly, the relationships between them.

Then for a very short time I set up a WordPress installation specifically for links. I was not the first one who attempted this (https://sebastiangreger.net/2014/01/own-your-data-part-1-bookmarks/ as an example), but it did not work out well for me.

As for the existing social bookmarking services, for example http://pinboard.in or http://historio.us/, I did not want to pay and wanted control of my data (thank God the export feature in Delicious worked more often than not, but I don’t want to risk it anymore).

As for the need to “share” it, I want to have access to it from various places and, since there’s nothing private, putting it in the cloud and putting a password on it sounds like an unneeded layer of complication. Lastly — who knows — maybe someone will actually get some use out of it.

Semantic Mediawiki

Mediawiki is the software Wikipedia runs on. Semantic Mediawiki is an open-source extension for it that adds the ability to store and query data on a whole another level.

Semantics means, basically, meaning. The difference between “60”, “60kg”, “My weight is 60kg.”

Traditionally, Mediawiki allows the pages to link to each other, but the exact nature of the connection is not clear, and you can’t use the connections much. Semantic Mediawiki allows to define additional data for every page, and allows to define relationships between pages. The data “Benjamin Franklin was born in the USA in 1706” suddenly becomes searchable, for example as “Give me the people born in America before 1800” and “Give me the list of countries where people named Ben were born”. A link “Benjamin Franklin -> Philadelphia” becomes “Benjamin Franklin was (BORN IN) Philadelphia”.

This is awesome.

After looking at it, I understood that I have immense power in my hands, and that I have no idea how to use it. As in, how to create an architecture that was both meaningful and easy to adhere to.

Seeing all this, I thought it would make sense to upgrade my “Link database” to something much more interconnected and useful, a personal knowledge management system.

And here it is.

2016-12-09-213801_1594x634_scrot

The system

Take this page.

Every page has 5 values:

  • l: The actual URI
  • t: the title
  • c: the complexity (how easy/hard is it to read; sometimes I just don’t want to think too much), 1 to 10
  • r: the rating, also 1 to 10
  • o: If it’s a page with only one link, around which the content of the page has been built. (As opposed to “Here are 5 links about X”)

Plus, of course, any additional text.

Properties can be set:

1) In the text itself, for example like this:

[[l::https://plus.maths.org/content/os/issue53/features/hallucinations/index]]
- [[t::Uncoiling the spiral: Maths and hallucinations.]]

2) Invisibly:

{{#set: o=true |c=8 }}

3) using the following nice template I’ve written:

http://www.pchr8.net/wiki/index.php?title=Template:B 

[[l::{{{1}}}]] - [[t::{{{2}}}]]. 
----
Complexity: [[c::{{{3|5}}}]]; Rating: [[r::{{{4|5}}}]]; Is only link: [[o::{{{5|true}}}]]


{{#set:
 l={{{1}}}
 |t={{{2|1}}} &lt;!-- If no title given, use URI as name --&gt;
 |c={{{3|5}}} &lt;!-- 5 as default value --&gt;
 |r={{{4|5}}} &lt;!-- 5 as default rating unless something else given
 |o={{{5|true}}} &lt;!-- only link by default --&gt;
}}

which can be used like this:

{{B| https://www.fastcodesign.com/3043041/evidence/why-our-brains-love-high-ceilings |Why our brains love high ceilings |5 |7 }}

My main goal for this was that it should be fast, and fast for me. I can type the above much faster than I can multiple input boxes in a hypothetical GUI.

Then I decided to write some bad javascript to simplify it even more.

The bookmarklet/userscript

An actual bookmarklet would be definitely the next thing I'm doing, until then I'll be adding the pages manually.

But I wrote a small script (two years since I've used any Javascript, haha), to minimize the text above to just this:

https://www.fastcodesign.com/3043041/evidence/why-our-brains-love-high-ceilings Why our brains love high ceilings 5 7

The (badbadbad) Javascript code is the following:

var lines = $('#wpTextbox1').val().split('\n');

for (i=0; i&lt;5; i++) {
if (typeof lines[i] == 'undefined') {lines[i]='';}
}

if (!ValidURL(lines[0])) {alert(lines[0]+" doesn't look like a valid URL.")};
if (lines[1]=='') {lines[1]=lines[0]};
if (lines[2]=='') {lines[2]='5'};
if (lines[3]=='') {lines[3]='5'};

if (parseInt(lines[2]) &gt; 10 || parseInt(lines[2])&lt;0 || isNaN(lines[2])) {
alert(lines[2]+'is not a valid value, setting to default 5');
lines[2]='5';
}

if (parseInt(lines[3]) &gt; 10 || parseInt(lines[3])&lt;0 || isNaN(lines[3])) {
alert(lines[3]+'is not a valid value, setting to default 5');
lines[3]='5';
}

var text="{{B|\n"+lines[0]+"\n|"+lines[1]+"\n|"+lines[2]+"\n|"+lines[3];
if (lines[4]!='') text+="\n|"+lines[4];
text+="\n}}";

var field = document.getElementById('wpTextbox1');
var textArray = field.value.split("\n");
textArray.splice(0, 4);
textArray[0] = text;
field.value = textArray.join("\n");

function ValidURL(str) {
var pattern = new RegExp('^(https?:\\/\\/)?'+
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+
'((\\d{1,3}\\.){3}\\d{1,3}))'+
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+
'(\\?[;&a-z\\d%_.~+=-]*)?'+
'(\\#[-a-z\\d_]*)?$','i');
return pattern.test(str);
}

The minimized variant of the above now sits nice in my bookmarks bar, and is bound to a keypress in cvim. So I can fill just the URI, and it sets everything else to some default values and adds the Mediawiki template formatting.

TODO:

  1. Getting the page title automagically (see http://stackoverflow.com/questions/10793585/how-to-pick-the-title-of-a-remote-webpage), I'll need a PHP backend. It would be also interesting to check from the PHP if the IP making the request is currently logged in in my wiki, and get the title only then, to prevent abuse
  2. Making a bookmarklet which populates automatically most of the fields, like my old Delicious bookmarklet (sigh.)

Searching the wiki

The search in Semantic Mediawiki is explained pretty well here. Now I can do neat things like "Give me the pages in the Category 'To read' with complexity < 4". And lastly, categories can be inside other categories. If X is in category  A, which is a subcategory of B, it still shows up in searches for category B. (example) Pretty nice!

Knowledge Management

Things I want to learn or will probably need pretty often will have their own pages, like the Formulating Knowledge page. Simply because interacting with the material always helps much more than just reading it. Also I like that it will be represented in a way relevant for me, without unnecessary data and with additional material I think should be there.

For the link pages, there will be the link + very short summary (it has been working pretty well) + a couple of thoughts about it, + maybe relevant data or links to other pages.

TODO: Quotes + Move there my "To Read" / "To Listen to" lists. Also think of a better name for it.

Why?

Warum einfach, wenn es auch kompliziert geht? (A nice German phrase about avoiding the unbearable simplicity of being: "Why simple, when it can be complicated as well?")

On a serious note, I don't have any doubts that in the long run I'll be thankful for this system.

Firstly, I control all of this data. Feels good. Take that, capitalist ad-ridden surveillance corporations!

Secondly, working with a lot of information has always been something I do often and enjoy immensely, and it would make sense to start accumulating everything in one place. Every day I stumble upon a lot of material on the Internet, of very different nature, and with not-obvious connections between them. I have more interests than I can count.

Organizing everything like this so far looks to me the best alternative, and I'm reasonably certain it will work out. There's a lot that can be improved, and I think in a couple of moths it will morph into something awesome.

Finding ways to use all the accumulated data is a topic for another day.

(Y)


A couple of nice relevant inspiring places:

http://yourcmc.ru/wiki/  - in Russian, a person using Mediawiki as central hub for everything.

http://konigi.com/wiki/  - personal wiki, mostly design.

http://thingelstad.com/2012/bookmarking-with-semantic-mediawiki/ a much more advanced version of what I'm trying to do, also using Semantic Mediawiki. I should drop him a line :)