lunes, 27 de mayo de 2013
yet another git reset cheatsheet
It's mostly the same as I pointed in a post 2 years ago, but just explained in a different way, shorter, and probably easier to print in a small paper and stick it in your table.
Enjoy :)
PS: There's a poll running on reddit about git clients. No matter what you're using, vote for magit :)
cool org-mode 8 features
Org 8 had lots of improvements and new features compared to 7.9.x. There were a couple of those that I wanted to try as soon as possible:
- New Exporters: org-mode now uses org-element to parse org files. That's a big big improvement because that allows users to write new exporters relying on a somewhat more abstract and high level parser api than what we had before.
- orgstruct and orgstruct++ got orgstruct-heading-prefix-regexp option to set allowed prefixes and be able to fold parts of non-org files as if they where
(require 'ox-reveal) (setq org-reveal-root "reveal.js")
Meanwhile in orgstruct... being able to define prefixes for orgstruct-mode allows us to have foldable text files. For example, use the following line to make it work in elisp files.
(setq orgstruct-heading-prefix-regexp "^;; ")
miércoles, 22 de mayo de 2013
Lua vs javascript
I haven't programmed many many things in lua, but the simplicity of it reminds me of smalltalk (in a veery different meaning of simplicity), or scheme.
The fact that it relies in very few known concepts as lexical scope, tables, and.... and that's it.
More that a language, is a language builder toolset. It lets you do metaprogramming without really feeling that you're doing metaprogramming. It makes it so simple you'd say it's "the normal thing".
- loops? ok, you have 'for', and iterators. made from closures, or whatever, but that's it.
- TCO? yes, but just if it's explicit.
- splat arrays by default? as in Perl?... yes, just in the last position, perfect for apply-like calls. or you have unpack.
- Varargs functions? yup.
Ah! and there's also metalua, which sounds like great fun. something like tcl's block syntax or lisp quasiquoting to mold lua to your needs.
sábado, 11 de mayo de 2013
Ryan Holiday TNW keynote: manipulating media
The media, and how easy it is to generate buzz on the media and get traction. That guy might be some kind of marketing ninja.
So in TNW he did a talk about some experiences he had and how he sees the fragility of the truthiness in the media, and how they change mindful investigations for easy PR that will lead to easy clicks
If you watch the talk you'll understand the mixed feelings I had when writing about it. Hopefully the content is mostly correct and he's not playing on us.
Here is the article, and the video:
domingo, 14 de abril de 2013
Embedding Lua, embedding Guile
Lately I've spent a quite few hours hacking on Lua. I love its simplicity, and the way it exposes lots of inner aspects of the programming language, that are usually hidden from the user in other programming languages.
One of the cool aspects of lua is the easiness of embedding it into your C app. But let's make it more fun. Embed Guile also inthere.
Lua
The process to embed Lua in a C app is quite easy, and simple (for really simple things), but I guess it gets more cumbersome when the complexity of the embedding system increases. Being a stack based vm makes it non-trivial to write some embedding functions (recursive functions, for example).
Guile.
The way to embed guile into an app is also, really easy. And Powerful. And you're not bound to interact with it using a stack based machine, but you just register your functions, and use the generic SCM type for all inputs and outputs. I find it easier than Lua
The Code
Here's a minimal example that does some trivial calculations and the flux of the code passes from C to guile, guile calls another C function, and after this, we call lua which also calls a function we have defined in C. In the end it's doing something like (n! + 1).
jueves, 11 de abril de 2013
Running a shell command on current file
In vim, it's pretty common to run commands like
:!gcc %
It's pretty simple and the syntax is really easy to remember, ":" for command mode, "!" to run something, and in the command "%" will be replaced by your filename.
I haven't found anything similar to "%" for emacs, so let's write some elisp to fix it.
(defun shell-execute () (interactive) (let ((file-buffer (or (buffer-file-name) "")) (command (read-shell-command "Shell command: " nil nil nil))) (shell-command (replace-regexp-in-string "%" file-buffer command)))) (global-set-key (kbd "M-!") 'shell-execute)
domingo, 7 de abril de 2013
Guile's deprecation warnings
Some deprecated features have been used. Set the environment variable GUILE_WARN_DEPRECATED to "detailed" and rerun the program to get more information. Set it to "no" to suppress this message.Nice, no? Let's set the variable and rerun.
`scm_int2num' is deprecated. Use scm_from_int instead. `scm_num2int' is deprecated. Use scm_to_int instead.These kind of things make usin guile a pleasure. Now back to embedding.
