Tagged hacks

Here's a quick post showing how I solved an issue with an unreliable LTE backup connection. Depending on your hardware, firmware & UI version YMMV.

The problem

It appears that Huawei E3372 frequently disconnects from the LTE network for no apparent reason. It wouldn't be much of a problem if it managed to quickly and reliably reconnect, but that isn't the case it would seem. Whenever that happens packets get lost and websites don't load properly, and overall internet experience is well below acceptable. After some googling it turned out that it might be caused by E3372 automatically disconnecting from the network, but fortunately enough, automatic disconnects when idling seem to be a configurable feature [sic] in the HiLink version of the modem. Less fortunately though, the default interval is set to 5 minutes, and obviously needs to be changed, potentially even disabled altogether. Let's see what the WebUI has to offer in this regard:

Y u no cooperate

Oh...

(ノ `⌒´)ノ︵ ┻━┻

Continue reading

Cranking out another post took me way longer than I had anticipated when I rebooted this blog, but I got sidetracked by another quick hardware project that turned out to be way more involved and equally more fun than I originally thought...

multicart

I've designed an Atari 400/800/XL/XE standard cartridge compatible board that can hold up to 127 different standard 8KB and 16KB game ROMs at the same time. It's memory chip agnostic and features software game selection & a few neat hacks.

Continue reading

With Google Reader being discontinued and everyone looking for alternatives I've decided to look for a little less "standard" solution, and hey, it turns out Emacs can be a pretty powerful RSS reader.

Newsticker.el

News Ticker is a built-in Emacs feed reader that doesn't get much attention for some reason. It is feature-rich, handles both RSS 2.0 and Atom feeds and has quite a bunch of tweakable options. Here's a simple setup to start with:

(require 'newsticker)

; W3M HTML renderer isn't essential, but it's pretty useful.
(require 'w3m)
(setq newsticker-html-renderer 'w3m-region)

; We want our feeds pulled every 10 minutes.
(setq newsticker-retrieval-interval 600)

; Setup the feeds. We'll have a look at these in just a second.
(setq newsticker-url-list-defaults nil)
(setq newsticker-url-list '("..."))

; Optionally bind a shortcut for your new RSS reader.
(global-set-key (kbd "C-c r") 'newsticker-treeview)

; Don't forget to start it!
(newsticker-start)

Continue reading

Resistance is futile...

As we all know Emacs is a great operating system and a decent editor, and as such it has been serving me really well - I find myself assimilating more and more of my tools and daily activities into the Emacs collective. Recently I realised that Conky just wouldn't cut it anymore...

First of all, I barely look at my desktop. There's just no reason to do that other than checking some of the system stats such as memory usage or CPU load when I'm hacking arround and testing stuff.

For this particular use-case I figured the Emacs mode-line would be perfect to display all the relevant statistics directly in Emacs in such a way that I could glance through them without interrupting my workflow - giving me real-time feedback with minimal distraction.

Continue reading

One of the most distinctive features of Common Lisp and Lisp in general, are its code-generation and code-manipulation capabilities.

Probably the best example is the LOOP macro - a Swiss Army knife of iteration that can do pretty much anything. The following snippet iterates a list of random numbers collecting some statistics of its contents and does that while being very concise and readable:

(let ((random (loop with max = 500
                    for i from 0 to max
                    collect (random max))))
  (loop for i in random
          counting (evenp i) into evens
          counting (oddp i) into odds
          summing i into total
          maximizing i into max
          minimizing i into min
        finally (format t "Stats: ~A"
                          (list min max total evens odds))))
Stats: (0 499 120808 261 240)

Continue reading

So, I finally found some time for a Template Metaranting follow-up post. This time let's get down to business as this one contains a fair amount of code.

Sadly, I won't rant as much but instead I'll try to show how awesome D's templates really are. We'll write a piece of code, based on this Scheme implementation, that is, a simple monad) that we'll use to build a binary tree, with uniquely numbered nodes containing their height, without any global state (therefore purely) entirely at compile time.

Quick Reader, grab my code!

ADVENTURE!

Continue reading

There's an increasing interest with the D programming language amongst my readers so I figured I'll post a bunch of short posts about D and see what happens.

Anyway, here's a classic example showing Ruby's capabilities taken from Seven Languages in Seven Weeks:

class Roman
  def self.method_missing name, *args
    roman = name.to_s
    roman.gsub!("IV", "IIII")
    roman.gsub!("IX", "VIIII")
    roman.gsub!("XL", "XXXX")
    roman.gsub!("XC", "LXXXX")

    (roman.count("I") +
     roman.count("V") * 5 +
     roman.count("X") * 10 +
     roman.count("L") * 50 +
     roman.count("C") * 100)
  end
end

puts Roman.X
puts Roman.XC
puts Roman.XII

Continue reading

Here's a cool hack I use to optimize my docs searching.

Let's start off with DuckDuckGo search engine. By itself it's a pretty powerful tool thanks to its numerous features like the !bang syntax. For example searching for:

!cpp std::string::clear

...takes me exactly where I want.

Let's use it to our advantage, shall we?

StumpWM is a tailing window manager that allows you to define system-wide key bindings that work and feel pretty much like Emacs ones. Combining that with DuckDuckGo'es !bang syntax makes you just a few clicks away from anything out there:

(defcommand duckduckgo (phrase) ((:string "Search: "))
  "Searches for something on DuckDuckGo."
  (run-shell-command
    (concatenate 'string
                 *your-fav-webbrowser*
                 " http://duckduckgo.com/?q="
                 (substitute #\+ #\Space phrase))))
(define-key *root-map* (kbd "d") "duckduckgo")

Now, if you want to find out if I used substitute correctly all you have to do is:

C-t d !lisp substitute

...what will take you directly there. Turns out I did.

But wait, there's more!

Continue reading

Just to evangelize D a little and increase my code/crap ratio, let's pretend we develop a library in C++ that contains this class:

class SomeMetaVariables {
    public:
    std::string foo;
    bool bar;
};

// ... Somewhere in the client code:
SomeMetaVariables baz;
baz.foo = "foo";
baz.bar = true;

Our library is quite successful and many people are using SomeMetaVariables despite its obvious flaws. Now, say we get many requests for additional functionality, for example: "Make bar true only when foo is set to "foo" and other way arround." "Well, ok." - we say and commit this new version of SomeMetaVariables:

class SomeMetaVariables {
    std::string foo;
    bool bar;

    public:
    std::string getFoo() {
        return foo;
    }

    std::string setFoo(std::string newFoo) {
        foo = newFoo;
        bar = (foo == "foo");
        return foo;
    }

    bool getBar() {
        return bar;
    }

    bool setBar(bool newBar) {
        bar = newBar;
        foo = bar ? "foo" : "";
        return bar;
    }
};

We implemented the requested feature, but SomeMetaVariables' interface has changed... "But why are you mad clients? You asked for it!" - cries the C++ developer.

Continue reading