Thursday, 22 October 2015
Unity fails to open a project, spuriously reports that it is open in another instance
Unity refuses to open the same project in two instances - this much is sensible. But when Unity crashes, sometimes it leaves behind a "Temp" folder in the project, and if this exists, you won't be able to reopen the project. So delete "Temp", and problem solved.
Wednesday, 30 September 2015
Automatically Generated Nav Bar for Jekyll and Github pages
Github pages, which I use for the Simul documentation, uses Jekyll, which is great for building static websites and blogs.
I wanted to create an automatic two-level nav bar for my site, and after much searching, I found this approach, using the url's of the pages. The implementation didn't quite work for me, and I wanted multi-level navigation, so this is what I came up with:
UPDATE:
You could add further nav levels by putting extra inner for loops. Here's a more complete example from my site, that goes to three levels. (See also http://dbgdiary.blogspot.com/2015/11/piping-doxygen-output-to-github-pages.html Done)
I wanted to create an automatic two-level nav bar for my site, and after much searching, I found this approach, using the url's of the pages. The implementation didn't quite work for me, and I wanted multi-level navigation, so this is what I came up with:
{% assign url_parts = page.url | split: '/' %}
{% assign url_parts_size = url_parts | size %}
{% if url_parts_size != 0 %}
{% assign rm = url_parts | last %}
{% assign base_url = page.url | replace: rm %}
{% else %}
{% assign base_url = page.url %}
{% endif %}
<ul>
{% for node in site.pages %}
{% assign node_url_parts = node.url | split: '/' %}
{% assign node_url_parts_size = node_url_parts | size %}
{% assign filename = node_url_parts | last %}
{% if node_url_parts_size == 2 %}
<li>
<a class="sidebar-nav-item{% if page.url == node.url %} active{% endif %}" href="{{ node.url }}">{{ node.title }}</a></li>
{% if page.url contains node.url %}
<ul>
{% for node2 in site.pages %}
{% if node2.url contains node.url %}
<li><a href='{{node2.url}}'>{{node2.title}}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% endif %}
{% endfor %}
{% for num in (1...menu_level) %}
</ul>
{% endfor %}
</ul>
I think this works. It just looks at all the site's pages, and prints up links for those with two parts to the URL: these are the first sub-level. If that URL is part of the URL of the current page, it does another loop, to find the current page's siblings.UPDATE:
You could add further nav levels by putting extra inner for loops. Here's a more complete example from my site, that goes to three levels. (See also http://dbgdiary.blogspot.com/2015/11/piping-doxygen-output-to-github-pages.html Done)
{% assign sorted_pages = site.pages | sort: "url" %}
{% assign this_path = "" %}
{% assign pages = site.array %}
{% assign paths = site.array %}
{% assign titles = site.array %}
{% assign path_sizes = site.array %}
{% assign this_index = 100000000 %}
We've initialized some empty arrays here using site.array, which is defined in _config.yml at the site root as:
array: []
Next we build the arrays from the page list, tweaking Doxygen's filenames to produce a tree-like structure (doxygen's file structure is flat, but we want a tree of URI's):
{% for node in sorted_pages %}
{% assign path = node.url | remove: "/index.html" %}
{% if path contains "/dir_" or path contains "/struct" or path contains "/functions" or path contains "/namespacemembers" or path contains "graph_legend" or path contains "google" or path contains "-members.html" or path contains "/classes.html" %}
{% continue %}
{% endif %}
{% if path contains "_source.html" %}
{% assign path = path | replace: "reference/","reference/source/" %}
{% endif %}
{% assign path = path | replace: "reference/class","reference/classes/" | replace: "reference/classes/es","reference/classes" | replace: "reference/namespaces","reference/classes" | remove: ".html" | replace: "_1_1","/" | replace: "_01"," " | replace: "_8","." | remove_first: "/" | replace: "_ooo","/" %}
{% assign psz = path | size %}
{% assign title = node.title | replace "Namespace List","Reference" | remove: "Files (x86)/Jenkins/jobs/Simul Installers/workspace/Simul/PRODUCTS/TrueSky/Help/" | remove: " Source File" | remove: " Class Reference" %}
{% if title == "404" or path contains "search-results" %}
{% continue %}
{% endif %}
{% assign path_parts = path | split: '/' %}
{% assign path_parts_size = path_parts | size %}
{% assign paths = paths | push: path %}
{% assign pages = pages | push: node %}
{% assign path_sizes = path_sizes | push: path_parts_size %}
{% assign titles = titles | push: title %}
{% if node.url == page.url %}
{% assign this_path = path %}
{% assign this_node = node %}
{% assign this_index = forloop.index0 %}
{% endif %}
{% endfor %}
Having build the arrays, we now iterate through the page URI's from the outermost level to as many levels as we want. The first loop:
{% assign menu_level = 0 %}
{% for node in pages %}
{% assign node_path = paths[forloop.index0] %}
{% assign node_title = titles[forloop.index0] %}
{% assign node_path_parts = node_path | split: '/' %}
{% assign node_path_parts_size = path_sizes[forloop.index0] %}
{% unless node_path_parts_size == 1 %}
{% continue %}
{% endunless %}
<li>
<a class="sidebar-nav-item{% if page.url == node.url %} active{% endif %} sidebar-1" href="https://www.blogger.com/%7B%7B%20node.url%20%7D%7D">{{ node_title }}</a></li>
{% if this_path contains node_path %}
{% assign paths2 = site.array %}
{% assign pages2 = site.array %}
{% assign titles2 = site.array %}
For the second loop we will iterate through all the pages, but only pick out the ones with two elements in the path, and only the ones that contain the path to the current parent in loop 1. First we build the array, pages2:{% for node2 in pages %} {% unless path_sizes[forloop.index0] == 2 %} {% continue %} {% endunless %} {% assign path2 = paths[forloop.index0] %} {% if path2 contains node_path and node2.url != node.url %} {% assign paths2 = paths2 | push: path2 %} {% assign pages2 = pages2 | push: node2 %} {% assign titles2 = titles2 | push: titles[forloop.index0] %} {% endif %} {% endfor %}
Now iterate through pages2:
{% if pages2.size > 0 %}
{% assign menu_level = 1 %}
<ul>
{% for node2 in pages2 %}
<li><a class="sidebar-nav-item{% if page.url == node2.url %} active{% endif %} sidebar-2" href="https://www.blogger.com/%7B%7Bnode2.url%7D%7D">{{ titles2[forloop.index0] }}</a></li>
{% assign path2 = paths2[forloop.index0] %}
{% if this_path contains path2 %}
Now the same process for pages3, build the array:
{% assign pages3 = site.array %}
{% assign titles3 = site.array %}
{% for node3 in pages %}
{% unless path_sizes[forloop.index0] == 3 %}
{% continue %}
{% endunless %}
{% assign path3 = paths[forloop.index0] %}
{% if path3 contains path2 and node3.url != node.url %}
{% assign paths3 = paths3 | push: path3 %}
{% assign pages3 = pages3 | push: node3 %}
{% assign titles3 = titles3 | push: titles[forloop.index0] %}
{% endif %}
{% endfor %}
And iterate through the array for the third level:
{% if pages3.size > 0 %}
{% assign menu_level = 1 %}
<ul>
{% for node3 in pages3 %}
<li><a class="sidebar-nav-item{% if page.url == node3.url %} active{% endif %} sidebar-3" href="https://www.blogger.com/%7B%7Bnode3.url%7D%7D">{{ titles3[forloop.index0] }}</a></li>
{% endfor %}
</ul>
{% endif%}
{% endif %}
{% endfor %}
</ul>
{% endif%}
{% endif %}
{% endfor %}
That's it for a set of Doxygen html pages - if your output is not from Doxygen the process may be simpler.
Saturday, 29 August 2015
Building icu statically for linkage to Qt
It's bad enough having to link to all the Qt dll's without having to distribute its various dependencies as well - OpenSSL and ICU chiefly among them. Then if you write a dll that plugs into someone else's exe you need to watch out that you could be trying to load a different version of a dependency dll that's used elsewhere in the exe.
So using static libs of the dependencies to link when you build Qt should help a lot. OpenSSL has some nice well-maintained static windows binaries (https://www.openssl.org/related/binaries.html), but icu does not.
There is this: http://www.npcglib.org/~stathis/blog/precompiled-icu/
But it uses static runtimes. So if you want a static build with dynamic (MD) runtimes, you're out of luck.
Path order is crucial. If you call vcvarsall.bat before adding cygwin\bin to the path, you'll get something like:
But if you add cygwin/bin after %PATH%, you'll get something like:
So only the above order works.
and for debug:
When you come to build Qt, set an ICU environment variable to the parent icu directory, and in the Qt make command add the options:
-icu -I "%ICU%\include" -L "%ICU%\%LIB_OR_LIB64%"
where LIB_OR_LIB64 is "lib" or "lib64" depending on the platform.
So using static libs of the dependencies to link when you build Qt should help a lot. OpenSSL has some nice well-maintained static windows binaries (https://www.openssl.org/related/binaries.html), but icu does not.
There is this: http://www.npcglib.org/~stathis/blog/precompiled-icu/
But it uses static runtimes. So if you want a static build with dynamic (MD) runtimes, you're out of luck.
Building with Visual Studio
The Visual Studio solution all_in_one.sln that comes with ICU only builds dynamic libs. So you can modify the projects in the solution to link statically. Make sure that the output debug libraries have a suffix 'd' to their filenames, because they'll be built in the same directory as the release libraries.Building with make
The recipe to build static ICU with MSVC is:cd "%WORKSPACE%\source\"
set PATH=C:\cygwin\bin;%PATH%
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
dos2unix -f *
dos2unix -f configure
dos2unix -f mkinstalldirs
bash runConfigureICU Cygwin/MSVC -prefix=/cygdrive/d/Jarvis/icu_static/dist -enable-static -disable-shared
dos2unix -f install-sh
make && make install
Dos2unix prevents errors of the form '\r unknown command' in the make script.Path order is crucial. If you call vcvarsall.bat before adding cygwin\bin to the path, you'll get something like:
icupkg: unable to open input file /cygdrive/d/icu/win32-x86/data/out/build/icudt55l\coll\root.res"
But if you add cygwin/bin after %PATH%, you'll get something like:
link.exe is not a valid executable.
So only the above order works.
Output
You'll get these files in lib (for Win32) or lib64 (for x64):icudt.lib icuin.lib
icuio.lib
icule.lib
iculx.lib
icutest.lib
icutu.lib
icuuc.lib
testplug.lib
and for debug:
icudtd.lib icuind.lib
icuiod.lib
iculed.lib
iculxd.lib icutestd.lib
icutud.lib
icuucd.lib testplugd.lib
When you come to build Qt, set an ICU environment variable to the parent icu directory, and in the Qt make command add the options:
-icu -I "%ICU%\include" -L "%ICU%\%LIB_OR_LIB64%"
where LIB_OR_LIB64 is "lib" or "lib64" depending on the platform.
Thursday, 20 August 2015
Help Qt Designer to find plugins
Qt Designer can't find plugins without QT_PLUGIN_PATH being set. You should also set QT_QPA_PLATFORM_PLUGIN_PATH for the Qt gui applications. If you're writing your own Qt exe, you can set these paths internally.
set QTDIR=C:/Qt/qt5_msvc2012_x64_build/qtbase set QT_PLUGIN_PATH=%QTDIR%/plugins set QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%/plugins/platformsNote also that Qt Designer will only load plugins built with the same libraries. And when you do a debug build of Qt, although it appends "d.dll" to its dll's, it does not append "d" to its executables. So a debug build of Qt Designer, in the same Qt distribution as release, will overwrite the release build, thus preventing your plugins from loading! So always build debug first, then release.
Cygwin connecting by ssh to remote Linux
If ssh can't add your server to its list of known hosts, you may need to create a "passwd" file in C:\cygwin\etc. Use:
mkpasswd -l -p "$(cygpath -H)" > /etc/passwd
Thursday, 6 August 2015
Using Sublime Text Search+Replace to clean Visual Studio Projects
The find-in-files functionality of Sublime Text can be used to find end remove bad settings from Visual Studio project files - handy if you have a lot of projects.
Search for: <ShowProgress>LinkVerboseLib</ShowProgress>\n
and replace it with nothing. That hides a lot of unneeded output.
Replace:
<LinkLibraryDependencies>true</LinkLibraryDependencies>
Search for: <ShowProgress>LinkVerboseLib</ShowProgress>\n
and replace it with nothing. That hides a lot of unneeded output.
Replace:
<LinkLibraryDependencies>true</LinkLibraryDependencies>
with
<LinkLibraryDependencies>false</LinkLibraryDependencies>
To stop MSBuild from linking stuff you don't want lunk.
Sunday, 19 July 2015
Windows keyboard stops working
If your keyboard in Windows ever just stops working, but it's clearly not a hardware problem as you can still log-in - it just doesn't work once you have - look for an icon in the bottom-right (the notification area) called FilterKeys.
Double-click the icon, turn off all its nonsense, and the keyboard should start working again.
Double-click the icon, turn off all its nonsense, and the keyboard should start working again.
Subscribe to:
Posts (Atom)