tag:blogger.com,1999:blog-28582184785839301412024-03-14T07:15:04.595+01:00CodeapeI have a short memory so these texts are a way for me to remember and to share the stuff I try to remember ... sometimes I can actually find useful stuff in here. codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.comBlogger67125tag:blogger.com,1999:blog-2858218478583930141.post-52176237023593841752020-01-10T14:31:00.006+01:002021-01-25T14:45:12.379+01:00Making an internet troll in Blender 2.8<p>A 16 part series, I made, about sculpting, retopology, texturing, rigging and animating in Blender 2.8.</p><p>Enjoy</p>
<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/videoseries?list=PLzKXAtwR1JGmsfSjaGzlaFC9ZDoxXyDwo" width="560"></iframe>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-70271399868673186532019-10-22T19:20:00.000+02:002019-12-26T17:21:38.481+01:00Baking textures in Blender 2.8There are two different common scenarios (not the only ones though) when you bake textures in Blender 2.8:<br />
<br />
<ul>
<li>You have one low poly mesh you want to bake one texture to from multiple high poly meshes</li>
<li>You have multiple high poly meshes that are associated to several low poly meshes and you want to bake everything to one texture</li>
</ul>
<br />
Her are two videos I made about these two senarios:
<br />
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/E27ji7AzQ10" width="480"></iframe><br />
<br />
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/j-8lbfJJa40" width="480"></iframe><br />
<br />codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-59800303082232811932019-08-05T17:11:00.000+02:002019-12-26T17:12:08.258+01:00Creating a base mesh in Blender 2.8I have started to sculpt in Blender. When you sculpt you want something to start from. Right now I am playing around with the idea of doing a full body sculpt in the future. This is a simple and fast way to create a base mesh for a humanoid in Blender 2.8 <br />
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/TrvJP9_XsYc" width="480"></iframe>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-66309647104174179762019-03-02T15:00:00.000+01:002019-12-26T17:02:59.769+01:00My Space Invaders cloneSo I made a couple of game assets in blender:<br />
<br />
<ul>
<li><a href="https://www.youtube.com/watch?v=wN9f2Q9MI4s">Making of the spaceship</a> (<a href="http://www.codeape.org/2018/08/modelling-and-texturing-spacecraft-in.html">blog post</a>)</li>
<li><a href="https://www.youtube.com/watch?v=DEbVQDe0nRk">Making of the astroid</a> (<a href="http://www.codeape.org/2019/01/making-asteroid-in-blender-279-timelapse.html">blog post</a>)</li>
<li><a href="https://www.youtube.com/watch?v=2eId_21XKoY">Making of the saucer</a> (<a href="http://www.codeape.org/2019/01/making-flying-saucer-in-blender-279.html">blog post</a>)</li>
</ul>
<br />
I used those assets to make a little Space Invaders clone in <a href="https://godotengine.org/">Godot engine</a>:
<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/J60BSHOfWI8" width="480"></iframe>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com1tag:blogger.com,1999:blog-2858218478583930141.post-9847756674672737672019-01-06T16:22:00.000+01:002019-12-26T16:42:20.373+01:00Making a Flying Saucer in Blender 2.79Today I made a textured flying saucer. Another simple model you can make in no time and use as a asset in a game.
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/2eId_21XKoY" width="480"></iframe>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-7897714168429641912019-01-05T15:19:00.000+01:002019-12-26T16:42:46.829+01:00Making an Asteroid in Blender 2.79I show how simple and fast you can make an asteroid with low poly count but still looks ok. You could for example use as an asset in a simple game.
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/DEbVQDe0nRk" width="480"></iframe>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com1tag:blogger.com,1999:blog-2858218478583930141.post-83074509735214237432018-08-14T15:04:00.000+02:002019-12-26T15:14:31.853+01:00Modelling and texturing a spacecraft in Blender 2.79I am learning 3D art in Blender. This is my first serious(ish) project. It is a spacecraft and I use primitive operations like extrude and grab and the mirror modifier.
<br />
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/wN9f2Q9MI4s" width="480"></iframe>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-43796300640448873302017-05-22T21:58:00.001+02:002017-05-22T21:58:56.868+02:00Godot Engine Online Course<p>
If you plan to use the Godot Engine for a project in the future why not <a href="https://www.kickstarter.com/projects/gdquest/make-professional-2d-games-godot-engine-online-cou">back this online course</a>
</p>
<iframe width="480" height="270" src="https://www.kickstarter.com/projects/gdquest/make-professional-2d-games-godot-engine-online-cou/widget/video.html" frameborder="0" scrolling="no"> </iframe>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com25tag:blogger.com,1999:blog-2858218478583930141.post-38519171483781752462017-05-18T23:00:00.000+02:002017-05-18T23:00:31.322+02:00Creating games on Linux <p>
I will only write about game engines in this post. To be more specific I will only write about game engines that support Linux and are royalty free. This post will not cover any tools for game asset creation. With game assets I refer to Music, Sound effects, Textures, 2D sprites, 3D models etc.
</p>
<h3>Leadwerks</h3>
<p>
I started to do some game programming on Linux about 3 years ago (nothing published, just for fun). It all started when I <a href="https://www.kickstarter.com/projects/1937035674/leadwerks-build-linux-games-on-linux">backed</a> the port of the game engine <a href="http://www.leadwerks.com/">Leadwerks</a> to Linux. I liked the idea of helping this particular engine getting ported to Linux because the port also included all the tools (map editor etc.). The engine is not open source but it is not expensive if you compare with other engines. You buy the engine from Steam and the standard version gives you Lua as script language and the Pro version gives you a C++ API and the Lua script language. The engine has good performance and the APIs are quite easy to wrap your head around.The tutorials and documentation on Leadwerks home page are good and you can find good tutorial videos on YouTube. There is also a nice and helpful community (forum) around Leadwerks. The engine and tools also run in Windows (and maybe Mac in the future). I have had a lot of fun with this engine and it is quite easy to use if have programming experience. Here is a list of the features that Leadwerks have for the time of this writing:
</p>
<ul>
<li>Instantaneous asset reload</li>
<li>Visual interface for every task</li>
<li>Drag and drop import of models and textures</li>
<li>CSG primitives and compound shapes</li>
<li>Smooth groups</li>
<li>Carve and hollow</li>
<li>Save any object as a prefab</li>
<li>Automatic texture mapping</li>
<li>Auto-generate materials and normal maps</li>
<li>Built-in script and shader editor and debugger</li>
<li>Hardware-accelarated terrain painting tools</li>
<li>Paint vegetation onto your landscapes</li>
<li>OpenGL 4.X Renderer</li>
<li>Entity System</li>
<li>Environment Probes</li>
<li>Hardware skinning with up to 256 bones</li>
<li>Hardware Occlusion Culling</li>
<li>Terrain and Vegetation System</li>
<li>Customizable Post-Effects System</li>
<li>Fast and Accurate Physics</li>
<li>Physics</li>
<li>Navigation AI</li>
<li>Visual Flowgraph</li>
<li>Integrated IDE and Lua Debugger</li>
<li>VR - HTC Vive, Oculus and OSVR</li>
<li>Game Launcher - Free Self-Publishing to Steam Workshop</li>
</ul>
<p>
The only shortcoming Leadwerks has, that I can think of, is that there is very rudimentary support in the engine it self for game UI things like buttons, text fields etc. You need to write it your self or find a third party solution.
</p>
<h3>Godot</h3>
<p>
Lately I have started to play around with <a href="https://godotengine.org/">Godot engine</a> which is a free open source game engine. It is a quite feature packed engine that is well maintained and has a large and friendly community. It is worth taking a look at even if you are prepared to pay money for an engine. The engine works good both for 2D and 3D games, it has it own python(ish) scripting language and it has a very nice Animation system. Another rely nice feature is that it has a very mature game UI system that with buttons, text fields, list boxes etc. and if you miss a UI component you can easily write it you self. Godot organizes has something called scenes and sub scenes. For example a player character could be a scene and all enemy characters could be scenes and all these scenes can then be instantiated as sub scenes to a level scenes. Scenes are awesome when you get used to them and they provide a rely simple and effective work flow in the end. Even if I only have spent about 40 hours with the engine (at the time of this writing) I rely like it. Godot 2.1.X has the following nice features:
</p>
<ul>
<li>Visual editor, full of mature tools.</li>
<li>Uncluttered UI, with context-sensitive editors.</li>
<li>Scene system, supporting instancing and inheritance.</li>
<li>Friendly content creation interfaces for artists, level designers, animators</li>
<li>Visual shader editing for 2D and 3D.</li>
<li>Persistent live editing (changes are not lost after stopping the game).</li>
<li>Fully dedicated 2D engine, no hacks.</li>
<li>Work in pixels as your units, but scale to any screen size and ratio.</li>
<li>Custom 2D physics engine that works in pixel coordinates.</li>
<li>Flexible kinematic controller for collision without physics.</li>
<li>Blit 3D models as sprites into 2D.</li>
<li>Import 3D models from 3DS Max, Maya, Blender, and more with full animation.</li>
<li>Skeleton deforms and blend shapes.</li>
<li>Several light types, with shadow mapping.</li>
<li>Render with HDR, anti-aliasing and linear color modes.</li>
<li>Post-process fog, glow, bloom, color adjustment, …</li>
<li>Support for Physically-Based Rendering planned for the end of 2016.</li>
<li>Animate 2D or 3D. Visual animation editor with timeline.</li>
<li>Frame-based or cut-out animation for sprites and rigs.</li>
<li>Any property of any object can be animated, even function calls.</li>
<li>Use custom transition curves and tweens.</li>
<li>Helpers to animate 2D rigs, with skeletons and IK.</li>
<li>Efficient optimizer to pack imported 3D animations.</li>
<li>Animation Tree support for fluid character animation.</li>
<li>Python-like scripting language.</li>
<li>Built-in editor with syntax highlighting, real-time parser and code completion.</li>
<li>Powerful integrated debugger and profilers. Can debug a game running on mobile devices.</li>
<li>Integrated class documentation browser.</li>
<li>C++ API to optimize parts of the game or extend any part of the engine.</li>
<li>Godot works on Windows, OS X, Linux, FreeBSD, OpenBSD and Haiku. Editor runs in 32-bit and 64-bit, in all platforms.</li>
<li>Small download (around 20 MB), and you are ready to go.</li>
<li>Very easy to compile yourself in any platform (no dependency hell).</li>
<li>Filesystem usage is friendly to popular version control systems (Git, Subversion, Mercurial, PlasticSCM, Perforce, …).</li>
<li>Scene instancing makes teamwork a breeze, every team member can focus on their own scene. Be it a character, stage, … Edit without stepping on each other's toes.</li>
<li>Text-based descriptive and optimal scene format.</li>
<li>Script syntax supported by GitHub.</li>
</ul>
<p>
Compared to Leadwerks it has more features but Godots scripting language (GDScript) is has less performance than Leadwerks LUA script. However in the upcoming Godot 3.0 there will be performance improvements to GDScript and there will support for (kind of) importing C++ libs in to Godot in a very straight forward way called <a href="https://godotengine.org/article/dlscript-here">GDNative</a>.
</p>
<h3>Summary</h3>
Both engines are good, so it is only a matter of taste, what are your need and what shortcomings can you live with. This is a very short post about two game engines but I hope this was enough for you to go and try them out.
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-84612268208889337522017-02-15T21:42:00.001+01:002017-02-15T21:44:08.917+01:00Glyphy<p>
I found GLyphy a couple of years ago: <a href="https://github.com/behdad/glyphy">https://github.com/behdad/glyphy</a> (original finding was in <a href="http://tech.slashdot.org/story/14/01/15/187216/glyphy-high-quality-glyph-rendering-using-opengl-es2-shaders">this slashdot article</a>). GLyphy is a text renderer that are using actual vectors submitted to the GPU instead of rendering to bitmaps. The benefit with doing the rendering with vectors is the superb quality of the rendered text, the disadvantage is a much higher runtime cost. However, maybe the cost is worth it at the time of this writing. Today we have virtual reality headsets for example. In virtual reality, low quality rendering of text might destroy the whole experience in a VR UI.
</p>
<p>
Well, it has been laying around in the back of my head for a long time and out of curiosity I started to look for serious projects using it in the wild. I did not find any bigger project using it ... sadness. In the end I added an request/issue to the Godot engine about them to start using GLyphy: <a href="https://github.com/godotengine/godot/issues/7806">github issue</a>.
</p>
<p>
If anyone know about some project using GLyphy, please post a comment about it.
</p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com1tag:blogger.com,1999:blog-2858218478583930141.post-42755214439633098432017-02-09T08:33:00.000+01:002017-02-09T08:33:39.127+01:00Learning OpenGL <p>
A while ago I started to play with OpenGL and OpenGL shaders again. I thought that it would be nice to write down some good tips about good sources and tools for your learning process. I think that learning OpenGl 4 (the latest major version at time of writing) is more useful to learn than earlier versions because when you are done learning OpenGL 4 basics it is probably what most hardware will support.
</p>
<p>
If you have no knowledge at all about OpenGL I think this is a good starting point: <a href="http://simonschreibt.de/gat/renderhell/">Render hell</a>. It is probably the best (and the most fun) overview you can find for a render beginner.
</p>
<p>
After reading that short but colorful introduction you should buy your self these OpenGL books:
<ul>
<li><a href="http://www.amazon.com/OpenGL-Programming-Guide-Official-Learning/dp/0321773039">OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3 (8th Edition)</a></li>
<li><a href="http://www.amazon.com/OpenGL-SuperBible-Comprehensive-Tutorial-Reference/dp/0321902947">OpenGL SuperBible: Comprehensive Tutorial and Reference (6th Edition)</a></li>
<li><a href="http://www.amazon.com/OpenGL-Shading-Language-Cookbook-Edition/dp/1782167021">OpenGL 4 Shading Language Cookbook - Second Edition</a></li>
</ul>
The first two are about OpenGL 4 and how to use OpenGL in broad terms and are the de facto standard reference literature in the subject and the last one is handy OpenGL Shading Language cookbook. There are plenty of tutorials also available on the internet if you do not want to buy the books above. However, the books above will probably take you further than any online tutorial.
</p>
<p>
To learn OpenGl yo need to code. Most of what you need is covered in the books above or in many of the online tutorials you can find. However if you are mostly interested in programming in the OpenGL shading language then there are two tools that can be of interest: Shadertoy and ShaderTool.
</p>
<p>
During my play I have found a very useful sandbox called Shadertoy. Shadertoy is a webpage where you can write WebGL pixel/fragment shader code and see the result directly so it is a perfect tool for learning and play around with pixel (fragment) shader code. WebGL is based o OpenGL ES 2.0 and OpenGL ES is a subset of OpenGL. It is pure joy! So go there and have fun: <a href="https://www.shadertoy.com/">https://www.shadertoy.com/</a>
</p>
<p>
<a href="http://www.shadertool.com/">ShaderTool</a> is a desktop application only available for Windows at the time of this writing (will be available for Windows, Mac and Linux in the future). It supports writing Vertex, Control (Hull), Evaluation (Domain), Geometry and Pixel shaders. So ShaderTool is much more powerful tool than Shadertoy, but it costs money. Here is a list of some features ripped directly from the developer:
<ul>
<li>Write shaders and view results instantly</li>
<li>Support of HLSL and GLSL (DirectX and OpenGL)</li>
<li>Latest shader models fully supported</li>
<li>Code editor with syntax highlighting, warning and error output</li>
<li>Easy-to-use node-based render pipeline</li>
<li>Import models, textures, audio files and other resources per drag'n drop</li>
<li>Export your shaders and share them with others</li>
<li>Create template projects for more efficient shader development</li>
<li>Direct use of shaders in DirectX or OpenGL applications</li>
<li>Oculus Rift DK 2 fully supported (Direct Acces Mode)</li>
<li>Use audio streams for shader input to create stunning effects</li>
<li>Post-Effects fully supported</li>
<li>Create multiple render-pipelines and combine them to create AAA shaders used in games</li>
</ul>
</p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-18728526497453364512014-08-29T10:51:00.001+02:002014-10-07T08:07:31.685+02:00hilite.me is nice for my blog posts<p>
When you have a lot of code in your posts they can end up looking messy and/or dull. To make the code easy to read the code need color. Color add more structure for the brain (also called syntax highlighting). To get syntax highlighting in my blog post I have started to use <a href="http://hilite.me/">hilite.me</a>. Hilite.me produces a html div block with inline CSS so no external CSS or Javascript files are required. I use the colorful style with row numbers by the way.
</p>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%">1</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">print</span> <span style="background-color: #fff0f0">'Produced with hilite.me'</span>
</pre></td></tr></table></div>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-10296181794363552382014-02-20T23:12:00.000+01:002014-02-20T23:12:34.461+01:00Changes are a good thing<p>
For many years I have run my own public server to host my blog on. First I used pyblosxom and wrote the plug-ins pygallery and pyguest. After some years I started to use blogofile and then i wrote smugofile. However, I am a bit tired to host my blog and maintain plug-ins, so now I will stop doing that. I have put my source code for the blogware plug-ins on git hub if anyone want to play with the code.
</p>
<p>
I will keep my blog on a service and keep on blogging and direct my coding on other stuff. If I produce something interesting, I will probably mention it here.
</p>
<p>
CU ... time for some coding.
</p>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-91722615875513284952012-03-19T12:49:00.000+01:002014-01-16T08:38:33.713+01:00Smugofile is born<p>
Smugofile is a collection of scripts to create galleries for
<a href="http://www.blogofile.com/">Blogofile</a> from public
<a href="http://www.smugmug.com/">SmugMug</a> galleries.
Smugofile galleries link images on SmugMug directly instead of downloading them.
</p>
<p>
You can find more information on
<a href="https://github.com/codeape/smugofile">git-hub</a>.
</p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-54764206448299230372012-02-20T22:15:00.000+01:002014-01-16T08:33:09.746+01:00W3C validator does not like css3<p>
If you use a referer url
(<code>http://jigsaw.w3.org/css-validator/check/referer</code>) to the w3c
validator for your css3, the validator will tell you that you have a broken css.
This is because css3 is not a finished standard (from w3c point of view) and the
validator will assume that you use css 2.1 by default. I discovered this when I
<a href="/blog/2012/02/18/responsive-design-and-css3-media-queries/">added css3
media queries to my blogs css</a> and the validation returned errors. However
you can force the w3c validator to validate css3 by appending
<code>?profile=css3</code> to the referer url like this:
<code>http://jigsaw.w3.org/css-validator/check/referer?profile=css3</code>
</p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-13738209350578656642012-02-18T13:45:00.000+01:002014-01-16T08:30:01.527+01:00Responsive Design and CSS3 Media Queries<p>
Today I added responsive design to my little corner on the web. The idea with
responsive design is to have a web page layout that changes with the screen size
of the device the viewer is currently using to display the web page.
</p>
<p>
Do you want to see how it works? Well, the resize width of the web browser
window you are using to browse this site and let it be narrower than the content
and the sidebar (the sidebar contains the last 5 posts and the categories). You
will now see that the sidebar is relocated to be just bellow the title banner of
this web page.
</p>
<p>
Do you want to read more? A good starting point is this
<a href="http://deanhume.com/Home/BlogPost/responsive-design-and-css3-media-queries/60">
grate blog post</a> by Dean Hume.
</p>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-21183021995234207592011-11-04T13:36:00.000+01:002014-01-16T08:09:46.286+01:00Sshguard needs a test run<p>
After <a href="http://www.codeape.org/blog/2011/11/03/fail2ban-is-good-stuff/">
posting about Fail2ban</a> yester day I remembered that there is one more cool
tool. The tool is <a href="http://www.sshguard.net/">Sshguard</a> and is similar
to Fail2ban. However, Sshguard is implemented in C and not a scripting language
like Fail2ban (python). Sshguard also increases the ban time exponentially ...
and that is nice.
</p>
<p>
I have not tested Sshguard yet but one of my friends highly recommends it.
</p>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-76091109355413410482011-11-03T22:25:00.000+01:002014-01-16T08:09:35.905+01:00Fail2ban is good stuff<p>
<a href="http://www.fail2ban.org/">Fail2ban</a> is a handy little script for
anyone who wants to protect them self from hackers brute force attacks.
Fail2ban scans log files like <code>/var/log/pwdfail</code> or
<code>/var/log/apache/error_log</code> and bans IP that makes too many password
failures. It updates firewall rules to reject the IP address. It works with SSH,
HTTP, FTP, Mail services etc.
</p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-15654296964826644072011-11-02T21:44:00.000+01:002014-01-16T08:09:27.176+01:00Note to self - remember how run-parts work<p>
A couple weeks ago I wrote a bash script and tested it and the script worked. I
copied the bash script to the daily cron jobs (<code>/etc/cron.daily</code>)
and after a couple of days I noted that it had never been run. After 2 hours of
debuging I syill could not get it to run. However, then I rembered that the
cron jobs are executed by <code>run-parts</code>. I opened the man page and what
did I find:
</p>
<pre>If neither the --lsbsysinit option nor the --regex option is given then the
names must consist entirely of upper and lower case letters, digits,
underscores, and hyphens.
</pre>
<p>
The filename of my bash script had a dot in it (<code>scriptname.sh</code>) and
crontab does not use <code>run-parts</code> with the <code>--lsbsysinit</code>
option nor the <code>--regex</code> option. This is the second time I have
screwed up a cron script name like this.
</p>
<p>
The simple solution was to remove the suffix from the filename of the script.
</p>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-80521284666317020782011-11-01T15:00:00.000+01:002014-01-16T08:08:38.159+01:00Makefiles for building many binary flavors<p>
If you want to share code for several binaries you would normally organize this
code as a shared or static library. This is usually how I do it, but recently I
came across a situation where this actually became a clumsy way of doing it.
</p>
<p>
The real life scenario is the following. We have a binary that make a lot of
syntactical and type checks for a configuration file format. If the
configuration file is ok the binary starts to generate system configuration
files. We will label this binary as tool. Additional to the tool binary we want
a binary that only do the checks and is not able to generate files and that
binary is labeled tool-simple. The code base is a huge directory tree with many
Makefiles, like this:
</p>
<pre>|-Makefile
|-pkg/
|-src/
| |-proj1/
| | |-Makefile
| | |-main.c
| |
| |-proj2/
| | |-Makefile
. . .
. . .
. . .
</pre>
<p>
In this case proj1 contains the source code for the binary called tool. However,
proj1 needs to be built in two binary different flavors from the exact same
source files but with different define arguments to gcc. This could have easily
been done by running make twice (traverse the build tree twice) in the normal
case. However, because the binaries will be packaged in the same tgz file we can
only traverse the build tree once if we want to make a sane build environment.
The solution is to create a structure for project q that look like this:
</p>
<pre>|-src/
| |-proj1/
| | |-Makefile
| | |-tool/
| | | |-Makefile
| | | |-cmd.c
| | | |-cmd.h
| | | |-common.inc
| | | |-main.c
| | |
| | |-tool-simple/
| | | |-Makefile
</pre>
<p>
Lets consentrate on the files in the project1 dirextory tree.
</p>
<pre>proj1/Makefile</pre>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%">1
2
3
4
5
6
7
8
9</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #0066BB; font-weight: bold">all</span><span style="color: #333333">:</span>
make -C tool all
make -C tool-simple all
<span style="color: #0066BB; font-weight: bold">clean</span><span style="color: #333333">:</span>
make -C tool clean
make -C tool-simple clean
<span style="color: #888888">#eof</span>
</pre></td></tr></table></div>
<p>
There is nothing special about this Makefile and that is the nice thing about it.
Lets keep things simple and clean where we can and all the special cases
isolated.
</p>
<pre>proj1/tool/cmd.c</pre>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #557799">#include "cmd.h"</span>
<span style="color: #557799">#include <stdio.h></span>
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">tool_func</span>() {
printf(<span style="background-color: #fff0f0">"Do tool stuff</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>);
}
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">simple_func</span>() {
printf(<span style="background-color: #fff0f0">"Do simple stuff</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>);
}
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">common_end</span>(){
<span style="color: #557799">#ifdef SIMPLE</span>
printf(<span style="background-color: #fff0f0">"Simple end</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>);
<span style="color: #557799">#else</span>
printf(<span style="background-color: #fff0f0">"Tool end</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>);
<span style="color: #557799">#endif</span>
}
<span style="color: #888888">//eof</span>
</pre></td></tr></table></div>
<pre>proj1/tool/cmd.h</pre>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 1
2
3
4
5
6
7
8
9
10
11</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #557799">#ifndef CMD_H</span>
<span style="color: #557799">#define CMD_H</span>
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">tool_func</span>();
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">simple_func</span>();
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">common_end</span>();
<span style="color: #557799">#endif</span>
<span style="color: #888888">//eof</span>
</pre></td></tr></table></div>
<pre>proj1/tool/main.c</pre>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #557799">#include "cmd.h"</span>
<span style="color: #557799">#include <stdio.h></span>
<span style="color: #333399; font-weight: bold">int</span> <span style="color: #0066BB; font-weight: bold">main</span>(<span style="color: #333399; font-weight: bold">int</span> argc, <span style="color: #333399; font-weight: bold">char</span><span style="color: #333333">**</span> argv) {
simple_func();
<span style="color: #557799">#ifndef SIMPLE</span>
printf(<span style="background-color: #fff0f0">"Tool working ...</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>);
tool_func();
<span style="color: #557799">#endif</span>
common_end();
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #0000DD; font-weight: bold">0</span>;
}
<span style="color: #888888">//eof</span>
</pre></td></tr></table></div>
<p>
The only thing interesting in these 3 C files (main.c, cmd.c and cmd.h) are the
ifdefs and ifndefs that are used to include and exclude code depending on the
build. From the real scenario the shared code for the binaries are rather 80%
than the few percent that are used in these files.
</p>
<pre>proj1/tool/common.inc</pre>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%">1
2
3
4
5
6</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #996633">CC</span><span style="color: #333333">=</span>gcc
<span style="color: #996633">OBJ</span> <span style="color: #333333">=</span> main.o <span style="color: #666666; font-weight: bold; background-color: #fff0f0">\</span>
cmd.o
<span style="color: #888888">#eof</span>
</pre></td></tr></table></div>
<p>
The file common.inc mainly contains the list of all object files that should be
produced. In this case we have also included the common definition of CC.
</p>
<pre>proj1/tool/Makefile</pre>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #557799">include common.inc</span>
<span style="color: #996633">TARGET</span><span style="color: #333333">=</span>tool
<span style="color: #0066BB; font-weight: bold">all</span><span style="color: #333333">:</span> <span style="color: #6600EE; font-weight: bold">$(TARGET)</span>
<span style="color: #008800; font-weight: bold">$(</span>TARGET<span style="color: #008800; font-weight: bold">)</span>: <span style="color: #008800; font-weight: bold">$(</span>OBJ<span style="color: #008800; font-weight: bold">)</span>
<span style="color: #008800; font-weight: bold">$(</span>CC<span style="color: #008800; font-weight: bold">)</span> -o <span style="color: #996633">$@</span> <span style="color: #996633">$^</span>
%.o: %.c
<span style="color: #008800; font-weight: bold">$(</span>CC<span style="color: #008800; font-weight: bold">)</span> -Wall -c -o <span style="color: #996633">$@</span> <span style="color: #996633">$<</span>
clean:
rm -f <span style="color: #008800; font-weight: bold">$(</span>TARGET<span style="color: #008800; font-weight: bold">)</span> <span style="color: #008800; font-weight: bold">$(</span>OBJ<span style="color: #008800; font-weight: bold">)</span>
<span style="color: #888888">#eof</span>
</pre></td></tr></table></div>
<p>
The Makefile in the tool directory is a very normal Makefile with the include of
common.inc as the only deviation.
</p>
<pre>proj1/tool-simple/Makefile</pre>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #557799">include ../tool/common.inc</span>
<span style="color: #FF0000; background-color: #FFAAAA">vpath</span> <span style="color: #FF0000; background-color: #FFAAAA">%.h</span> <span style="color: #FF0000; background-color: #FFAAAA">../tool</span>
<span style="color: #FF0000; background-color: #FFAAAA">vpath</span> <span style="color: #FF0000; background-color: #FFAAAA">%.c</span> <span style="color: #FF0000; background-color: #FFAAAA">../tool</span>
<span style="color: #996633">TARGET</span><span style="color: #333333">=</span>tool-simple
<span style="color: #0066BB; font-weight: bold">all</span><span style="color: #333333">:</span> <span style="color: #6600EE; font-weight: bold">$(TARGET)</span>
<span style="color: #008800; font-weight: bold">$(</span>TARGET<span style="color: #008800; font-weight: bold">)</span>: <span style="color: #008800; font-weight: bold">$(</span>OBJ<span style="color: #008800; font-weight: bold">)</span>
<span style="color: #008800; font-weight: bold">$(</span>CC<span style="color: #008800; font-weight: bold">)</span> -o <span style="color: #996633">$@</span> <span style="color: #996633">$^</span>
%.o: %.c
<span style="color: #008800; font-weight: bold">$(</span>CC<span style="color: #008800; font-weight: bold">)</span> -Wall -c -o <span style="color: #996633">$@</span> <span style="color: #996633">$<</span> -DSIMPLE
clean:
rm -f <span style="color: #008800; font-weight: bold">$(</span>TARGET<span style="color: #008800; font-weight: bold">)</span> <span style="color: #008800; font-weight: bold">$(</span>OBJ<span style="color: #008800; font-weight: bold">)</span>
<span style="color: #888888">#eof</span>
</pre></td></tr></table></div>
<p>
The interesting stuff is found in the Makefile contained in the tool-simple
directory In this Makefile we also include the common.inc file from the tools
directory. The tools-simple directory does not contain any C files that can be
compiled to the object files declared in common.inc though. We will compile the
.c and .h files from the tools directory in to the tools-simple directory
with the help of the <code>vpath</code> directive. Note the lower case of the
directive <code>vpath</code> because <code>vpath</code> and <code>VPATH</code>
are two different directives. <code>VPATH</code> specifies a list of directories
that make should search. Similar to the <code>VPATH</code> directive, but more
selective, is the <code>vpath</code> directive , which allows you to specify a
search path for a particular class of file names: those that match a particular
pattern. Also note that we define SIMPLE in this Makefile with the argument
-DSIMPLE when we build our object files for tool-simple By defining SIMPLE we
will not compile some code as you can see from the C files above.
</p>
<p>
Go and have fun with some Makefiles!
</p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-89833056195683391772011-10-13T23:14:00.000+02:002014-01-16T08:07:56.477+01:00Awesome EM Based Layout<p>
Today I updated the design of my little blog. Usually it is meaningless to
mention that, but in this case I need to give some credit to a good source of
inspiration.
</p>
<p>
I stared out playing around with matching colors and got very bored. I have done
this many times and it never end up well So i started over and decided to look
for some inspiration by searching for words like: cool web design I found a lot
of good looking black and white home pages. The color problem was now solved!
</p>
<p>
During my search for good looking black and white web pages I also found
<a href="http://mirificampress.com">Mirificam Press</a>. And started to read the
<a href="http://mirificampress.com/resources_and_study.php">Series and Study</a>
section. After some reading I ended up reading this nice article:
<a href="http://mirificampress.com/permalink/indestructable_website_em_based_layout">
Indestructible Website: How to Build an EM Based Layout that Won't Break
</a>. So I decided to use an EM based layout that won't break.
</p>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com1tag:blogger.com,1999:blog-2858218478583930141.post-75959068811972818282011-09-16T23:34:00.000+02:002014-01-16T08:06:44.081+01:00ValueError on Mac OS X caused by locale<p>I was lazy! Apparently I only needed to set my locales right in the terminal
and the error disappeared. I added this to my .bash_profile:
</p>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%">1
2</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #007020">export </span><span style="color: #996633">LC_ALL</span><span style="color: #333333">=</span>en_US.UTF-8
<span style="color: #007020">export </span><span style="color: #996633">LANG</span><span style="color: #333333">=</span>en_US.UTF-8
</pre></td></tr></table></div>
codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-17829403894085288482011-09-14T15:22:00.000+02:002014-01-16T08:00:19.429+01:00Blogofile ValueError on Mac OS X<p>Today I found a nasty little bug in Blogofile: <a href="https://github.com/EnigmaCurry/blogofile/issues/112">https://github.com/EnigmaCurry/blogofile/issues/112</a></p>
<p>I get a ValueError from Blogofile on my Mac: This bug is problematic because I can not do a local build before I send new stuff over to the Linux server. </p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-89440304123529829442008-11-18T08:25:00.000+01:002014-01-17T08:20:15.115+01:00W3C and youtube<p>
I did a w3c validation of codeape.org and discovered that I had forgot to w3c-ify the YouTube code. Fixed it!
<p>
</p>
Here is the service i usually use for this kind of stuff: <a href="http://www.trustfm.net/W3CYouTubeProducer/">W3C YouTube Producer</a>
</p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0tag:blogger.com,1999:blog-2858218478583930141.post-87446773030976766012007-11-13T16:20:00.000+01:002014-01-17T08:31:31.002+01:00pygallery 2.01<p>
pygallery.py 2.01
Finally! Now you can group not only thumbs but also galleries in this release of pygallery.py. Have fun =)
</p>codeapehttp://www.blogger.com/profile/08155259222389273105noreply@blogger.com0