Showing posts with label zim. Show all posts
Showing posts with label zim. Show all posts

Zim Zim Python Python Fix Fix

I recently upgraded to Ubuntu/Kubuntu 10.04 and it comes with some changes. Zim wiki is now completely python and much faster and clearly cleaner and more attractive. Thunderbird 3 is also very nice. Upgrade went easily, but some questions were difficult, like: "The quantum entanglement of multiple simultaneous realities has caused a Gamma Ray Burst, continue, Yes or No".

It seems that the equation references in Zim are slightly different and so I devised this little tidbit to bring harmony back to the universe of Zim, Zimpy, and perhaps python itself. The point of this is to take {{./Dir/equation_xx}} and convert it to {{./equation_xx}}. I could have used grep, sed, awk or C, but python is a clean language and I think it is more understandable when viewed by others.

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os.path
import sys

# If there is more than one reference on a line in the Zim it will require that the script be run once for each level. 
#I could just iterate a few times, but it is easy enough to hit up arrow in terminal and run again
#I am also limiting the location to within media just to make sure it doesn't go awry in my root directory
#This is GPL code if you have any question what that means : 
#         Return to your home planet and never visit Earth again!!
#Use at your own risk, code provided as example only
fileScan=0

def doall(aDir,anExt):
 name=os.listdir(aDir)
 allScan=0
 global fileScan
 for named in name:
  if named.find(anExt) != -1:
   (jbase,jext)= os.path.splitext(named)
   allScan=allScan+fixequations(jbase,aDir) #t or not determines if it really does something
   fileScan=fileScan+1
 return allScan
 
#Just list the files that would be changed
def fixequationst(thebase,adir):
 print "Fixing ",adir," file ",thebase+".txt"
 return 1
 
def fixequations(thebase,adir):
 allScan=0
 thename1=thebase+".txt"
 thename4=thebase+"UNIQUEOLD.txt"
 thename2=thebase+"UNIQUENEW.txt"
 handle=open(adir+"/"+thename1,"r")
 handlew=open(adir+"/"+thename2,"w")
 aline="something"
 while aline:
  aline=handle.readline()
  if aline.find("media") != -1 and aline.find("{{") != -1 and aline.find("}}") != -1 and aline.find("equation") != -1:
   token4s=aline[aline.find('{{/media')+2:aline.find('equation}}')+8]
   if token4s != -1  and  aline.find('{{/media')+2 < aline.find('equation}}')+8 : 
    (jbase,jext)= os.path.splitext(token4s)
    jext2=jext.split("?")
    newr= aline.replace(token4s,"./"+os.path.basename(jbase)+jext2[0][0:]+"?type=equation")
#    print newr,token4s,thebase,adir #This would allow progress monitoring of changes
    handlew.write(newr)
    allScan=allScan+1
   else:
    handlew.write(aline)
  else:
   handlew.write(aline)
 handle.close()
 handlew.close()
 os.rename(adir+"/"+thename1,adir+"/"+thename4)
 os.rename(adir+"/"+thename2,adir+"/"+thename1)
 os.remove(adir+"/"+thename4)
 return allScan
 
def scanDirs(ipath,theExt):
 filesChecked=0
 thisext=theExt
 thisdir=ipath
 filesChecked=filesChecked+doall(thisdir,thisext)
 return filesChecked
 
#------- This is where it does something ------
pathsScanned=0
allScan=0
filesChecked=0
if len(sys.argv) > 2:
 InputDir=sys.argv[1]
 x=os.path.exists(InputDir+"/Home"+sys.argv[2])
 y=os.path.isfile(InputDir+"/Home"+sys.argv[2])
 if x==True and y==True:
  print "Scanning"
  for root, dirs, files in os.walk(InputDir):
   for onedir in dirs:
    path = os.path.join(InputDir,root, onedir)
    filesChecked=filesChecked+scanDirs(path,sys.argv[2])
    pathsScanned=pathsScanned+1
 else:
  if x==False:
   print InputDir+" does not exist and returns "+str(x)+" when checked."
  if y==False:
   print InputDir+"/Home.txt is not a file and thus "+InputDir+" is not a Zim Wiki location. And when checked returns "+str(y)
