how to adapt C++-objects for TSX

TSX doesn’t recognize partial writes to objects as writes to the whole object. This can cause a missing synchronisation.

The fix is very easy: you mark an object as written. This is possible with the prefetch builtin of GCC:

__builtin_prefetch(pointer_to_object, 1, 0)

The meaning of the two parameters are:

1 = write access
0 = weak locality. Don’t force tsx to cache something. We just want to mark an address as written to.

Advertisements

new Project: spkcspider

I started 7 months ago a project, spkcspider. It is like a digital business card with blogging and wp writing function. The key difference to current systems is that you can store structured data which is computer readable.

This way you can provide your data to web shops with just a link. For security I use in links embedded tokens and a multi factor authentication.

I wrote my project in python because if you look around: php, javascript or ruby are maybe widespread but they all have a dependency hell. You cannot really fix your project as maybe there is a dependency to an old, vulnerable version or an unknown hole (what is more likely if multiple authors just add a little piece).

Sorry for not going into the details. I will do it in a few weeks. My time is currently very limited.

Anyway, here are more information:
https://spkcspider.net/cgi-bin/cgihandler.fcgi/spider/ucs/list/7/NeDIjcG8wwFp63Li/

As you see, there is a cryptic string in the url. This is part of my security concept.
And sorry for the speed. It is currently prototyped as a fastcgi application.

how to add a new prefix to fancyref

Sometimes you want to define a new fancyref prefix. This is how to do it:

\newcommand*{\fancyrefalgolabelprefix}{algo}
\newcommand*{\Frefalgoname}{\@empty}
\newcommand*{\frefalgoname}{\@empty}

\fancyrefaddcaptions{english}{
\renewcommand*{\Frefalgoname}{Algorithm}
\renewcommand*{\frefalgoname}{
\MakeLowercase{\Frefalgoname}
}
}
\fancyrefaddcaptions{german}{
\renewcommand*{\Frefalgoname}{Algorithmus}
\renewcommand*{\frefalgoname}{
\Frefalgoname
}
}

