Planeta Blogów WMI UAM

March 10, 2025

Borkowski Marcin

2025-03-10 Persisting variables across Emacs sessions revisited

You really never know. My post about persisting Emacs variables was a short tip, written in literally a few minutes to give me a respite from writing and time to complete some longer posts which are underway. It is no mystery that some posts are long (and I hope good) articles, and some are just short texts I put out when I’m overwhelmed with work – and the post about persist was definitely in the latter category. While I still consider it a useful tip, I never expected to get serious feedback about it – and here it is.

First, a commenter told me about the savehist feature, which has been part of Emacs since v22.1. I have to admit I didn’t know (or didn’t remember) about savehist – it’s no shame, though, Emacs is huge and nobody can be reasonably expected to know everything about it.

Anyway, savehist is something which indeed does roughly the same thing as persist. There are some differences, though. For example, persist saves the variables it knows about on killing Emacs, while savehist also saves them every 5 minutes (which is a nice thing, since Emacs crashes are very rare but not unheard of, especially if you run the bleeding edge like me). The main difference, though, is that savehist – as its name suggests – is really aimed at history variables. It uses a pretty clever trick to activate itself when the user enters the minibuffer, then checks if a history variable is used and if it is, it automatically adds it to its list of variables to keep. You can add custom, non-history variables for it to save with savehist-additional-variables and prevent some histories from saving with savehist-ignored-variables, so it can be used to keep any variable saved, though. (It also has a pretty interesting feature which makes sense for history variables but is absurd for most other uses, which is to automatically trim the saved list to a predefined number of elements – see the docstring for savehist-additional-variables.) My understanding is that this is aimed at users who want to customize Emacs to persist (some or all) history variables and possibly something else. On the other hand, persist is much smaller (about 120 lines compared to savehist​’s 250) and hence simpler, and looks like something aimed also (or maybe even mainly) at package writers who want their package to have the value of some variable remembered across Emacs sessions. This is something that savehist explicitly doesn’t support – the list of saved and ignored variables are kept in user options, and I can’t imagine a package changing the value of a user option behind the scenes. With persist, the list of kept variables is not “centralized” in an option (it is kept in an internal variable persist--symbols, though) – every persisted variable’s value is saved to a different file, named after that variable, and you can just delete a file from the ~/.emacs/persist directory to stop persisting a no longer used variable. (Of course, if you have a persist-defvar invocation in your init.el, the file will be recreated when you restart Emacs.) This has an interesting consequence – if the variable’s name contains a slash, then its value is kept deeper in the directory hierarchy. (If you are wondering what would happen if someone used an actual null byte in a variable name – which is technically possible, of course – well, I checked that, and rather predictably you get a wrong-type-argument filenamep error.)

Quite unexpectedly, I also received an email with someone telling me that Emacs has yet another way to persist variables, and – surprise! – it’s built-in, too! Multisession variables are very similar to what persist offers, with one important distinction – you need to use the function multisession-value to access the value of a multisession variable. It also works as a setter, so (setf (multisession-value my-variable) my-value) is the way to set or update a value of such a variable. (If you wonder how it’s possible that multisession-value is a function and not a macro, the answer is simple – multisession variables are in fact wrapped in objects holding more than just the current value of the variable, and multisession-value is made to be a generalized variable, something I might be tempted to write about in a future blog post.)

Other than the syntax differences, multisession variables work very similarly to persist​ed variables, with some (minor) differences. One of them is that they support running more than one Emacs session simultaneously, although this support is very rudimentary – there is no locking, so if two Emacs sessions try to update the same variable at the same time, the result is unpredictable. More interestingly, there are two backends for multisession variables – they can be kept in files within ~/.emacs.d (much like persist) or in an SQLite database (provided your Emacs was compiled with SQLite support, which it really should). Also, each multisession variable can contain information about the package it belongs to – this is useful when you say M-x list-multisession-values to see the list of all multisession variables, together with their packages and values, and the ability to interactively edit or delete them.

This means that multisession variables are a valid (and perhaps even better) alternative to persist​ed variables, slightly more expensive in terms of code complexity, but having a few features you might consider worth it (and built-in, although persist almost is, too, being on Elpa). And as is often the case, this means that you – as an Elisp programmer – have a choice which one to choose. (The main reason I use persist is that until very recently I had no idea about multisession variables. In fact, when I wrote my first code using persist, multisession variables didn’t even exist – they are a relatively new addition to Emacs, dating to December 2021, just a few weeks after I used persist for the first time.)

That’s it for today, happy hacking – and happy persisting your variables;-)!

CategoryEnglish, CategoryBlog, CategoryEmacs

March 10, 2025 06:00 PM

March 03, 2025

Borkowski Marcin

2025-03-03 Applying some modification to selected files in a directory

Some time ago I had a rather specific need. I wanted to automatically modify a bunch of files in a directory, and I wanted to automate it as much as possible – but without writing any Elisp. Don’t get me wrong, I love coding in Elisp, but in that case I wanted a solution really quickly, faster than I could possibly code it.

First of all, I knew I can record a keyboard macro which assumes that the point is on a file in Dired and performs the required edits. Here is a template for such a macro:

RET                     ;; dired-find-file
M-<                     ;; beginning-of-buffer
C-s                     ;; isearch-forward
place                   ;; self-insert-command * 5
RET                     ;; isearch-exit
edit                    ;; self-insert-command * 4
C-x C-s                 ;; save-buffer
C-x LFD                 ;; dired-jump

(Note: the above output is not what you could see when typing C-x C-k C-e, that is, kmacro-edit-macro-repeat. It turns out that the commands displayed on the right depend on the mode Emacs was in when pressing C-x C-k C-e. My macro assumes that it is started in a Dired buffer but switches to editing a file. What I did was this: I first edited my macro in Dired mode, copied its contents above, then I edited it again in some other mode and copied just the commands that would be run in that mode. Then I manually replaced newline next to RET to what RET really does in Isearch mode, that is, isearch-exit.) This way the right column shows the actual commands the macro would be invoking, for the sake of clarity.)

Now this is all good – I can now press f4 with the point on a file I want to modify – but I wanted something even more streamlined. I wanted to apply my modification to every file whose name matches some regular expression. Can it be done without writing a single byte of Elisp? You bet it can! In Dired, you can easily mark a set of files based on various criteria. One of them is exactly what I need – dired-mark-files-regexp, bound to * %. (This seems a terrible keybinding, but it’s actually quite mnemonic. Marking commands are on the * prefix, which is easy to remember as the normal way of marking files in Dired is with an asterisk. Then, % reminds of C-M-%, that is, query-replace-regexp. And while at that, do yourself a favor and press * C-h while in Dired to see what mark-related commands are available. For example, you can have several “types” of marks in Dired. In fact, there is even more than you can find on the * prefix – for example searching across marked files. TIL that you can even mark all files which contain a given regex, which is insanely cool and bound to % g – of course, * g would be better – but g clearly stands for grep here.)

Now, if only I could easily move the point to the next marked file. Wait, but I can! The key M-} (which is not easy to type, but you only need to do it once per macro in my case) is bound to dired-next-marked-file.

This way I can record a macro which visits the file the point is on, makes the necessary changes there, saves, goes back to the Dired buffer and moves to the next marked file. A final tip is this: it might be more useful to first make the changes to the first file manually, stop right before saving and start the macro recording with the save-buffer command. Then of course you stop the recording just before saving the next file. The rationale is that after each macro invocation you get the chance to manually inspect the changes made, and then you either accept them and just press f4 to save, move to the next file and make changes there, or adjust something in the current (unsaved) buffer and then press f4 to do the same. (You can achieve a similar result with C-x q or C-u C-x q during macro recording, but it is a bit more work.)

If you are astonished that I actually advocated not coding in Elisp this time – well, Dired and Emacs keyboard macros are pretty powerful, and as you can see, can go a long way! And you can of course marry the two approaches – for example, you can create a command to make the changes you need in every of the marked files, and then record a macro which runs that command, saves the file, goes back to Dired and moves to the next marked file (or something similar). As usual with Emacs, its legendary flexibility is there for you!

That’s it for today, see you next time!

CategoryEnglish, CategoryBlog, CategoryEmacs

March 03, 2025 06:00 PM

February 22, 2025

Borkowski Marcin

2025-02-22 Inserting Ledger transactions even faster

After I wrote my mbork-ledger-insert-transaction command, bound it to C-c C-v (in Ledger mode only, of course) and started using it, I noticed a big problem with it. It only inserts the heading line of the transaction and its source account, leaving the line for the target account empty. The result is that I need to fill in that line manually, which defeats the purpose of inserting the whole transaction fast.

