/
index.xml
345 lines (269 loc) · 22.2 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Manuel Ohlendorf</title>
<generator uri="https://hugo.spf13.com">Hugo</generator>
<link>http://manuel-ohlendorf.de/blog/</link>
<language>en-us</language>
<author>Manuel Ohlendorf</author>
<updated>Tue, 29 Sep 2015 09:34:00 CEST</updated>
<item>
<title>The crazy date/time formatting in Go</title>
<link>http://manuel-ohlendorf.de/blog/2015/09/29/the-crazy-date/time-formatting-in-go/</link>
<pubDate>Tue, 29 Sep 2015 09:34:00 CEST</pubDate>
<author>Manuel Ohlendorf</author>
<guid>http://manuel-ohlendorf.de/blog/2015/09/29/the-crazy-date/time-formatting-in-go/</guid>
<description><p>Formatting and parsing date/time strings is a very common use-case in programming. A lot of the programming languages I worked with take the same approach for that: Using the Unicode time pattern syntax <a href="http://www.unicode.org/reports/tr35/#Date_Format_Patterns">UTS #35</a>. For me it is always hard to remember the details, especially when it comes to the upper and lower case codes. A typical format string in Java for an english date would be</p>
<pre><code> EEE, MM/dd hh:mm:ssa yyyy ZZZ
</code></pre>
<p>Fairly simple, but you have to remember that the month part is always upper case, the minute part is always lower case, 12-hour time is the lower case <code>hh</code>, <code>a</code> is the am/pm marker, etc. There a several more pattern letters if you want to get more detailed on the time format.</p>
<p>Go takes a completely new road to date/time formatting. Instead of codes it uses a standard time for describing the desired date/time format. The same date format as above written in Go is:</p>
<pre><code> Mon, 01/02 03:04:05PM 2006 -0700
</code></pre>
<p>As you can see this is a special time counting from one for the month part to six for the year part and seven for the time zone (which is MST). So there a only three things to recall: it starts with the month, the hour part is PM (15 o&rsquo;clock in 24-hour time) and the day of the week is Monday - instead of all all those abstract time pattern letters.</p>
<p>Now let&rsquo;s parse and format a simple date string from an english date format to the german date format:</p>
<pre><code class="language-Go">package main
import (
&quot;fmt&quot;
&quot;time&quot;
)
func main() {
// my birthday
value := &quot;04/19/1979&quot;
// the format of the value
parseFormat := &quot;01/02/2006&quot;
// parse the string into a time object
time, _ := time.Parse(parseFormat, value)
// the german output format
printFormat := &quot;02.01.2006&quot;
// and print it with the desired format
fmt.Println(time.Format(printFormat))
}
// =&gt; &quot;19.04.1979&quot;
</code></pre>
<p>I like this new approach of Go. Writing the standard time down the way yours looks may be strange in the first place, but it&rsquo;s easy to recall, and it also happens to match the form of your time string, syntactically.</p>
</description>
</item>
<item>
<title>Material Design Buttons with AppCompat</title>
<link>http://manuel-ohlendorf.de/blog/2015/09/03/material-design-buttons-with-appcompat/</link>
<pubDate>Thu, 03 Sep 2015 10:21:06 CEST</pubDate>
<author>Manuel Ohlendorf</author>
<guid>http://manuel-ohlendorf.de/blog/2015/09/03/material-design-buttons-with-appcompat/</guid>
<description><p>With the new release v23.0.0 of the AppCompat library it is now possible to create Material Design Buttons for Lollipop and Pre-Lollipop devices.</p>
<p>If you just want to define the color of all Buttons you can set a special theme property called <code>colorButtonNormal</code>:</p>
<pre><code class="language-XML">&lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.AppCompat.Light&quot;&gt;
&lt;item name=&quot;android:windowBackground&quot;&gt;@android:color/white&lt;/item&gt;
&lt;item name=&quot;colorPrimary&quot;&gt;@color/primary&lt;/item&gt;
&lt;item name=&quot;colorPrimaryDark&quot;&gt;@color/primary_dark&lt;/item&gt;
&lt;item name=&quot;colorAccent&quot;&gt;@color/accent&lt;/item&gt;
&lt;item name=&quot;colorButtonNormal&quot;&gt;@color/button_normal&lt;/item&gt;
&lt;/style&gt;
</code></pre>
<p>Now every Button has the color <code>@color/button_normal</code> and looks like a nice Material Design Button.
But what if you have different Button types with different colors? No problem! Just define a new style for your special button:</p>
<pre><code class="language-XML">&lt;style name=&quot;SpecialButton&quot; parent=&quot;Widget.AppCompat.Button.Colored&quot;&gt;
&lt;item name=&quot;colorButtonNormal&quot;&gt;#555&lt;/item&gt;
&lt;item name=&quot;android:textColorPrimary&quot;&gt;#fff&lt;/item&gt;
&lt;/style&gt;
</code></pre>
<p>You can use this style on a Button element like that:</p>
<pre><code class="language-XML">&lt;Button
android:theme=&quot;@style/SpecialButton&quot;
android:id=&quot;@+id/special&quot;
android:layout_width=&quot;wrap_content&quot;
android:layout_height=&quot;wrap_content&quot;
android:text=&quot;@string/special&quot; /&gt;
</code></pre>
<p>As you can see, the style is not used as a style but as a theme. This is because the attributes <code>colorButtonNormal</code> and <code>android:textColorPrimary</code> are not properties of the Button. Instead they are applied by the <em>magic</em> theme mechanism from Android. I am not entirely sure how it works but it seems to work&hellip;</p>
<p>For more information on styling and <em>not</em> on theming you should read <a href="http://blog.danlew.net/2014/11/19/styles-on-android/">Styling Views on Android (Without Going Crazy)</a>.</p>
</description>
</item>
<item>
<title>Using Hugo as the new static site generator</title>
<link>http://manuel-ohlendorf.de/blog/2015/02/17/using-hugo-as-the-new-static-site-generator/</link>
<pubDate>Tue, 17 Feb 2015 08:45:58 CET</pubDate>
<author>Manuel Ohlendorf</author>
<guid>http://manuel-ohlendorf.de/blog/2015/02/17/using-hugo-as-the-new-static-site-generator/</guid>
<description><p>Four years since my last
<a href="http://manuel-ohlendorf.de/blog/2011/03/14/l-system-parser-with-jangaroo/">blogpost</a> and a very crappy
old style of the site, I have decided completely revamp it.</p>
<p>My first thoughts were: You need a new static site generator and it has to be
written in your favourite programming language (for now, this is JavaScript).
After some googling and tinkering I came to a very different conclusion: Not the
programming language or the features of the generator are important to me, but
the available themes!</p>
<p>So more googling was necessary to come up with <a href="http://gohugo.io">Hugo</a> and the
theme <a href="https://github.com/spf13/hyde">Hyde</a> and not 10 minutes later the new
site was online - yes, it was that fast!</p>
<p><a href="http://gohugo.io">Hugo</a> has every feature you would expect from a static site
generator: sitemap generation, RSS generation, serving and life-reloading during
development and a good documentation.</p>
<p>But the most important feature for me is the very good theming mechanism that
allows you to use a theme as a git submodule in your project, without changing
any code in it. It is always possible to update the theme to the latest version
or even change it to a different one. Every style specific changes that you want
to make happen in your own templates.</p>
<p>Another property of <a href="http://gohugo.io">Hugo</a> that convinced me, is its
performance - Hugo is <em>blazing</em> fast! Generating this site takes about 25
milliseconds.</p>
<p>One thing, that bothered me was, that the Hugo&rsquo;s documentation describes a very
complicated way of hosting the blog on <a href="http://github.com">Github</a>. Therefor I
have chosen my submodule-way, again.</p>
<p><a href="http://gohugo.io">Hugo</a> generates the final site into the <code>public</code> folder. That
is where you want to init the
<a href="http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html">submodule</a>
into:</p>
<pre><code>$ git submodule add http://github.com/mohlendo/mohlendo.github.com public
</code></pre>
<p>Now every time the site is rebuild, you can commit and push the changes to the
website repository and github will automatically publish them - in my case to
<a href="http://mohlendo.github.com">http://mohlendo.github.com</a>.</p>
<p>That&rsquo;s it again - a new site generator and a new blogpost! Probably the last,
though, until I change the site generator again&hellip;</p>
</description>
</item>
<item>
<title>L-System parser with Jangaroo</title>
<link>http://manuel-ohlendorf.de/blog/2011/03/14/l-system-parser-with-jangaroo/</link>
<pubDate>Mon, 14 Mar 2011 16:44:03 UTC</pubDate>
<author>Manuel Ohlendorf</author>
<guid>http://manuel-ohlendorf.de/blog/2011/03/14/l-system-parser-with-jangaroo/</guid>
<description><p>Have you ever heard of <a href="http://www.jangaroo.net">Jangaroo</a>? It is an ActionScript&reg;-to-Javascript compiler. It's an open-source project with an implementation of the Flash&reg; API and the whole toolchain every programmer likes: Maven dependency management, good IDE support, TDD with JooUnit (a port of FlexUnit) and a lot more. It even comes with a declarative UI language EXML (well, it is quite similar to MXML), that can be used to generate <a href="http://www.sencha.com/products/extjs/">ExtJS</a> applications. For about a year I am now also helping to evolve Jangaroo and its toolchain.</p>
<p>Once upon the time when Adobe&reg; Flex was the next big thing, I was very much impressed by this cool technology. I developed an UI during a professional project with Flex 3 and was a beta tester for Adobe&reg; Flex 4 and all the tools that came with it like FlexBuilder and Thermo. Back then I wrote a little <a href="http://en.wikipedia.org/wiki/L-system">Lindenmayer system</a> parser with a Flex 4 UI: <a href="https://github.com/mohlendo/lsystem">lsystem</a>.</p>
<p>Below you see some <a href="http://en.wikipedia.org/wiki/L-system">Lindenmayer systems</a> that are generated with the Jangaroo version of the original Flash&reg; lsystem parser. It is still the same code, but the program now completely runs in the browser &ndash; without any plugin and only with HTML5. The code can be found here: <a href="https://github.com/mohlendo/lsystem-jangaroo">lsystem-jangaroo</a>.</p>
<iframe id="lsystem1" src="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=1" frameborder="0" width="640" height="480">
no frames
</iframe>
<iframe id="lsystem2" src="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=2" frameborder="0" width="640" height="480">
no frames
</iframe>
<p>All in all there are 10 Lsystem presets that can be viewed with my litte program:
<ul>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=0" target="_blank">Lsystema vulgaris</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=1" target="_blank">Tree 1</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=2" target="_blank">Tree 2</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=3" target="_blank">Tree 3</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=4" target="_blank">Koch curve</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=5" target="_blank">Quad Koch island</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=6" target="_blank">Hilber curve</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=7" target="_blank">Sierpinski Arrowhead</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=8" target="_blank">Dragon curve</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=9" target="_blank">Lévy C curve</a></li>
<li><a href="http://manuel-ohlendorf.de/jangaroo/lsystem/lsystem.html?lsystem=10" target="_blank">Penrose Tiling P3</a> Warning! This may crash your browser!</li>
</ul>
</p>
</description>
</item>
<item>
<title>Baubericht Amati Shamrock - Tag 1</title>
<link>http://manuel-ohlendorf.de/blog/2011/01/14/baubericht-amati-shamrock---tag-1/</link>
<pubDate>Fri, 14 Jan 2011 20:09:03 UTC</pubDate>
<author>Manuel Ohlendorf</author>
<guid>http://manuel-ohlendorf.de/blog/2011/01/14/baubericht-amati-shamrock---tag-1/</guid>
<description>
<p>Dies ist der erste Teil eines Bauberichts des Bausatzes
<a href="http://de.wikipedia.org/wiki/Shamrock_V">Shamrock</a> von Amati im Maßstab von
1:80. Da ich ein blutiger Anfänger bin, was Schiffsmodellbau angeht, ist dieser
Bausatz genau das Richtige, denn der Rumpf ist ein vorgefertigtes Resinteil. So
fängt das echte Modellbauen erst bei dem Deck an. Der Bausatz ist eigentlich auf
italienisch, es liegt aber ein Zettel mit den wichtigsten Übersetzungen bei - so
lernt man auch gleich noch etwas Fremdsprache, z.B. <em>non Incollare</em> - nicht
festkleben ;-)</p>
<h3 id="das-deck:3226d2f44ae028109dcc977bcfbb32c2">Das Deck</h3>
<p>Der erste Schritt ist, das Deck - ein lasergeschnittenes Holzteil - auf den
Resinrumpf zu kleben. Natürlich ist davor etwas Schleifarbeit nötig, das
Decksholzteil ist nämlich etwas zu lang und breit, was bedeutet, dass das Modell
nach dem Schleifen leider nicht mehr maßstabsgetreu ist. Egal.
<a href="http://www.flickr.com/photos/mohlendo/5355083592/"><img src="http://farm6.static.flickr.com/5127/5355083592_9bb04e3809.jpg" alt="Deck - Schritt 1" />
</a></p>
<p>Als nächstes werden die 4mm starken Decksplanken aufgeleimt. Die Leisten müssen
gebogen werden, weil sie sonst brechen würden. Ich habe das einfach in einem mit
heißem Wasser gefüllten Waschbecken gemacht: Die Leiste für ein paar Minuten im
Wasser baden und dann immer stärker biegen. Das Ergebnis sieht so aus:
<a href="http://www.flickr.com/photos/mohlendo/5355091696/"><img src="http://farm6.static.flickr.com/5164/5355091696_f547170430.jpg" alt="Decksplanken" />
</a></p>
<p>Ich bin bisher doch ziemlich überrascht, dass alles ohne große Probleme geklappt
hat. Hier gibt noch weitere
<a href="http://www.flickr.com/photos/mohlendo/sets/72157625822875866/">Bilder</a> des
ersten Tages. Fortsetzung folgt!</p>
</description>
</item>
<item>
<title>Hosting a Blogofile Blog on GitHub with GitHub Pages</title>
<link>http://manuel-ohlendorf.de/blog/2010/12/23/hosting-a-blogofile-blog-on-github-with-github-pages/</link>
<pubDate>Thu, 23 Dec 2010 13:09:03 UTC</pubDate>
<author>Manuel Ohlendorf</author>
<guid>http://manuel-ohlendorf.de/blog/2010/12/23/hosting-a-blogofile-blog-on-github-with-github-pages/</guid>
<description>
<p>So, in my first blog post I will describe howto use
<a href="http://www.github.com">GitHub</a> to serve a <a href="http://www.blogofile.com">Blogofile</a>
Blog, which I have done with this blog. ### First, what is
<a href="http://www.blogofile.com">Blogofile</a>? Blogofile is a framework for static
websites. You don&rsquo;t need a webserver and no database, only webspace. Blogofile
provides templates, controllers and filters, almost like any other dynamic web
frameworks and compiles them to a static website. Right now it is more or less a
blogging engine but you can actually create any website you want. Have a look at
the website for details.</p>
<p>And there comes <a href="http://www.github.com">GitHub</a> into the play.
<a href="http://www.github.com">GitHub</a> provides with <a href="http://pages.github.com/">GitHub
Pages</a> a very simple way of publishing content to the
web. So why not using <a href="http://www.github.com">GitHub</a> for serving your blogofile
website.</p>
<h3 id="github-setup:1e5a439a674e6273b2b26fe741d14769">Github setup</h3>
<p>You need 2 public repositories for that, the source code repository and the
website repository that contains the compiled pages. My two repos are:</p>
<ul>
<li><a href="http://github.com/mohlendo/manuel-ohlendorf.de">manuel-ohlendorf.de</a> with the source code</li>
<li><a href="http://github.com/mohlendo/mohlendo.github.com">mohlendo.github.com</a> with the compiled HTML files</li>
</ul>
<p>The later one is a special repository for user pages published with <a href="http://pages.github.com/">GitHub
Pages</a>.</p>
<h3 id="git-setup:1e5a439a674e6273b2b26fe741d14769">Git setup</h3>
<p>The whole source code of your website with the Mako templates etc. will be
pushed to the source code repository. The command <code>blogofile build</code> compiles the
website into the sub-folder <code>_site</code>. The contents of this directory is what we
want to push to the website repository which GitHub will publish to the web. In
order to do that we need to create a git
<a href="http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html">submodule</a>
with the command:</p>
<pre><code>git submodule add http://github.com/mohlendo/mohlendo.github.com _site
</code></pre>
<p>That creates a new submodule <code>_site</code>. Now every time the site is rebuild, you
can commit and push the changes to the website repository and github will
automatically publish them - in my case to
<a href="http://mohlendo.github.com">http://mohlendo.github.com</a></p>
<h3 id="config-py-changes:1e5a439a674e6273b2b26fe741d14769">_config.py changes</h3>
<p>Every time blogofile recreates the website it completely clears the <code>_site</code>
directory and therefor also the <code>.git</code> directory of the submodule. This leads to
a confusion of git and it cannot track changes on the compiled website anymore.</p>
<p>I wrote some small custom <code>pre_build()</code> and <code>post_build()</code> hooks that moves the
<code>.git</code> directory to a temp folder and restores it after a successful build.</p>
<h3 id="pre-post-build-hooks:1e5a439a674e6273b2b26fe741d14769">Pre/Post build hooks:</h3>
<pre><code class="language-python">def pre_build():
if not os.path.isdir(&quot;_tmp&quot;):
os.mkdir(&quot;_tmp&quot;)
else:
shutil.rmtree(&quot;_tmp&quot;)
os.mkdir(&quot;_tmp&quot;)
if os.path.isdir(os.path.join(&quot;_site&quot;,&quot;.git&quot;)):
shutil.move(os.path.join(&quot;_site&quot;,&quot;.git&quot;),&quot;_tmp&quot;)
#Do whatever you want before the _site is built
pass
def post_build():
if os.path.isdir(os.path.join(&quot;_tmp&quot;,&quot;.git&quot;)):
shutil.move(os.path.join(&quot;_tmp&quot;,&quot;.git&quot;),&quot;_site&quot;)
#Do whatever you want after the _site is built
</code></pre>
<p>Sadly, blogofile only invokes the <code>post_build()</code> hook when everything works
fine. When you have an error in your templates blogofile only invokes the
<code>pre_build()</code> hook. But destroying your submodule is no problem since you have
it on GitHub! Just delete the <code>_site</code> folder and update the submodule with <code>git
submodule update</code> in the root folder of your blogofile project.</p>
<h3 id="that-s-it:1e5a439a674e6273b2b26fe741d14769">That&rsquo;s it!</h3>
<p>Quite cool, I think, because you don&rsquo;t need any webserver or webspace and still
have quite a nice blog! As a start you can also fork my two github repos.</p>
</description>
</item>
</channel>
</rss>