\frefformat{main}{\fancyrefalgolabelprefix}{
\textbf{\frefalgoname\fancyrefdefaultspacing#1}#3
}
\frefformat{vario}{\fancyrefalgolabelprefix}{
\frefalgoname\fancyrefdefaultspacing#1#3
}
\frefformat{plain}{\fancyrefalgolabelprefix}{
\frefalgoname\fancyrefdefaultspacing#1
}

\Frefformat{main}{\fancyrefalgolabelprefix}{
\textbf{\Frefalgoname\fancyrefdefaultspacing#1}#3
}

\Frefformat{vario}{\fancyrefalgolabelprefix}{
\Frefalgoname\fancyrefdefaultspacing#1#3
}
\Frefformat{plain}{\fancyrefalgolabelprefix}{
\Frefalgoname\fancyrefdefaultspacing#1
}

Replace “algo” with what you want. Sadly there is no macro for creating this easier.

Here some pitfalls:
You have to use:

\newcommand*{\Frefalgoname}{\@empty}
\newcommand*{\frefalgoname}{\@empty}

for preallocating the commands. If you go after manual and use \newcommand* inside \fancyrefaddcaptions{german} you will get strange redefinition errors.

how to fix: android has not enough space for updates (after many updates)

After some time android updates stopped due to insufficient space. After a short investigation I found out that the problem is google play

google play saves every update intern in its cache. This way the cache grows to a enormous size.

The fix is very easy: clear the cache of google play. For this go to settings -> apps and open google play in the list of apps. There should be a button: “clear cache”. Pressing it will solve this problem

How to fix: grub.cfg is not loaded under uefi

I spend recently much time to find out why grub didn’t load the grub.cfg under UEFI.
The used distribution is ubuntu.

I found out that there are two pitfalls:

  1. The grub.cfg stub to load the the real grub.cfg is not installed. Run in this case grub-install with the right parameters again
  2. Some distributions like Ubuntu have a uefi name hardcoded in the grub loader. Means: if you use a different name as “ubuntu” for your uefi entry, the grub.cfg stub is not found.

Hope this helps to solve UEFI problems

The case against ipv4 sockets

Nobody needs ipv4 sockets anymore. Even in ipv4 environments. You can use mapped ipv4 addresses for receiving from and connecting to ipv4 sockets. For this you must NOT enable IPV6_V6ONLY. Remove calls like this:

socket.setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 1)

This option is by default disabled so you don’t have to disable the option manually.

Python sample code for ipv6 ready sockets (client side):

import socket
from http.client import HTTPConnection
retval = socket.getaddrinfo(url, port, socket.AF_INET6, socket.SOCK_STREAM, flags=socket.AI_V4MAPPED)
if len(retval) == 1: # check if there was a result
    con = HTTPConnection(retval[0][4][:2])

Server side:

from http.server import SimpleHTTPRequestHandler, HTTPServer import socket PORT = 8000 class server(HTTPServer): address_family = socket.AF_INET6
    def verify_request(self, request, client_address):
        if client_address[0] in ["::1", "::ffff:127.0.0.1"]: # check if localhost
            return True
        return False

httpd = server(("::", PORT), SimpleHTTPRequestHandler) # bind to anyaddress
httpd.serve_forever()

Another pitfall is binding the server to localhost. This breaks ipv6, ipv4 compatibility as you can either specify an ipv4 mapped address or an ipv6 address. There are two solutions for this case:

  1. multiple binds (and reuseport, reuseaddr socket option)
  2. bind to anyaddress (“::”, in c:(in6addr_any)) and manually check ip addresses (easier and implemented in example, causes connection resets (port is visible))

fix texlive/tex hang (mktexlsr)

To fix a very slow mktexlsr, look up the pathes in which your distribution put texfiles, and run for each of the directories
texhash <directory>
most probably running:
mktexlsr <directory>
also works
in archlinux the core tex files are in texlive-core

Here an example :

sudo texhash /usr/share/texmf-dist
sudo texhash /var/lib/texmf

as result a file will be created in /etc and mktexlsr should work now

Update: a missing /usr/share/texmf directory is maybe the cause for the bug in the first place (this directory is created e.g. by gnuplot (archlinux))

gtk3 combobox

The combobox shows nothing?
Then you lack a renderer.
add it this way:

addnodecombo = self.builder.get_object("addnodecombo") # in my case get the combo box from gtk.Builder
addnodecomborender=Gtk.CellRendererText() # create a renderer
addnodecombo.pack_start(addnodecomborender, True) # add the renderer (what True does I haven't looked up)

# set the column (in my case 0)
# this can be a different column as the id column.
# what "text" does is most probably setting a column name which isn't shown. I think it can be everything
addnodecombo.add_attribute(addnodecomborender, "text", 0)

how to use gtk3 treestore in pygobject

1. Step:
create a treestoremodel
model=Gtk.TreeStore(str,str) (or use Gtk.Builder for this)

2. Step:
add an entry in the highest level and take its iterator. This can be done with
it=model.insert_with_values(None, -1, [0,1], [“hello”, “world”])
Explaination:
None: parent (None is the highest level)
-1: the last position=appending
[0, 1]: the columns
[“hello”,”world”]: fills the selected columns with values
it: the iterator, it becomes important for the next step

3. Step:
now we have an iterator. In the first call of insert_with_values we used None.
This is replaced by the iterator. And voila a child object

model.insert_with_values(iter, -1,[0,1],[“hello”,”child1″])
model.insert_with_values(iter, -1,[0,1],[“hello”,”child2″])

The last thing to do is to add the treestore to a treeview and add some Renderers for the columns,
but for that there is already a tutorial:
https://python-gtk-3-tutorial.readthedocs.org/en/latest/treeview.html#the-view

why commercial (proprietary) software sucks

People especially economists compare buying a software with buying a car. But this isn’t true. Actually the purchase is comparable to buy a license to use a special car with many restrictions.

e.g. you can’t

  • install it on as many pcs you want. In contrast everyone you trust and has driver license can drive your car
  • modify it (just a very little).
  • give it away/sell it
  • cannibalize it after it stopped working (a broken car you can strip from useful components)
  • go to a car dealer/repairshop of your choice (there are some movements in the car industry to restrict this either)
  • disable advertisments (in the car world they are optionally for your car)
  • have a choice which car you use. In software world nearly every company tries to lock in the users

One similarity is: you are the product.
Many people live from you by exploiting your nescience (in the car as in the software industry)