By the way, in the meantime I upgraded my Ledger mode and it turned out that the newer version already has something quite similar to what I am writing, that is, C-c C-a (ledger-add-transaction). It does not work for me very well, though – it uses the Ledger xact command, which is much too “magical” (that is, I don’t really know what it does under the hood) and unreliable for me. I suspect that it finds the first transaction in the file matching the given criteria and creates a “similar” one with the given date. This is one of the problems – I would very much prefer if it looked for the last transaction matching what I tell it. Moreover, I still have to type quite a bit. For example, my solution lets me choose the source account with just one keystroke instead of a regex matching some account. Also, I heavily utilize amount eliding, so my grocery transaction may have three postings, food, candy, and wallet, and I will type in the amount spent on candy (which is usually much smaller than the one for food, hence it is easier for me to enter) and the whole amount I paid (“wallet”, with a minus sign), which is something I can just copy from the receipt or the bank history, letting Ledger fill in the food spending (which is often a lot of items I don’t want to spend time adding manually (even using my Calc-based command). Apparently, when the first posting (here, “food”) does not have an amount associated with it, xact does not work. All these issues are probably related to how I use Ledger (and since it is very flexible, this may be very different to how John Wiegley uses it), but they mean that xact is pretty much useless for me.

I spent some time thinking how to solve it. I started (again) with looking at Ledger mode sources – this time I made sure that I pulled the newest version from the official repo (it turned out that previously I was using a very outdated version). It is easy enough to get the list of all accounts in the current buffer (as strings) – the function ledger-accounts-list-in-buffer does exactly that. I could do that and ask the user for the account – with completion – but that is not what I want here. If I went that route, I would need to add one more interactive step to the list of things the user has to do, that is, select the target account. This could work, but usually, when making a purchase in some specific store (whose name I already have in the transaction description), the target account (which is the “spending category”, like “food” or “books”) is the same – it is not very probable that I’d buy food in a bookstore or books in a grocery store. With that in mind, I decided that my code should search the current buffer for the most recent existing transaction with the same description and get the target account from there. This will not cover all cases (I often shop in discount stores where I can buy food, snacks and other things, and sometimes I may buy very different things there), but should be enough for a vast majority, especially that the “most common” type of things I usually buy in a particular store is almost always the first posting in the transaction.

For example, here is one possible transaction from my Ledger file (translated into English):

2024-11-29 * Some store name
    Expenses:Food
    Assets:Cash:My wallet    -12.34 PLN

I may additionally buy some candy and/or something for a friend, and then the transaction would look like this:

2024-11-29 * Some store name
    Expenses:Food
    Expenses:Candy            4.56 PLN
    Assets:Receivables:Tom    5.67 PLN
    Assets:Cash:My wallet   -22.57 PLN

As you can see, the first posting is always the same, so copying that line and only it is a very reasonable idea. Of course, if there are no matching transactions (which may happen when entering some description for the first time), the target will be left empty for the user to fill in, but that’s ok, since it’s going to happen only once per transaction description (which is the store name in my case).

As for finding the previous transaction, I just decided to use re-search-backward with a custom regex. Again, this might not work for everyone – for example, I use ISO-8601 dates exclusively, and all my transactions are in the “cleared” state. (I don’t often use transaction states, and Ledger mode displays the description of a “pending” transaction in a bright red, so I reserve that state for transactions which are entered tentatively and should be fixed as soon as possible. For example, when I type in the bank statements, I don’t always know how to categorize some items there, so the transactions spend the relatively short time – before me typing them in and my wife telling me what she bought – in a “pending” state.)

Finally, I set ledger-clear-whole-transactions to t – I have no use for using states of individual postings in a transaction anyway, so this allows me to clear the current transaction even if the point is not on its first line.

Note: I’ve been using this setup for some time now, and I have to say that it is much better than the previous version. Time will tell if I find yet another way of streamlining my usage of Ledger, but I’m quite happy with it as it is!

CategoryEnglish, CategoryBlog, CategoryEmacs

February 22, 2025 09:00 AM

February 17, 2025

Borkowski Marcin

2025-02-17 isearch-forward-thing-at-point

One thing which I do very often is isearching for some term, like a function or variable name. Recently I learned that Emacs has a nice feature which helps with that. Pressing M-s M-. (or M-s .) invokes the isearch-forward-thing-at-point command, which does exactly what you would expect. Very useful! In fact, pressing M-s C-h reveals even more usefulness. Try it out for yourself!

CategoryEnglish, CategoryBlog, CategoryEmacs

February 17, 2025 06:00 AM

February 10, 2025

Borkowski Marcin

2025-02-10 Running one own's commands

One of the common complaints of Emacs users is “I defined this cool little command to make my life easier and then I forgot to use it”. Well, I found one way to help with that. Every Emacs function, variable and macro somehow knows in what file it was defined, so in theory it shouldn’t be too difficult to know which functions were defined, say, in the user’s init file. Then, I could create a special version of execute-extended-command (usually bound to M-x) which could only run commands defined in the user’s init file.

It turns out that the practice is slightly more complex. One complication is that some users employ Org mode to load things on startup. For example, I have this in my init.el:

(org-babel-load-file "~/.emacs.d/init-file.org")

This means that my commands are not really defined in ~/.emacs.d/init.el, but in ~/.emacs.d/init-file.el instead. This means that I can’t just use user-init-file to get the name of the file to look for “my” commands in. Also, it was not obvious for me at first where to look for the filename where a function was defined. I even asked about it on the Emacs mailing list, and after a few hours I got the answer I needed: the load-history variable. (Interestingly, I could have found this variable myself. I looked into Emacs sources and I managed to find the symbol-file function. Had I checked it in the Elisp reference, I would probably notice that load-history is described in the same section. That is a good lesson for the future – when looking for a function, variable or macro I need, I can check the reference’s sections corresponding to related functions, variables or macros.)

Anyway, once I know about load-history, it is very easy to get the list of all commands defined in a given file.

(defcustom my-command-file user-init-file
  "File to look for commands in `execute-my-command'.")

(defun my-commands ()
  "A list of all commands defined in `my-command-file'."
  (seq-reduce
   (lambda (acc elt)
     (if (and (consp elt)
              (eq (car elt) 'defun)
              (commandp (cdr elt)))
         (cons (cdr elt) acc)
       acc))
   (alist-get my-command-file load-history nil nil #'string=)
   ()))

(After I wrote this, I learned about the file-loadhist-lookup function, which might simplify the above code a tiny bit, but I decided it’s not worth it to change it.)

Like I said above, I keep my commands in a separate place, so I can do this instead.

(setq my-command-file (expand-file-name "init-file.el" user-emacs-directory))

Since load-history contains absolute filenames, I decided to use expand-file-name and user-emacs-directory so that I can just give Emacs the name of “my command file” and not bother with typing (or copying) the absolute path to it; your mileage may vary.

Now, to run a command but with autocompletion restricted to “my commands” only it is enough to temporarily bind read-extended-command-predicate.

(defun execute-my-command (prefix-arg)
  "Execute a command found defined `my-command-file'."
  (interactive "P")
  (let* ((my-commands (my-commands))
         (read-extended-command-predicate
          (lambda (command buffer)
            (memq command my-commands))))
    (execute-extended-command prefix-arg)))

(global-set-key (kbd "s-X") #'execute-my-command)

I also bind my-commands to the result of evaluating (my-commands) (neatly using the fact that Elisp is a Lisp-2) so that the list of “my commands” is only created once per using execute-my-command. Finally, I bind it to s-X (that is, super + shift + X) and that’s it.

A bit ironically, the only remaining issue is to remember to use execute-my-command instead of the usual execute-extended-command (M-x)… Still, it’s way easier to remember one command than over a hundred of them (I indeed have that many commands defined in my init file!).

As usual, Emacs turned out to be a really great environment for people like me who like to tinker with their configs and the ways they use their computer. Not that I’m surprised!

CategoryEnglish, CategoryBlog, CategoryEmacs

February 10, 2025 06:00 PM

February 01, 2025

Borkowski Marcin

2025-02-01 ketchup.el

A few years ago I wrote tomato.el, which I’ve been using ever since on a daily basis. I was not always happy with it, though. The main issue I had with it is that the 25 minute intervals seemed a little bit too rigid. Oftentimes I heard a ding meaning that a tomato has just ended, and I take a short break, which disrupted my flow. Other times the short break became a bit longer and my productivity plunged. Also, it was not rare that I finished some task and saw that only, say, 18 minutes passed, so what do I do for the next 7 so that I don’t “lose” my tomato?

Some time ago, someone pointed me to an absolutely fascinating article about a concept called Third time, which really resonated with me. It also mentioned how the Pomodoro technique is worse than you might think, and even if I didn’t arrive at the exact same points, I fully agree with that criticism. To reiterate my last example, I often worked on some task A for some time – say 40 minutes – and then switched immediately to some task B, spending 10 minutes on it before taking a break. This means that I clocked just one “tomato” even though I worked for 50 minutes and “deserved” two. (I usually solved this by not clocking out of task A, which gave me the two tomatoes, but that corrupted my clock data. This was not as bad as it seems – when many of my tasks take several hours, discrepancy on the order of minutes is not really a problem, but it still bothered me a tiny bit.)

The most intriguing here is the fact that I independently devised a system very close to the “Third time” concept. I have intended to blog about it for a long time (I made an Emacs tool to help me with that about 6 years ago!), but my code still a bit buggy, so it will probably have to wait some time until I resolve its issues.

In the meantime, I decided to stop using tomato.el and introduce a new system. Instead of 25-minute chunks, it uses 5-minute ones, so the most I can “lose” if I clock out early is 4 minutes, not 24. (Since I’m going to use small pieces of a “tomato” instead of the whole ones, I decided that ketchup.el is a great name!) Of course, I still want something to incentivize me to work in longer intervals and not take a 1-minute break after each 5 minutes of work – that would be ridiculous. Here is my idea. Instead of counting “pomodoros” or “tomatoes” in Beeminder, I’m going to count abstract “points” based on these 5-minute chunks. However, the amount of points is not a linear function of the time spent working. Spending N minutes productively translates to floor(N/5)*(1+floor(N/25)) points. In other words, every 5-minute chunk is worth one point plus the number of points equal to the number of full 25-minute chunks. This way, working for a full 25-minute period still gives me a nice bonus, but stopping after 24 minutes is not worthless, either. Also, if I’m in the flow and don’t stop working after 25 minutes, but work for, say, 30 or 35, that is “better” than working for 25, taking a break and then working for the additional 5 or 10 minutes.

Initially, I thought to make this function a bit more complicated and explicitly “punish” (by awarding fewer points) continuous intervals of work of more than, say, 50 minutes. The idea is that I should take breaks and not sit down for prolonged periods of time. However, I hardly ever do that, because every now and again I need to go to the toilet, or make myself some tea, or something like that, so I figured I don’t need additional incentives for that anyway. (Case in point: I downloaded my Beeminder data for the goal I have for my daily job for several years. I had over 28 thousand datapoints – meaning 28k+ stretches of work – and only 22 of them were 90 minutes or longer.)

Interestingly, just changing the code for tomato.el so that another number of points is sent to Beeminder is not enough to achieve what I want. The first change I needed was that I no longer want notifications about some interval passing – the whole point is that I don’t want my flow to be disrupted. From now on, the plan is to work for how long it’s needed, not in rigid, 25-minute stretches. Another change is that I now need to tell Emacs that some tasks should not be awarded points. For example, I have some “tasks” for the few videogames I play, with a “do-less” Beeminder goal attached. They are mostly casual games I spend no more than 10-15 minutes on at a time. When using tomato.el, that was not a problem – in the (very rare) case of playing for 25 minutes or more, I just deleted the Beeminder datapoint manually. Now that would definitely not scale – playing for 5 or 7 or 10 minutes is something I do much more often. I decided to add another Org property, called just ketchup, which must be set to a non-empty string for the respective headline to be eligible for “ketchup points”. (Of course, this property is inherited throughout the Org file structure.)

And that’s if for today. I started a new Beeminder goal for the “ketchup points”, with a conservative slope for now, to see how it goes.

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode

February 01, 2025 05:00 PM

January 27, 2025

Borkowski Marcin

2025-01-27 org-use-sub-superscripts

Today I have a short tip which is very niche, but potentially useful to some people. At least, it’s very useful for me. ;-)

I have a big Org file with work-related notes. This means that it contains lots of code snippets (mostly SQL, sometimes Bash or JavaScript). It also means that non-code notes often contain references to identifiers.

Being a Lisper, I obviously like my identifiers to be kebab-case. Of course, you can’t use those in SQL or JS, so in those languages I’m stuck with snake. (I hate camelCase and its ilk with passion, although Emacs can make them just a bit more palatable.)

This poses a minor but annoying problem. Surrounding each and every identifier with ~ to mark it as “code” is very inconvenient, especially when I want to copy them to the kill ring. On the other hand, if I don’t do that, I get a result looking like this:

snake case identifier.png

The reason is obvious – Org mode tries to be helpful and treats _ as introducing a subscript.

I thought that I almost never use actual subscripts in my Org documents, so why not turn this feature off? Initially I thought of a very quick and dirty hack, namely redefining the face Org mode ues to show sub- and superscripts. I learned that it is just the general face used for LaTeX fragments, so changing it might be too drastic a step. I looked at the manual, though, and was pleasantly surprised. It turns out that there is an easy way to disable treating characters or words after _ as subscripts. You just need to set the org-use-sub-superscripts option. Go read the relevant section to learn what are the possible values and how to set it up globally or only for a single Org file.

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode

January 27, 2025 06:00 AM

January 20, 2025

Borkowski Marcin

2025-01-20 Sleep versus productivity

Everybody says that in order to be productive, you need to get enough sleep. This, of course, seems reasonable, but is there a way to actually confirm it scientifically?

Well, here is my attempt. Note that it is not really very scientific – but at least it is measurable.

I’ve been using the current iteration (with minor changes) of my personal productivity system for over 3 years now. Of course, I track the “points” I get for completing my tasks in Beeminder. Also, I have Beeminder goals to go to bed and get up not too late. Those two are simple – I track the “number of minutes after 22:00 I go to bed” and “number of minutes after 5:00 I get up” as do-less goals. I’ve been tracking those for almost 9 years now.

Recently, it occurred to me that this means that I have pretty precise data about the length of my sleep and about how productive I was the next day. How about running some simple analysis on those data? Beeminder lets me export all my data for a goal as a csv file (as it should – these are my data, after all!), so that’s exactly what I did.

I am sad to report that the results were rather disappointing. The correlation coefficient between my sleep time and the “productivity points” turned out to be 0.06 – positive, but basically negligible.

I still believe that getting enough sleep is important, of course – even though my primitive experiment did not confirm it. If you have any ideas about how to perform a similar experiment in a better way – I’m all ears. In the meantime, I will continue using my systems.

CategoryEnglish, CategoryBlog

January 20, 2025 08:00 AM

January 13, 2025

Borkowski Marcin

2025-01-13 A minor Org Clive improvement

It’s been a while since I touched Org Clive, but I’m still using it. (Side note: after writing about a dozen articles on my Doctor Who weblog it went a bit dormant. I’m still thinking about it – in fact, even more than thinking, I’m slowly writing it – and I really do hope to come back to publishing there with some regularity. Stay tuned, and if you are interested, keep its RSS feed in your RSS reader.) One gripe I had with it is that the org-clive-generate-subtree command is a bit stupid. If I’m in the middle of writing a long article (and articles on that weblog tend to be long enough to warrant sections), and I’m in the middle of a section of an article, M-x org-clive-generate-subtree tries to export the current subtree (that is, the section), and complains.
Entry ‘…’ does not have the ‘CUSTOM’ property

The solution is obvious – that command should go up the Org hierarchy until it gets to a headline with the CUSTOM_ID property and export it, or signal an error when it doesn’t find any.

Quite fortunately, I have already solved a very similar problem, so I know about the org-up-heading-safe function. The solution turned out to be (expectedly) short, although slightly tricky because of the use of not and unless (and as we all know, negations are a bit less intuitive for our brains).

That’s it for today – stay tuned for more Emacs and programming stuff in the future, and if there is no article here some day, it will most probably mean that a new post appeared on Crimson Eleven Delight Petrichor!

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode

January 13, 2025 09:00 PM

January 05, 2025

Borkowski Marcin

2025-01-05 Killing all buffers visiting files in a certain directory

When I leave the office, I generally close all work-related things – I sign out of Slack, shut down the virtual machine, and unmount the encrypted filesystem with work data. Obviously, I also want to kill all buffers “related to” that filesystem, for example all buffers visiting files there.

This is similar but different from project-kill-buffers – that command kills the buffers belonging to the current project (for example, the current Git repository), and I usually have more than one Git repo in the encrypted filesystem.

There seems to be a few ways of doing this. Probably the simplest one uses Ibuffer. You can just press * e to mark all buffers whose associated file doesn’t exists and then D to kill the marked buffers. This is a clever thing (since the filesystem is unmounted, all buffers visiting files there will get marked), but sadly is not enough. For example, Magit buffers are not associated with files, so they won’t be selected.

Another idea is to use % f to mark buffers by their filename, and enter a regex matching the directory name you need. For some reason, the Magit buffers are also selected with this approach, although I’m not sure why. I think the magic happens in the ibuffer-buffer-file-name function, but I’m not really sure if I want to dig into how exactly this works, since this solution is not complete, either. For example, *Diff* buffers are not marked with this approach, and I often diff similar fragments of code.

It turns out that Ibuffer has yet another facility which can help here. / F can filter the buffers by their directory; once I only have buffers in a given directory, I can press t to mark all of them (actually, toggle all the marks, but if nothing is marked, this does what I need) and then D to kill them.

This, of course, is just a workaround – what I’d really need is a simple command, let’s call it kill-all-buffers-in-directory, which would do exactly this, but automatically. It is still just a proxy – I could open a file in my encrypted directory and M-x cd to another directory in it – but as this is something I never do, closing all buffers whose “default directory” is a subdirectory of the mount point of my filesystem is enough for me.

As usual, the hard thing is to create a reasonable UI. In this case, this means notifying the user about the result of the buffer killing spree. The user must know if not all buffers were killed (this may happen if for example a buffer was visiting a file modified since the last save, and the user answered “no” when asked whether to save that buffer). I decided that just showing how many buffers were killed out of how many found is fine; as an added bonus, I used error if at least one buffer was not killed.

(defun kill-all-buffers-in-directory (directory)
  "Kill all buffers whose current directory is DIRECTORY."
  (interactive "D")
  (let* ((buffers (seq-filter
                   (lambda (buffer)
                     (string-prefix-p
                      directory
                      (expand-file-name (with-current-buffer buffer default-directory)))
                     )
                   (buffer-list)))
         (killed-status (mapcar #'kill-buffer buffers))
         (buffer-count (length killed-status))
         (not-killed-count (seq-count #'null killed-status))
         (killed-count (- buffer-count not-killed-count))
         (message (format "%s/%s buffer(s) killed" killed-count buffer-count)))
    (if (zerop not-killed-count)
        (message message)
      (error message))))

Note that I used the built-in seq-filter to avoid depending on cl. (I could have used seq-map too, but there is nothing wrong with mapcar.)

Also, I had to use expand-file-name. The docstring for default-directory says:
It should be an absolute directory name; on GNU and Unix systems, these names start with “” or “" and end with “”.
It turns out that for buffers visiting files, default-directory starts with / (at least this is what I have observed), but for Dired buffers under my home directory it starts with ~. Go figure.

That’s it for today. As usual, Emacs proves to be a great environment for tinkering and molding your tools into exactly what you need – even if sometimes an unexpected quirk pops up. Of course, I cannot not mention here the late Robert J. Chassell’s excellent Introduction to Programming in Emacs Lisp – and also my book about Emacs Lisp, designed as a “next step” after that. That book shows how to build three utilities in Emacs Lisp, starting from a very simple prototype and arriving at a useful tool for editing prose (reorder-sentence), complete with a pretty polished UI.

CategoryEnglish, CategoryBlog, CategoryEmacs

January 05, 2025 01:00 PM

January 08, 2015

Hromada Mateusz

Warka 9 – American India Pale Ale

Zasyp:

  • pale ale 4kg
  • pszeniczny 0,8kg
  • carapils 0,5kg

Zacieranie w 18l wody, słód dodany w 55°C:

  • 68°C – 65 minut przerwy (po 30 minutach podgrzanie z 65°C do 68°C)

Po filtracji i wysładzaniu wyszło 21,5 litra brzeczki o BLG 11,1.

Chmielenie:

  • 60 minut – 40g Simcoe
  • 20 minut – 30g Simcoe
  • 5 minut – 30g Simcoe
  • 0 minut – 30g Amarillo
  • dry hopping – 30g Simcoe (6 dni), 30g Simcoe (3 dni)

Po schłodzeniu i filtracji wyszło 19 litrów o BLG 16.

Fermentacja (drożdże US-05):

  • 11 dni burzliwej
  • 23 dni cichej

Do refermentacji użyłem 140g cukru i 735g wody.

ABV: ok. 6.2%

by ruanda at January 08, 2015 09:38 PM

Warka 8 – Cydr

Składniki:

  • sok jabłkowy Riviva 22l

Sok ma BLG 12.

Fermentacja (drożdże US-05):

  • 7 dni burzliwej
  • 38 dni cichej

Do refermentacji użyłem 155g cukru i 1135g wody.

ABV: ok. 6.3%

by ruanda at January 08, 2015 09:34 PM

Warka 7 – American Wheat

Zasyp:

  • pszeniczny 2kg
  • pilzneński 2kg

Zacieranie w 16l wody, słód dodany w 45°C:

  • 45°C – 15 minut przerwy
  • 53°C – 15 minut przerwy
  • 68°C – 75 minut przerwy (po 30 minutach podgrzanie z 64°C do 70°C)

Po filtracji i wysładzaniu wyszło 21 litry brzeczki o BLG 7.

Chmielenie:

  • 60 minut – 10g Chinook
  • 20 minut – 20g Palisade
  • 5 minut – 20g Cascade
  • 0 minut – 20g Amarillo
  • dry hopping – 30g Amarillo, 10g Cascade, 10g Palisade

Po schłodzeniu i filtracji wyszło 18 litrów o BLG 12.

Fermentacja (drożdże US-05):

  • 8 dni burzliwej
  • 35 dni cichej

Do refermentacji użyłem 120g cukru i 880g wody.

ABV: ok. 5.5%

by ruanda at January 08, 2015 09:28 PM

November 11, 2014

Girl, lost in IT

Nowy wpis, nowe miejsce

W poprzednim wpisie uprzedzałam, że muszę wprowadzić duże zmiany. Nie jestem już w stanie pisać każdego tekstu w dwóch językach. Dodatkowo czuję, że zmieniłam się przez ostatnie kilka lat – czuję, że „wyrosłam” trochę z tego bloga. Właśnie napisałam pierwszy tekst w nowym miejscu. Blog nazywa się Na miękko - serdecznie zapraszam.

by ynka at November 11, 2014 09:02 PM

October 13, 2014

Krzysztof Szarzyński

Zawieszenie publikacji

Jeśli dobrze liczę, to od 402 dni nic tu nie napisałem. Ponieważ zazwyczaj nie mam niczego interesującego do powiedzenie/napisania, dlatego przerzuciłem się na inne platformy, które lepiej pasują do “beztekstowej” formuły. Nadal robię zdjęcia – więcej niż kiedyś, ale publikuje je w mniejszych porcjach. Zapraszam na mój profil 500px, gdzie wrzucam rożne zdjęcia z całego […]

by Quati at October 13, 2014 06:41 PM

June 12, 2014

Hromada Mateusz

Warka 6 – Żytni Stout

Zasyp:

  • pale ale 2kg
  • żytni 2kg
  • żytni czekoladowy 0,25kg
  • Carafa typ III special 0,25kg

Zacieranie w 16l wody, słód dodany w 55°C:

  • 55°C – 10 minut przerwy
  • 70°C – 60 minut przerwy (po 60 minutach podgrzanie z 62°C do 68°C)
  • 68°C – dodanie ciemnych słodów, 40 minut przerwy

Po filtracji i wysładzaniu wyszło 20,5 litra brzeczki.

Chmielenie:

  • 60 minut – 10g Tomahawk
  • 15 minut – 30g Tomahawk
  • 5 minut – 30g Tomahawk
  • dry hopping – 30g Tomahawk

Po schłodzeniu i filtracji wyszło 18 litrów o BLG 13.

Fermentacja (drożdże S-04):

  • 22 dni burzliwej

Do refermentacji użyłem 125g cukru i 835g wody.

ABV: ok. 4,4%

by ruanda at June 12, 2014 08:38 PM

April 27, 2014

Girl, lost in IT

W planie zmiany + jak tu trafiłam (w obrazkach)

Kolega wyraził ostatnio zaniepokojenie działaniem swojego czytnika RSS. To przecież niemożliwe, żebym tak długo nie napisała nic na swoim blogu! Niestety, możliwe. Do tego powód jest dość absurdalny: piszę mniej, ponieważ piszę więcej. Naprawdę. Pamiętacie, jak przeżywałam swoje 10000. urodziny? Postanowiłam wtedy na poważnie wziąć się za rzeczy, o których zawsze myślałam, że zrobię je […]

by ynka at April 27, 2014 06:28 AM

March 22, 2014

Hromada Mateusz

Warka 5 – Imperial India Pale Ale

Zasyp:

  • pale ale 5kg
  • wiedeński 1kg
  • carapils 0,5kg
  • pszeniczny 0,2kg

Zacieranie w 21l wody, słód dodany w 55°C:

  • 55°C – 10 minut przerwy
  • 65°C – 90 minut przerwy (po 60 minutach podgrzanie z 61°C do 65°C)

Po filtracji i wysładzaniu wyszło 23 litry brzeczki o BLG 14.

Chmielenie:

  • 60 minut – 40g Chinook
  • 10 minut – 20g Citra, 20g Simcoe
  • 5 minut – 30g Citra, 30g Simcoe
  • 0 minut – 15g Cascade, 15g Palisade
  • dry hopping – 15g Cascade, 15g Palisade

Po schłodzeniu i filtracji wyszło 21 litrów o BLG 17.

Fermentacja (drożdże US-05):

  • 9 dni burzliwej
  • 10 dni cichej

Do refermentacji użyłem 130g cukru i 630g wody.

ABV: ok. 7,6%

by ruanda at March 22, 2014 07:44 PM

March 12, 2014

Hromada Mateusz

Warka 4 – American Wheat

Zasyp:

  • pszeniczny 2kg
  • pilzneński 2kg

Zacieranie w 15l wody, słód dodany w 55°C:

  • 55°C – 10 minut przerwy
  • 68°C – 70 minut przerwy (po 50 minutach podgrzanie z 62°C do 67°C)

Po filtracji i wysładzaniu wyszło 21 litry brzeczki o BLG 9,5.

Chmielenie:

  • 60 minut – 10g Chinook
  • 20 minut – 20g Palisade
  • 5 minut – 20g Cascade
  • 0 minut – 20g Amarillo
  • dry hopping – 30g Amarillo

Po schłodzeniu i filtracji wyszło 18 litrów o BLG 13.

Fermentacja (drożdże US-05):

  • 8 dni burzliwej
  • 11 dni cichej

Do refermentacji użyłem 120g cukru i 800g wody.

ABV: ok. 5.3%

by ruanda at March 12, 2014 06:14 PM

February 23, 2014

Girl, lost in IT

Oddam za darmo!

Raz na jakiś czas znajduję w domu coś, co dawno już przestało mi być potrzebne, ale co mogłoby jeszcze przydać się komuś innemu. Niektóre takie rzeczy wystawiam na Allegro (zwłaszcza, jeśli są warte więcej niż kilkadziesiąt złotych), jednak do Allegro często zniechęca mnie konieczność oszacowania kosztów przesyłki. Jeśli chcę pozbyć się czegoś szybko, tanio i […]

by ynka at February 23, 2014 05:23 PM

February 15, 2014

Hromada Mateusz

Instalacja Raspbian przez debootstrap

IMG_20140214_203617

Wymagania

Potrzebny jest Linux, w miarę świeży debootstrap i qemu-arm-static. Oczywiście potrzebny też jest dostęp do użytkownika root.

Partycjonowanie i formatowanie karty SD

Kartę należy podzielić na dwie partycje. Pierwsza, sformatowana w FAT będzie zamontowana jako /boot. Druga partycja będzie zamontowana jako /, można ją sformatować np. w ext4:

root@lol:/mnt# fdisk /dev/sdh
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1021, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1021, default 1021): +64M

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (10-1021, default 10):
Using default value 10
Last cylinder, +cylinders or +size{K,M,G} (10-1021, default 1021):
Using default value 1021

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
root@lol:/mnt# mkfs.vfat /dev/sdh1
[...]
root@lol:/mnt# mkfs.ext4 /dev/sdh2
[...]
root@lol:/mnt# mkdir rpi
root@lol:/mnt# mount /dev/sdh2 rpi/
root@lol:/mnt# mkdir rpi/boot
root@lol:/mnt# mount /dev/sdh1 rpi/boot/

Instalacja i konfiguracja

Debootstrap należy przeprowadzić w dwóch etapach, gdyż binarki przeznaczone są na inną architekturę.

root@lol:/mnt# debootstrap --foreign --arch armhf wheezy rpi/ http://archive.raspbian.org/raspbian
[...]
root@lol:/mnt# cp /usr/bin/qemu-arm-static rpi/usr/bin/
root@lol:/mnt# LANG=C chroot rpi/ /debootstrap/debootstrap --second-stage

Następnie można chrootować się na budowany system:

root@lol:/mnt# LANG=C chroot rpi/ /bin/bash

Potrzebne są repozytoria w sources.list:

deb http://archive.raspbian.org/raspbian wheezy main contrib non-free
deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free

W pliku /boot/cmdline.txt należy dodać parametry do kernela:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

/etc/fstab:

proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 0

Różne sieciowe ustawienia są w plikach /etc/hostname, /etc/resolv.conf i /etc/network/interfaces.

W chroocie należy doinstalować paczki git, binutils i ca-certificates.

Potrzebne jest narzędzie rpi-update:

root@lol:/# wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update
root@lol:/# chmod +x /usr/bin/rpi-update
root@lol:/# mkdir /lib/modules
root@lol:/# rpi-update
[...]

Aby dostać się do RPi po restarcie potrzebne jest ssh i hasło na roota:

root@lol:/# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@lol:/# apt-get install ssh
[...]

Po wyjściu z chroota, odmontowaniu obu filesystemów i przełożeniu karty do RPi powinien zabootwać się Raspbian dostępny przez ssh:

root@trololo:~# uname -a
Linux trololo 3.10.30+ #640 PREEMPT Fri Feb 14 19:09:14 GMT 2014 armv6l GNU/Linux

Linki

by ruanda at February 15, 2014 01:20 PM

February 02, 2014

Hromada Mateusz

Warka 3 – American Stout

Zasyp:

  • pilzneński 3kg
  • monachijski 1kg
  • jęczmień palony 0,3kg
  • barwiący 0,2kg

Zacieranie w 15l wody, słód dodany w 55°C:

  • 55°C – 10 minut przerwy
  • 68°C – 70 minut przerwy (po 35 minutach podgrzanie z 64°C do 66°C)
  • 66°C – dodanie ciemnych słodów i 15 minut przerwy

Po filtracji i wysładzaniu wyszło 22 litry brzeczki o BLG 11.

Chmielenie:

  • 60 minut – 15g Centennial
  • 15 minut – 15g Centennial
  • 5 minut – 15g Centennial
  • 0 minut – 25g Centennial
  • dry hopping – 30g Centennial

Po schłodzeniu i filtracji wyszło 19,5 litra o BLG 15. Dodałem 1,5l wody.

Fermentacja (drożdże S-04):

  • 8 dni burzliwej
  • 12 dni cichej

Do refermentacji użyłem 140g cukru i 860g wody.

by ruanda at February 02, 2014 09:54 PM

Girl, lost in IT

10000* lat

Parę (naście) dni temu skończyłam 32 lata. Ta magiczna liczba nie doskwiera mi za bardzo i nie ona jest bezpośrednią przyczyną powstania tego tekstu. Do rozmyślań skłoniły mnie życzenia, które składano mi z tej okazji. Kilkoro (młodszych) znajomych, niezależnie od siebie, obdarowało mnie życzeniami brzmiącymi mniej więcej tak: „Wszystkiego najlepszego. Żebyś miała wspaniały rok. I […]

by ynka at February 02, 2014 06:17 PM

January 27, 2014

Hromada Mateusz

Warka 2 – American Pale Ale

Zasyp:

  • pilzneński 2,5kg
  • monachijski 1,3kg
  • karmelowy jasny 0,2kg

Zacieranie w 12l wody, słód dodany w 55°C:

  • 55°C – 10 minut przerwy
  • 69°C – 60 minut przerwy (z podgrzaniem w 40 minucie)

Po filtracji i wysładzaniu BLG 10.

Chmielenie:

  • 60 minut – 15g Simcoe
  • 15 minut – 15g Simcoe
  • 5 minut – 15g Simcoe
  • 0 minut – 25g Simcoe
  • dry hopping – 30g Simcoe

Po schłodzeniu i filtracji wyszło 16,5 litra o BLG 13.

Fermentacja (drożdże US-05):

  • 8 dni burzliwej
  • 10 dni cichej

Do refermentacji użyłem 110g cukru i 740g wody.

ABV: ok. 5%

by ruanda at January 27, 2014 06:25 PM

January 26, 2014

Hromada Mateusz

Warka 1 – American India Pale Ale

Pierwszą warkę uwarzyłem z przygotowanego zestawu surowców.

Zasyp:

  • pale ale 5,5kg
  • Cara Gold 0,5kg
  • pszeniczny 0,2kg

Zacieranie w 18l wody, słód dodany w 55°C:

  • 55°C – 10 minut
  • 69°C – 60 minut (bez podgrzewania, końcowa 62°C)
  • 76°C – mashout

Po filtracji i wysładzaniu wyszło 23 litry brzeczki o BLG 15.

Chmielenie:

  • 60 minut – 25g Warrior
  • 20 minut – 20g Simcoe
  • 10 minut – 10g Amarillo
  • 5 minut – 10g Amarillo
  • dry hopping – 30g Amarillo

Po schłodzeniu i filtracji wyszło 20,5 litra o BLG 17.

Fermentacja (drożdże US-05):

  • 10 dni burzliwej
  • 11 dni fermentacji cichej

Do refermentacji użyłem 135g cukru i 660g wody.

ABV: ok. 7%.

by ruanda at January 26, 2014 07:03 PM

December 15, 2013

Girl, lost in IT

O zmianie (pracy)

Kilka dni temu kolega z poprzedniej pracy spytał, czy przeniosłam blog w nowe miejsce – nie napisałam prawie nic od czasu, gdy zmieniłam pracę. Babcia przy każdym spotkaniu pyta, czy „korporacja” zdążyła już przeżuć mnie i wypluć. Odpowiem krótko: nie i nie! To prawda, że w ciągu ostatnich kilku miesięcy nie napisałam zbyt wiele. Miało […]

by ynka at December 15, 2013 07:46 PM

September 08, 2013

Krzysztof Szarzyński

Warszawa 2013 – Quati w stolicy.

Zanim zaproszę na ostatnią odsłonę zdjęć z mojego krótkiego pobytu w Warszawie, chwila luźnych wywodów. Nocowałem w hotelu przy placu Konstytucji, który oferował dwa rodzaje pokoi: ciche i z widokiem na miasto. Mi się trafiło oglądanie miasta, ale ponieważ ze mną na szkolenie przyjechało kilka innych osób z Poznania, to zdecydowaliśmy się z Adamem iść […]

by Quati at September 08, 2013 06:19 PM

September 04, 2013

Krzysztof Szarzyński

Warszawa 2013 – część druga

Dziś druga porcja obrazków z Warszawy. Hasłem przewodnim miało być “ludzie w Warszawie”, ale chyba troszkę bardziej pasuje “życie w Warszawie”. Chyba nigdy nie byłem dobry w nadawaniu tytułów i nazw. 🙂 Część trzecia zostanie opatrzona moimi przemyśleniami i komentarzem co do samego miasta. Zdjęcia również będą bardziej dotyczyć tego co widziałem i przeżyłem 🙂

by Quati at September 04, 2013 05:27 PM

September 01, 2013

Krzysztof Szarzyński

Warszawa 2013 – część pierwsza

W tym roku wakacje były podzielone na dwie cześći. Najpierw pojechaliśmy z Olą do Zwierzyńca, gdzie odpoczywaliśmy aktywnie zwiedzając Zamojszczyznę i korzystając z dobrodziejstwa krętych rzek i kajaków turystycznych. Ciągle czekam na chwilę weny żeby wybrać kilka zdjęć i je opublikować 🙂  Drugim etapem moich wakacji było… skończenie życia jako student i rozpoczęcie “dorosłości” w […]

by Quati at September 01, 2013 08:07 PM

Girl, lost in IT

Cicho sza!

Wcale nie zarzuciłam pisania tego bloga. Krótko o tym, co ostatnio dzieje się u mnie: Kupiliśmy dom. Trwa remont. Kompletnie nie doszacowałam nakładów czasowych (o finansowych nie będziemy tu rozmawiać) niezbędnych do realizacji takiego przedsięwzięcia. Tłumaczę książkę o C++ i Qt (Dlaczego? Patrz wyżej). Jest gruba. Zamiast tłumaczyć, spędzam godziny na rozmowach z fachowcami. Pół […]

by ynka at September 01, 2013 07:36 PM

July 13, 2013

Girl, lost in IT

Open’er, czyli wieczne poszukiwania

Heineken Open’er to co roku ta sama historia. Wiele tygodni przed festiwalem niecierpliwie zaczynam śledzić lineup i planować, co będę chciała zobaczyć. Bliżej terminu okazuje się, że z pięciu wymarzonych koncertów dwa odbywają się naraz, a trzy inne jeden po drugim – na scenach oddalonych od siebie o kilometr. Planuję także, z kim pojadę i […]

by ynka at July 13, 2013 08:00 AM

June 26, 2013

Krzysztof Szarzyński

Nowe zabawki i noc kupały

Obiecanki – cacanki. Czyli tradycyjnie, jak Quati mówi, że coś napisze, to znaczy, że mówi. 🙂 Dziś mam kilka zdjęć zrobionych za pomocą nowej zabawki, która oprócz tego, że jest świetnym gadżetem, to spełnia też czasami funkcję obiektywu. Otóż moim nabytkiem jest Sigma 50 mm F1.4 DG EX HSM, czyli typowa portretowa “stałka” z dość jasnym […]

by Quati at June 26, 2013 09:43 PM

May 30, 2013

Girl, lost in IT

Feminiści kontra statystyka

Uczestniczyłam ostatnio w konferencji, w której programie znalazł się panel dyskusyjny poświęcony mniejszościom w środowisku informatyków. Podczas panelu miałam okazję porozmawiać z inspirującymi i pełnymi dobrej woli ludźmi, jednak doszło tam również do pewnego zderzenia opinii, które wspominam do tej pory. Był sobie facet. Doświadczony lider, blogger, walczący o zwiększenie liczby kobiet w IT. Osoba, […]

by ynka at May 30, 2013 04:54 PM

April 20, 2013

Girl, lost in IT

Kup swojemu dziecku sobie robota Lego Mindstorms

Pierwszy raz klocki Lego widziałam, będąc małym dzieckiem, nie pamiętam nawet, czy było to Peweksie, „u prywaciarza”, czy może u kolegi, którego tata był kapitanem na statku handlowym, przez co w ich domu zawsze można było trafić na skarby niedostępne w normalnych sklepach (począwszy od mandarynek). Pamiętam, że zachwyciły mnie czyste kolory, przemyślane projekty oraz możliwości, jakie […]

by ynka at April 20, 2013 04:05 PM

March 16, 2013

Girl, lost in IT

Na słodko-gorzko o skutkach asertywności

Minęło już półtora miesiąca od kiedy zmieniłam pracę. Czas… biegnie szybko. Decyzja ciągle wydaje się dobra. Uczę się bardzo dużo. W trakcie ostatnich tygodni dwa razy odwiedziłam Warszawę, po raz pierwszy spróbowałam koreańskiej kuchni (z wyjątkiem zupy kimchi w Art Sushi, którą polecam, ale tylko ludziom o żołądkach ze stali), a także zapisałam się na […]

by ynka at March 16, 2013 12:37 PM

February 24, 2012

Dopierała Andrzej

2011-05-27 Darmowe fotoradary dla nissan connect

Może kogoś zainteresuje - nie znalazłem nigdzie opisu jak to łatwo zrobić “za friko”.

1. Ściągamy listę fotoradarów z http://ump.waw.pl/ plik z mapą fotoradarów (http://ump.waw.pl/update/Jacek.zip).
2. Rozkompresowujemy go
3. Łączymy to co nas interesuje do jednego pliku csv:

undefine@uml:~/tmp$ cat Kontrole\ Drogowe/*.csv Niebezpieczne\ Miejsca/*.csv Przejazdy\ Kolejowe/*.csv >x.csv
undefine@uml:~/tmp$ 

4. Usuwamy polskie znaczki (zapewne można jakoś przekodować, ale nie chciało mi się metodą prób i błędów szukać kodowania):

iconv -f cp1250 -t ascii//TRANSLIT  < x.csv > jacek.csv

5. Plik jacek.csv umieszczamy w katalogu myPOIs/myPOIWarnings na pendrive
6. Pendrive wkładamy do nissan connect i ładujemy POI użytkownika z menu(Setup → Navigation → Download my POIs)
7. Przestrzegamy ograniczeń ;)

February 24, 2012 08:24 AM

December 23, 2011

Dopierała Andrzej

2011-12-23 Ankieta Polskiego Badania Czytelnictwa: Przyszła do mnie prośba o wypełnienie ankiety. Z Polskiego Badania Czytelnictwa, sp. z o.o. Niby nic dziwnego, ale.. przyszła "smailem". A sama ankieta, po podaniu "pinu" z listu do wypełnienia na stronie http://www.ankieta.pbc.pl/ W zamian za wypełnienie ankiety oferują m.in. kupony sodexo na kwotę 20zł. I w sumie... Podszedłem do tematu trochę z mieszanymi uczuciami. Jak? Skąd? Po co? Z tego co znalazłem dane osobowe otrzymali z bazy PESEL na podstawie Dz.U. 2006 nr 139 poz. 993, 44h ust 2 par 2. List - był zaadresowany do mnie (imię, nazwisko, adres). Natomiast w samej ankiecie na stronie zwrot był przez "Pani". Pomyłka? Koniec końców zmarnowałem kwadrans i wypełniłem. Co prawda niezbyt wartościowo, bo z proponowanych czasopism to tylko sporadycznie Metro przeglądam jak akurat mi w korku wcisną, natomiast Fantastyki w ankiecie nie było, ale - jak to badanie statystyczne, to.. czemu nie.

Przyszła do mnie prośba o wypełnienie ankiety.
Z Polskiego Badania Czytelnictwa, sp. z o.o.

Niby nic dziwnego, ale.. przyszła “smailem”. A sama ankieta, po podaniu “pinu” z listu do wypełnienia na stronie http://www.ankieta.pbc.pl/

W zamian za wypełnienie ankiety oferują m.in. kupony sodexo na kwotę 20zł.

I w sumie… Podszedłem do tematu trochę z mieszanymi uczuciami. Jak? Skąd? Po co? Z tego co znalazłem dane osobowe otrzymali z bazy PESEL na podstawie Dz.U. 2006 nr 139 poz. 993, 44h ust 2 par 2.

List - był zaadresowany do mnie (imię, nazwisko, adres). Natomiast w samej ankiecie na stronie zwrot był przez “Pani”. Pomyłka?

Koniec końców zmarnowałem kwadrans i wypełniłem. Co prawda niezbyt wartościowo, bo z proponowanych czasopism to tylko sporadycznie Metro przeglądam jak akurat mi w korku wcisną, natomiast Fantastyki w ankiecie nie było, ale - jak to badanie statystyczne, to.. czemu nie.

December 23, 2011 09:04 PM

November 07, 2011

Dopierała Andrzej

2011-11-07 brother mfc5490CN: drukarka brother mfc 5490cn pod linuksem i.. ipv6.

Stara drukareczka HP 6540 się popsuła (uchwyt od czarnego tuszu przestał kontaktować), naprawa oczywiście nieopłacalna, a mi by się w domu przydał skaner, wiec… Nabyłem nową drukareczkę. Po przejrzeniu dostępnych opcji wybór padł na Brother MFC 5490CN
I - jak na razie nie mam co narzekać.
Drukowanie spod linuksa - ruszyło praktycznie od razu.
Skanowanie spod linuksa - również. Mimo iż po raz pierwszy w życiu konfigurowałem skaner pod linuksem.

A na dokładkę - drukarka działa również po ipv6…

Local> show ip v6

IPv6 is Enabled
IPv6 Static Address is Enabled
IPv6 Addresses are 2A02:848:A::XXXX:XXXX:XXXX:XXXX/64 (via Router)
                   FE80::XXXX:XXXX:XXXX:XXXX/64 (link-local)

The priority IP version of name resolving is IPv4

Będę musiał chyba firewalla wyklikać dla ipv6 :/

November 07, 2011 10:56 PM

September 09, 2011

Ogrodowczyk Wojciech

Koniec tej zabawy

Jak co bystrzejsi czytelnicy mogli zauważyć, nie pisuję już tu praktycznie nic, a zdjęcia tu umieszczane to jedynie opóźnione „przedruki” względem mojego konta na flickr. Kierując się więc brzytwą Okhama i zwykłym lenistwem...

September 09, 2011 08:12 AM

August 22, 2011

Dopierała Andrzej

2011-08-22 Lekko przerobiony multi router looking glass w php: Skrypt do przedstawiania na routerach.

Już kilka osób się mnie pytało jak zrobiłem http://lg.maverick.com.pl/.

Bazuję na lekko zmodyfikowanej wersji MRLG (Multi Router Looking Glass for PHP). Obecnie jego strona niestety nie działa - i oryginału nie mam do pobrania.

Moją zmodyfikowaną wersję umieściłem na mrlg-20091215.tgz, natomiast plik konfiguracyjny do niej na mrlg-config.php. Na pytania nie odpowiadam, w konfiguracji nie pomagam (bo nie mam czasu) - ale może komuś się przyda :).
Licencja - zgodnie z licencja oryginału - GPL.

Ale jak masz jakieś poprawki - podsyłaj :)

Wiem że brzydko zrobione, ale - było potrzebne na szybko i w parę godzin tylko na tyle mnie było stać.

Jak dodasz w swojej sieci kopię - zgłoś na traceroute.org - widoczność swojego miejsca w sieci się często przydaje :).

August 22, 2011 07:55 PM

August 21, 2011

Ogrodowczyk Wojciech

August 11, 2011

Ogrodowczyk Wojciech

August 05, 2011

Dopierała Andrzej

2011-08-05 Problematyczne ipv6 - dziwny resolver: problem z domenami z dodanym rekordem AAAA.

undefine@uml:~$ host aramin.net
aramin.net has address 42.1.94.0
;; Warning: Message parser reports malformed message packet.
;; connection timed out; no servers could be reached

i tak dla sporej części, o ile nie wszystkich adresów z dualstackiem - taki dziwny feature AP DSL-G604T w hotelu.

Do tej pory myślałem że dodanie rekordu AAAA nic nie psuje, teraz - sam się przekonałem że nie jest tak różowo, jak sie okazało że nie mogę się dostać na strony/serwery z dodanym AAAA. Na szczęście - można skorzystać z własnych albo googlowych dnsów.

Oczywiście prawidłowa odpowiedź to

undefine@uml:~$ host aramin.net
aramin.net has address 195.110.48.48
aramin.net has IPv6 address 2a01:5e00:2:52::30
aramin.net mail is handled by 0 mx.aramin.net.

August 05, 2011 04:55 PM

July 29, 2011

Ogrodowczyk Wojciech

July 27, 2011

Ogrodowczyk Wojciech

July 21, 2011

Ogrodowczyk Wojciech

July 14, 2011

Ogrodowczyk Wojciech

June 26, 2011

Dopierała Andrzej

2011-06-26 IPv6 na stronie: ipv6 na stronie

Co prawda po IPv6 day, ale.. wreszcie dołożyłem AAAA do mojej strony(i stron firmowych). Ciekawe co wybuchnie ;)

June 26, 2011 07:24 PM

June 17, 2011

Ogrodowczyk Wojciech

May 31, 2011

Ogrodowczyk Wojciech

Planet shot

Bcn planet shot

Eksperymentale ujęcie wychodka na szczycie świata, krok po...

May 31, 2011 11:44 AM

May 29, 2011

Ogrodowczyk Wojciech

March 12, 2011

Dopierała Andrzej

2011-03-12 IPv6-garsc-statystyk: kilka słów podsumowania o ruchu ipv6

Kilka statystyk z pewnego routerka. Zbierane ip6tables, w dłuższym okresie czasu. Wykresów nie daję, bo za mała próbka by ładnie wyglądało ;)

Dane z pewnej sieci osiedlowej w Poznaniu. IPv6 udostępnione klientom przez radvd. Głównie klienci “prywatni”.

Wejście:
2% - 6to4
pomijalne - PIX
24% - PLIX
3% - natywne IPv6 od Crowleya
69% - tunel z HE

Wyjście:
51% - 6to4(!)
6% - PIX
36% - PLIX
1% - Crowley
6% - tunel z HE.

Wnioski:
- podobnie jak w przypadku ipv4 duża część ruchu przypada na PLIX
- upload to głównie ruch kierowany do 6to4 - jak sądzę ruch p2p.
- bardzo duży download na tunelu z HE. Co prawda miałem trochę wątpliwości czy należy się w to bawić - to jednak obserwując ruch przy włączonym i przy wyłączonym tunelu widać że opóźnienia przez HE są często niższe. Pozatym - alternatywa to pchanie ruchu przez Crowleya, który.. również sporą część ruchu ma przez HE. HAWE jak na razie ipv6 nie dostarcza.

March 12, 2011 11:49 PM

February 22, 2011

Dopierała Andrzej

2011-02-22 IPv6 a 6to4: ipv6 6to4 sit0 routing ruch siec

Powolutku bawię się w wdrożenie IPv6 u pewnego ISP.

Na peeringach (w PIX i PLIX) ipv6 śmiga “natywnie”. Świata niestety jak na razie nikt nie dostarczył, więc leci tunelem z HE.

Do tego rozgłoszenie prefiksów do kilku testowych sieci - i troszkę ruchu widać.

W którymś momencie zauważyłem, że trochę ruchu leci do 6to4. Postawiłem więc bezpośredniego relaya(opis z http://wiki.debian.org/DebianIPv6) i…

mav-ipv6

Wniosek? Wbrew pozorom bardzo dużo (tak na oko 1/3) ruchu to ruch z relayami 6to4. Stąd zapewnienie dobrej komunikacji z nimi powinno być dosyć istotne przy udostępnianiu ipv6. Do testowego ip z którym obserwowałem ruch po ustawieniu bezpośredniego tunelowania 6to4 na moim routerze opóźnienia spadły z ok 80 do 50ms - a ruch wzrósł o kilkanaście procent.

(na wykresie jest widoczny wyłącznie ruch na tunelach - peeringi/polska leci natywnie, stąd nie mam prostej możliwości wyróżnienia go od ipv4)

February 22, 2011 11:06 PM

February 17, 2011

Dopierała Andrzej

2011-02-17 Rozkład ruchu na łączach: rozkład ruchu plix hawe tp pix

Taka mała ciekawostka.

Jest sobie mały operator. Świadczący głównie usługę dostępu do internetu dla “ludzi”. Pakiety - dosyć duże, po kilka/kilkadziesiąt megabitów, upload ciut mniejszy - po 2-3 megabity.
Ogólnie - zazwyczaj mało kto dociera do limitu w którąkolwiek ze stron.

Do tego jest troszkę hostingu i łącz biznesowych… Ale większośc to klienci indywidualni.

Łącza:
- peering w PIX-ie (http://www.pix.net.pl)
- peering w PLIX-ie (http://www.plix.pl)
- PBT HAWE (http://www.pbthawe.eu)
- Transmisję CDP Global od crowleya (http://www.crowley.pl)

i w którymś momencie na parę chwil pojawiła się testowa transmisja do TPSA - normalnie leci przez HAWE (i dalej styk z crowleyem).

Ruch - puszczony przez bgp prawie “samopas”. Lekkie preferencje by sterować ruchem na łączach zagranicznych (hawe/cdp), gdzieniegdzie unikanie problematycznych ścieżek - ale - można powiedzieć że rozkład jest prawie naturalny.

I teraz - procentowy wykres ruchu:
rozklad-lacz

Interesuje nas głównie download - uploadu jest niewiele - ok połowy downloadu, więc zazwyczaj mieści się w ramach kontraktu.

Co jest ciekawe… ok 30% ruchu zamyka się w plixie. Nawet trochę więcej.

PIX - jest malutki. poniżej 3% ruchu. Gdyby nie skala oraz fakt że jest prawie za darmo - nie było by go sensu trzymać.

HAWE i crowley - utrzymują się mniej więcej na zbliżonym poziomie - przerzucanie to głównie zmiany na ich upstreamach oraz “rzucanie” nimi (prepend przez community) by przerzucić na łącze gdzie dalej od kontraktu.

Przez jakiś czas była testowana tpsa. I tutaj niespodzianka - download był ledwo w okolicach 5% sumarycznego ruchu. Czyli - biorąc pod uwagę cenę - malutko. Z koleji upload to ok 20% ruchu - co w tej sytuacji oznaczało że było to jedyne łącze gdzie upload przekraczał download! I przypominam że to nie hosting, tylko głównie klienci indywidualni. Cóż - P2P rządzi.

February 17, 2011 11:59 AM

January 06, 2011

Dopierała Andrzej

2011-01-06 Konto w aliorbank: zakładanie konta w aliorbanku cz.1

Stwierdziłem że w mojej małej firemce przyda się kolejne konto. Obecne mam w mBanku, bo.. wiadomo - za darmo. No - prawie. 1zł za każdy przelew “na zewnątrz” - to już trochę w miesiącu wychodzi.

A Aliorbank ciągle kusi darmowym kontem, 5-cioma darmowymi przelewami w miesiącu i “premią” 50zł przy stanie konta 9k. Czyli więcej niż na lokacie w mbanku.

Z nowym rokiem - próbuję więc założyć konto.
Pierwsze wrażenia po przebrnięciu przez formularz?

  • Nie pozwala mi na wpisywanie polskich znaczków. Przeglądarka chrome. Po wklejeniu tekstu z polskimi znaczkami - ogonki znikają.
  • Do wybrania klasyfikacja usług… Ja w GUS-ie mam zgłoszoną 6202Z(działalność związana z doradztwem w zakresie informatyki - wg klasyfikacji z 2007 roku). A na stronie pozwalają na wybór pomiędzy.. 6201 a 6203.

Ale przebrnąłem - polskie znaczki jak sądzę poprawią mi w oddziale. O efektach pewnie poinformuję…

January 06, 2011 08:40 PM

October 16, 2010

Nawrot Andrzej

Rozmowy ze specjalistą ds. wdrożeń

Taki kwiatek.
Pytanie dotyczące odpowiedzialności za wykonywanie backupów pewnego systemu i odpowiedź konsultanta.

IT: Kto wykonuje backupy?

Specjalista:Backupy wykonuje MS SQL z automatu codziennie, raz na okres np. miesiąc kwartał baza powinna być nagrywana na trwały nośnik i to w zależności od firmy albo my albo dział IT
Danych nie powinniśmy stracić żadnych tylko w przypadku kataklizmu kiedy to stracimy serwer oraz kopie dyskowe – pozostaną nam tylko kopie na trwałych nośnikach, ale to sytuacje bardzo sporadyczna
Kopie na serwerze służą przede wszystkim do ewentualnych porównań w przypadku uszkodzenia – stąd codzienne kopie .

by jendras (noreply@blogger.com) at October 16, 2010 08:34 PM

June 08, 2010

Nawrot Andrzej

PowerShell via GPO

Aby zmienić ustawienia wykonywania skryptów potrzebujemy tego template'a.

http://www.microsoft.com/downloads/details.aspx?familyid=2917a564-dbbc-4da7-82c8-fe08b3ef4e6d&displaylang=en

by jendras (noreply@blogger.com) at June 08, 2010 08:29 AM

March 04, 2010

Nawrot Andrzej

Limit połączeń RDP

Ku pamięci

query session /server:servername


reset session [ID] /server:servername

by jendras (noreply@blogger.com) at March 04, 2010 02:17 PM

October 28, 2009

Nawrot Andrzej

Rodzinka w komplecie

 

Rodzinka w komplecie, brakuje tylko zniewiescialego SL :)
Posted by Picasa

by jendras (noreply@blogger.com) at October 28, 2009 10:08 PM

October 07, 2009

Najtkowski Marcin Jan

Dua Tonight

W trakcie nieustających muzycznych wojaży trafiłem znów na kawałek, którego słucham po kilkanaście-kilkadziesiąt razy dziennie. Kobiecy wokal – oczywiście, fajny, “chwytliwy” rytm oraz ogólna “sympatyczość” sprawiły, że Tonight zespołu Dua stał się moim numerem jeden ostatniego tygodnia.

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="265" width="320"><param name="allowFullScreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="src" value="http://www.youtube-nocookie.com/v/YIfJvPm9-rg&amp;hl=pl&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999"/><param name="allowfullscreen" value="true"/><embed allowfullscreen="true" allowscriptaccess="always" height="265" src="http://www.youtube-nocookie.com/v/YIfJvPm9-rg&amp;hl=pl&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" width="320"></embed></object>

Utwór można znaleźć na A Lounge Supreme vol. 5.

by naytec at October 07, 2009 11:40 AM