Blog posts, page 2

Batch cherry-picking with git

git

Today I came to work and found that I have to move 18 commits from my development git branch to the old release. I’ve worked on one feature for several weeks, and kept my branch up to date with master, so the history looked like this:

               Z -- Y -- X -- W -- V -- U -- T -- S            feature
              /         /              /
-- A -- B -- C -- D -- E ----- F ---- G -- H                   master
    \
     R -- Q                                                    release

So, my goal is to create a feature' branch on top of the release and copy the commits Z, Y, W, V, T and S there:

Continue reading

Draft posts with Hakyll

Hakyll, Haskell

If you’d like to write a long posts in your Hakyll blog, you often can find that you’d like to commit a post (or several posts), but you’re are not going to deploy it on server. Here is my solution inspired by this post. Now I can call Hakyll with --with-drafts and it will use both posts and drafts directories to collect posts data.

There are several issues I had faced with when I was solving this problem:

  1. Detect what program is running in the draft mode.
  2. Pass posts to Hakyll.
  3. It is safer to have a separate folder for generated site while running in the draft mode to avoid the draft articles deploying by mistake.
  4. Hakyll itself uses cmdargs package which checks if the command is executed with proper options.
Continue reading

Fixing nvidia-drivers-340.76 build with kernel 4.0

Gentoo, NVidia

After upgrade to gentoo-sources-4.0.5 I’ve found what I cannot install drivers for my good old GTS-250. This card is pretty old, so it supports only in 340.x branch of NVidia drivers. Unfortunately NVidia is not really fast in fixing of such kind of problems (https://devtalk.nvidia.com/default/topic/827836/-bug-nvidia-340-76-build-on-linux-64-fails-after-upgrade-of-kernel-v3-19-4-gt-v4-0-0/). They just provide a link to the patch in Ubuntu. But, AFAIK Gentoo maintainers doesn’t take such patches as well (I suppose it is break older kernels compatibility).

The cool thing I’ve never used before called epatch_user allows you to add custom patches to any ebuild supporting this feature. And actually this is the way, proposed to solve such issues. So, all you need to do is to create folder /etc/portage/patches/x11-drivers/nvidia-drivers-340.76 and place there following patch:

--- kernel/nv-pat.c.orig    2015-08-17 21:46:15.541979210 +0300
+++ kernel/nv-pat.c 2015-08-17 21:47:17.180978210 +0300
@@ -35,8 +35,8 @@
     unsigned long cr0 = read_cr0();
     write_cr0(((cr0 & (0xdfffffff)) | 0x40000000));
     wbinvd();
-    *cr4 = read_cr4();
-    if (*cr4 & 0x80) write_cr4(*cr4 & ~0x80);
+    *cr4 = __read_cr4();
+    if (*cr4 & 0x80) __write_cr4(*cr4 & ~0x80);
     __flush_tlb();
 }
 
@@ -46,7 +46,7 @@
     wbinvd();
     __flush_tlb();
     write_cr0((cr0 & 0x9fffffff));
-    if (cr4 & 0x80) write_cr4(cr4);
+    if (cr4 & 0x80) __write_cr4(cr4);
 }
 
 static int nv_determine_pat_mode(void)

Putting posts content on the index page

Hakyll, Haskell

Once you have created a Hakyll based site the first page contains only the titles of your posts. It can be acceptable if your first page contains another content, but if there are only the latest posts it looks weird. Let’s check how does it works.

Default index page template includes post-list.html template which contains following code:

<ul>
  $for(posts)$
    <li>
      <a href="$url$">$title$</a> - $date$
    </li>
  $endfor$
</ul>
Continue reading

Installing Hakyll on Gentoo Linux

Hakyll, Gentoo

I have been using Gentoo Linux as my primary OS since 2004. So, it usually important for me to choose software which available in Gentoo portage. And there is no Hakyll in portage :(

Of course, it is possible to install Hakyll from cabal using cabal-install, but according to the wiki this is not recommended. Instead of this, we can install this package fro the Gentoo Haskell overlay. So, first of all it required to add this overlay using layman (of course if you didn’t do it before).

$ emerge layman
$ layman -a haskell
$ echo "/var/lib/layman/make.conf" >> /etc/portage/make.conf
Continue reading

Why Hakyll?

Hakyll

Well, I thought about personal blog for a quite long time, but to be honest I’m really lazy. And the second thing, I don’t like most of CMS I’ve ever seen. So, the idea of static generation is looking much more suitable for this kind of stuff. But I never tried it before (to be honest I’ve never heard about it, except 1C Bitrix. At least I thought it generates a lot of static pages, but it still requires PHP).

Finally, I found out that there several solutions for site generation (thanks Vitaly Repin), like (Jekyll, Hakyll, Middleman). The interesting thing, is that if you try to google something like “Jekyll vs Hakyll”, there will be several posts about migration from Jekyll to Hakyll. Of course, it doesn’t mean that Hakyll is better, but it seems like it is more flexible.

Another reason why I’ve chosen Hakyll is Haskell. Haskell was a language which bring me to the functional programming world. It was like a magic for me (and it steel so, since I’ve never participated a real projects in Haskell). It feels like you just have written your first program, and it’s working (of course if you was able to compile it :)).

So, the first impression is “I like it”. Even thought, it’s not strictly required to know Haskell, and all of this stuff (like Monads and Monoids), this knowledge gives you some advantages, and it gives me a hope that I’ll be able to make this blog much better that it is now :)

My first blog post

Hakyll

This is my first post in this blog, just to be sure that Hakyll is working.

Checking a syntax coloring for Haskell:

-- factorial
fac n = foldr (*) 1 [1..n]

main = do
  putStrLn "Hello, World"

And for Scala:

// Hello world
object Test {
  def main(args: Array[String]) = {
    println("Hello, World!")
  }
}

And that’s all falks!

Recent posts

Tag cloud

Akka BeanPurée DSL Gentoo Hakyll Haskell Java NVidia Scala Spray XMonad collections git shapeless