else:
 print "Input arguments::"
 print sys.argv
 print "This requires base directory containing Home.txt and a limit on file types like: .txt"
 print "It must be invoked with python also as it requires 3 arguments."
 print "Example would be:"
 print "\"python FixZim.py /someplace .txt \""

print "Number of paths scanned is "+str(pathsScanned)+" and references changed is "+str(filesChecked)+" in "+str(fileScan)+" files."

Zimming the Wiki with Link maps

So I am doing a bad thing that could bite me later, but I wanted to get ahead of things a bit. I got the debian for the new Zim, which is Python based and so I installed that. I have looked through the code a bit. Everything seems to work the same and I have no problems with functions. The Link Map is new and that is interesting, but seems to be a WIP. Great work all in all. I can program in perl, but actually I find it clumsy and cryptic and more difficult to read, after using Python more.

Actually I don't see how it could bite me as I have been in all the modules and it is much easier to understand structure with Python than perl. It was a good choice to upgrade this. Well done. It seems a bit more polished, intuitive and smoother while still keeping the speed up. It responds much better and just seems less clunky.

This is version 0.46 and it is WAY faster after the PY code gets compiled the first time and beats the interpreted perl by a factor of 10 or more. Total win. Code looks great too and is well formatted.


The new Google search is just what I needed to pair search terms I hope, anyway it is good for links and that helps too. That search return is for aliens, so it gets a better layout sometimes than the tag cloud.

KDE4 is okay

KDE4 is totally awesome. I have gotten used to it and I have Wikipedia , dictionary, feeds, and many more widgets and they are really nice. I think they have a good vision for what they wanted and it was a rough start, but well worth the problems. Thanks you KDE. It isn't really that great a learning curve, I had more trouble using Apple desktop in genetics lab.

Okay, I admit it, this is really good. KDE4 is prime time stuff now and is the best color scheme and integration I have ever seen. A+++ It is a winner, 9.10 is great too. The most important thing?, it can browse XKCD on the desktop as a widget! And feed Slashdot and my favorite blogs as a gadget too.

