Monday, 28 October 2013

Snippets moved

I completed my transfer of snippets from Smipple to GitHub, so now they are available again. I guess I need to fix the embedded code in my old posts as well at some point.

But no sooner had I thought Mygists would fix the problem of finding the Gists than it's down. Hopefully not for long. The good thing is that Mygists is open-source and in any case has a usable API so I can always set up my own service if needed.

Now I wonder if I should move my small projects from there? A gist can include more than one file so at least a couple of those projects would work well.

Friday, 25 October 2013

D'oh, or theme continued.

I had completely forgotten that GitHub supports this as well. They just call these snippets Gists. I think this pretty much is a no-brainer now. GitHub versions the files , allows branching and I can even download all Gists on a go, although it requires a bit of scripting (hey ho). The only thing I miss right now are tags.

And the same code as an embedded Github Gist looks like:

We have a winner!

EDIT: I just found out MyGists. It supports tagging the gists with hashtags, so now the last big problem is solved - how to find the script I want after I have a large number of them.
I tried the snippet databases mentioned in my last post. I dropped DZone quickly without even trying it because it just looks ugly. SourcePod was interesting, but not really a database as there is no login. You can only find your old scripts from the same machine you submitted them.

That leaves Snipt and Snipplr. Here's what the embedded code looks like for Snipt:

And the same code for Snipplr:

I was eventually more drawn toward Snipplr but I'm starting to lean toward Snipplr for two reasons: first it looks like not much is happening at Snipplr any more. Last blog post was two years ago. API documentation is in one initial blog post years back. Snipt on the other hand seems to still be under active development. And Snipt is open source! Snipplr is still being used but it's still a bit disconcerning.

There are things in Snipplr I wish Snipt had. The embedded output for one, line numbers are nice. It also supports versions for each snippet.

Neither supports direct Git support. It would be nice to be able to pull your scripts occasionally so that if the service stops working I still have them readily available.

Wednesday, 23 October 2013

Code snippet hosting

Dang. has been down for a while and it looks like fixing it isn't a top priority for the maintainer. So I need to find a new home for my code snippets and hope I can get them out of smipple at some point.

The candidates that I could find during a quick browse are:

Next I need to evaluate these. 

Thursday, 17 October 2013

Effective quickfix window use in Vim

I have now setup Vim to take more advantage of the quickfix window and I think it's a pretty neat way.

First I changed cscope to use it instead of the default way which is a bit bulky by adding the following to .vimrc:
set cscopequickfix=s-,c-,d-,i-,t-,e-   
This in itself is cool because now I can just jump between the hits.

Of course quickfix window is already used when I build the software. Just to make moving around this list I did the following mappings:
map <A-p> :cp<CR> 
map <A-n> :cn<CR> 
So now I can use Alt-p and Alt-n to move between items in the quickfix window. The nice thing is, that this now also applies to any cscope lists! So instead of searching, then selecting a number to see a single context of, say, a function call, I can jump in the code to see all the hits with those keys.

And just to top this off, I also added the following:
map <A-P> :colder<CR>
map <A-N> :newer<CR>
Which means that I can now build, then maybe do a cscope search to check something (say, a function prototype) and quickly move between these two quickfix windows with those keys!

As a sidenote vim-airline messes up my GVim window badly, especially when using those quickfix windows so I had to move back to Powerline. Shame, because Airline had plenty of stuff going for it.

Friday, 20 September 2013

GDB inside Vim using clewn

I finally got around trying gdb inside vim and after a bit of tweaking it works.

Basic instructions are easy enough except for a few things. First, the readline mentioned is a package called libreadline-dev. Secondly, at least in Ubuntu 12.04 I needed to upgrade gdb to version 7.5 with

tar xvfz gdb-7.5.tar.gz
cd gdb-7.5
cp gdb/gdb /usr/local/bin

Because without this I got errors about some terminal issues. But after this running "clewn -va " and then "file
Having said that, for some reason command output is still only printed inside gdb, such as variable values. The buffer mentioned in the clewn documentation seems to be missing.

Friday, 13 September 2013

Copying from GVim

I had this annoying and weird problem with copying stuff from GVim to other apps. I just couldn't get it to work, no matter how many instructions I followed. I verified with xclip that none of the choices worked ("*y, "+y or painting with mouse). Funnily enough copying to GVim did work.

I still don't know what the full problem is, but I noticed I had been using vim-athena which does have xterm clipboard enabled (every instruction tells to check this first and most also end there) but not mouse. I don't know what that mouse option does since the mouse did work.

In any case, I installed vim-gtk2 and I got this to a working condition. Well, mostly. I can use the X clipboard ("*y) and I can use the mouse, as long as I click directly to the correct window with the middle mouse button. So I can't first activate the other window with the LMB or this doesn't work. Also system clipboard ("+y) still doesn't work.

But I can live with this, this was by far the most annoying problem I have had with vim so far. This is a deviation from other apps, since I can select other windows before copying the X clipboard.

So if you have the same issue with GVim in Linux, try the other versions of graphical vim and see if it helps.