I really enjoy the equation editor in Zim Wiki (( for reference I have tested PyZim version0.43 and it has almost identical features and seems to work quite well I didn't get real wild, but it seems it will be more "featureful" and supportable in Python.)) and it also has a diagram editor that uses graphviz now and so that is even more fun. It is part of add ons.

Ooh! they fixed equation editor preview as standard to get right window size! Neat.


\begin{cases}4x + 2y = 14 \\ 2x - y = 1.\end{cases} \,

digraph Matter { matter -> energy energy -> matter }

More on 'Zim the Python incarnation'. It includes MindMap using Cairo and so I am really looking forward to that. Below are quotes from the source tracker. Very nice and I learned something else from the "makefile" :-) I didn't realize a person could execute to get a variable.

PYTHON=`which python`
$PYTHON
Implement a MindMap widget to track links 1. Zim 2. Blueprints 3. Implement a MindMap widget to track l...
We need a "MindMap" widget, preferable Cairo based, to show and draw relations between pages. The widget should be able to handle complex graphs, not just hierarchical mindmaps. Each node in the graph would be associated with a page in your Notebook.

Messing with fuzzy select in gimp.


Maybe more than okay, as it has a real professional style developing and I could get used to it.I am blogging from my 32 bit Kubuntu v9.10 desktop and I actually like it now. It takes some getting used to. If you are a console user it seems frivolous to have all the widgets, gadgets, flipping, fading, pretty stuff. Okay maybe it is frivolous, but I can tolerate it and it can be configured the way I like. Install was very smooth and the new grub is almost artsy. Good work. Now I have to see if it rocks. I know it will as I am up on Python 2.6 and that means new features and new blender stuff. Also I have to see what is new with gimp and inkscape and so many other useful things.

I think I need a better more standard font for blogger or set default may be better, so I will fix that now. That may take some time as I want to investigate what fonts are standard with Linux and make the best use of that so I don't have to play around as much when I go to 10.04 version in March.

  1. firefox
  2. blender
  3. gimp
  4. zim
  5. inkscape
  6. gvim
  7. espeak
  8. graphviz
  9. idle
  10. dvipng
  11. okteta
  12. nmap
  13. g++
  14. unrar
  15. openmovieeditor
  16. kde-games
  17. zenmap
  18. ipython
  19. mesa-utils

Got firefox,blender,gimp,zim, inkscape, gvim ( Okay so I am not a purist vi person,. so what ), espeak. graphviz, idle (Python console), dvipng, [latex(tex-common)],((KHexEdit replaced by Okteta)),okteta, [hexedit=silly shell program that fails badly in konsole] ,nmap,g++ (for compile polyML), unrar (for makehuman python scripts extraction),openmovieeditor , ..... I am using Verdana for paragraphs and that seems okay in Firefox right out of the mill. And you bet I have Firebug, that is just too useful to be without. Wikipedia , that goes in the Firefox dictionary for sure!


motey@motey-desktop:~$ uname -a Linux motey-desktop 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux motey@motey-desktop:~$ cat /etc/issue Ubuntu 9.10 \n \l ---- ALSO ---- motey@motey-desktop:~$ lsb_release -c Codename: karmic motey@motey-desktop:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 9.10 Release: 9.10 Codename: karmic

And some stuff to cleanup and add back a few disks here and there. Also have to mount the external shares for nfs. I won't post my SSH keys here though :)


sudo fdisk -l ls -lA /dev/sd* | grep -E 'sd[abcd][0-9]' UUID=(hexes) /mnt/external auto users,auto,atime,rw,nodev,noexec,nosuid 0 0

I did have a little scare with grub, but I am at fault there for having such convoluted hardware arrangements that shift like sand. If they come up with a grub that can unscramble my mess I want to look at that source code.

I don't recommend using ATI proprietary drivers as they are VERY crashy and I put them in and took them out using the reference at: https://help.ubuntu.com/community/RadeonDriver Kwin seems to crash with ATI and it is a mess. If the hidden drivers ever start working I will post something here. I may lend my support to help speed up the open source drivers. They are a little slow, but acceptable.

motey@motey-desktop:~$ glxgears 14284 frames in 5.0 seconds 14565 frames in 5.0 seconds 14575 frames in 5.0 seconds

Vector formula practice

Now I am sure that the multiplexing of all the things I study are starting to create random expression problems when I document. "practice and practive", I wonder if that v was for vector? The mind is a chaos approximation engine.

Wikipedia has a very good reference to using equations in HTML and LaTex.

\overbrace{Vector\ properties}^{La^Tex\  reference} \ \ \ \begin{cases}
Scalar \  |\stackrel{\rightarrow}{A}| \\
Vector \stackrel{\rightarrow}{A} \\
dir(\stackrel{\rightarrow}{A}) = direction \\
det(\stackrel{\rightarrow}{A},\stackrel{\rightarrow}{B}) \\
\begin{bmatrix}a_1,a_2 \\ b_1,b_2\end{bmatrix} \\
det=(a_1\times b_2)-(a_2\times b_1) \\
det= \\
\hat A \times \hat B = \hat C \\
vec\  \vec A \\
dot\ is\  \dot{x} \\
Double dot\ is \  \ddot{A} \\
bar\ is\  \bar B \\
b\times h \times cos(\theta) \\
(\vec A \cdot \hat B)
\end{cases}

The goal is to have the documentation, that is in the program, display the description of a specific code sequence with the proper mathematical language. These things can be very complex and it is not just Nuclear physics or Astronomy that makes this difficult to use. OpenGL and AI for a game that is real time over a UDP connection can involve mathematics, methods, and concepts that are more complex than the most sophisticated equations of a neutron star collapse. Just incorporating light and its refraction, reflection and interference can branch to infinity very quickly.

I hope to have 'espeak' integrated well enough to allow the merging of a phoneme based language into the videos, so that in addition to speaking in the native language of the program user, it puts that audio in the video recording in a language specified with a speaker designation from a set of phoneme objects which is derived from Fourier analysis and recomposition.

Vectors in latex

The vector relationships can be analyzed using the angles of their intersection. Here the triangle and the relationship of the shadow ( or projection on plane ) of a vector describes the relationship between perception, effect, and identity. The relationships of the sides of a triangle do not change the ratio of A:B:C when transformed in distance, however rotation on axis changes the perception (effect). These things are critical to understanding angular momentum, orbits, and gyroscopic effects.

This also serves to enhance my LaTex skills with a new method \stackrel.

I am not a fan of the - and + signs applied to things that have more than one dimension and each time I see them I must now do a mental transform of my own to convert to what I consider a more proper representation of dimension without paired or even tripled negatives that are untangled after the fact. A string that vibrates down or up is not negative or positive, except by convention and position of observation. I may develop some symbols to represent a vector which is paired in symmetry. The attempts to unscramble a lack of complexity of description of the 3 space and its sets leads to many a bizarre work-around in practice IMHO.

If you look at the optical rotation of polarized light of biochemical compounds and their handedness rules it becomes quickly apparent that the symbol set is weak and poorly descriptive of systems of molecules with more than one chiral center. Even in a simple area like the relative rotation of hydrocarbon molecules Cn, the notation is incomplete and thus fails to be measurable complete. It is like a "case" statement in C which covers two of three possible conditions and simply ignores the third. I think it is bizarre, others are not troubled by paradox, I guess.

I think that the math system as it exists is like some huge software project that gets tweaks here and there to correct problems and is so ingrained and so heavily used that making a change is actually impossible, except for my own sanity. If you think that changing from English to metric measure is bad, think about changing the rules of math and retraining everybody in the world, ain't gonna happen in even 5 lifetimes.

The biggest problem with that is, if a machine can be given the proper rule set and has an advantage that can never be overcome, as machines don't care if you change the rules every millisecond, they just do what you program them to do, then they cannot be out thought and defeated in a worst case scenario of the Skynet decomposition. I can almost see the scenario. Programmer one finds it too difficult to resolve enemy combatants and so sets kill all in a certain scope and makes it a feature. Simultaneously another programmer finds that boundary conditions are screwing up analysis and sets scope to infinity. End result: Berserker.

It is possible that many of these things will not happen in the near future, however it is more possible that many of these things which are possible could crop up over time in a complex society. Some strange fluke could make a nano-machine that is just the right shape to screw up everything. Probability is the thing that is the worst contraption and I am afraid that will never be something that is controlled. The infinite probability engine might make me a liar one day IDK.

Fixing my Zim wiki for Latex equations

This is in the file 'EquationEditor.pm'
in directory '/usr/share/perl5/Zim/GUI/'

sub show { my ($self, $file) = @_; my $dialog = Gtk2::Dialog->new( __("Equation Maker"), $self->{app}{window}, #. dialog title [qw/modal destroy-with-parent/], 'gtk-help' => 'help', 'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok', ); $dialog->set_resizable(1); $dialog->set_default_size(400, 300);

I use the equation editor in my Zim wiki quite a bit and it bothered me that it showed up hidden in preview unless I resized the window afterwards. It got to the point that I had to mod it to work, for my sanity. The Line 'set_default_size(400, 300);' was changed from 400,0 and that fixed it.

The strange thing is that I change language context without even thinking, this is obviously perl with some gtk, but it all seems like a useful blur now, whether HTML, CSS, or whatever 5 |-| 1 7 it happens to be.

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen