Thursday 3 October 2013

Tuunyyte at h4hjozi


It was quite a successful (but sadly intimate) evening at h4hjozi. I managed to hack the printrbot together again after the unfortunate meltdown we had 2 weeks ago (note to self: don't leave PLA parts in direct sunlight during a heatwave again).





After checking all the axis and endstops and re-leveling I printed my trusted quicky print: a butterfly fridge magnet. I printed one for our fridge but kept on giving it away so now, I make sure that I always keep a spare one around in my print demo box.


Devin also finally managed a good gnu print at h4hjozi which is a great relief. I think I would have given up long ago if I had to suffer all the inexplicable problems he had. Just overjoyed that it is finally working \o/

I think this is a new h4h jozi meetup record: 2 working printers, each creating something successfully.

Thursday 26 September 2013

Laat die hele aarde juig - Retief Burger - Guitar Tabs in E

(this is just my stab at working it out for my future reference)

Laat die hele aarde juig

Words & Music:  Retief Burger 2008

Guitar Tabs in E  (CD/Original version is G)


Intro:

                                                           x2
e-----------------------------|-----------------------------|
B-----------------------------|-----------------------------|
G-13-11-13------13-11-13------|-13-11-13------13-11-13------|
D-----------------------------|-----------------------------|
A-----------------------------|-----------------------------|
E-----------------------------|-----------------------------|

Instrumental


Instrumental:
                                                           x3
e-----------------------------|-----------------------------|
B-----------------------------|-----------------------------|
G-13-11-13------13-11-13------|-13-11-13-14-13-11-----------|
D-----------------------------|-----------------------------|
A-----------------------------|-----------------------------|
E-----------------------------|-----------------------------|


e-----------------------------|-----------------------------|
B-----------------------------|-----------------------------|
G-13-14-13--------------------|-13-14-13--------------------|
D-----------------------------|-----------------------------|
A-----------------------------|-----------------------------|
E-----------------------------|-----------------------------|

Wednesday 17 July 2013

the day I had to hack wget

Thanks to Richard who insists on documenting stuff on mediawiki, I had to figure out how to make a static mirror of the html so that I a) have offline access and b) am 100% sure anything I put there is backed up properly and there is no chance of loosing any information.

I thought it was simple enough, just httrack or wget it, but it turned out to be much trickier :(

Problem #1: how to get httrack to authenticate

Mediawiki uses a form login and uses a login token that it stores in a cookie before opening the form :( which is good for security etc. but made it real tricky for me. In the end I could not get it working with httrack and moved on to wget, but not before figuring out how to intercept a cookie from my browser which was really helpful with debugging later. Some helpful links if you wanna try this:
http://www.dzone.com/snippets/using-wget-download-content
http://httrack.kauler.com/help/CatchURL_tutorial
http://www.httrack.com/html/fcguide.html

Problem #2: how to get wget to authenticate

It took some time to figure out the complicated login process mentioned above. This post from amadeus helped me get on the right track.

Problem #3: how to not 'click' on the logout link?!

Simple right just add --reject '* = *' to the configuration..
It turns out that wget (1.14 on ubuntu) for some reason first downloads all 'rejected' links and then deletes them?! !@#$!@#$
Thanks Tomàs Reverter for finally pointing me into the right direction with easy instructions for hacking wget.
His patch didn't do the trick for me so I hacked it a bit: 
Download the wget source code.
in src/recur.c on line 406 I injected an if statement so that we don't even enqueue 'rejected' urls

if (acceptable (child->url->url)) {
    url_enqueue (queue, ci, xstrdup (child->url->url),
    xstrdup (referer_url), depth + 1,
    child->link_expect_html,
    child->link_expect_css);
}
Then ./configure && make && sudo make install 
This did unfortunately not solve my problem yet, digging a bit further I noticed that the acceptable() method actually only checks regex rejects, and I thought that the glob version of reject gets converted or something.. NO! I had to specify
--reject-regex='.*=.*,.*UserLogout.*' before it finally started to work.
(The man page doesn't mention --reject-regex but I realized wget --help does )

Here is my script that downloads our internal wiki, it is very dirty and probably does loads of unnecessary stuff but it works, and it is 01:15 and I'm sick and I want to go to bed, but want to get this out while I have all the browser tabs still open:

WIKI_USERNAME='someone'
WIKI_PASSWORD='setupusthebomb'
TARGETHOST="http://intranet.example.com/mediawiki"
MW_DOMAIN="intranet.example.com"
MW_URL="$TARGETHOST"
INDEX_URL="$TARGETHOST/index.php"
MW_PAGE="Main_Page"
TARGET_DIR="/tmp/wget/"

# Mediawiki uses a login token, and we must have it for this to work.
WP_LOGIN_TOKEN=$(wget -q --no-check-certificate -O - --save-cookies cookies.txt --keep-session-cookies "$MW_URL/index.php/Special:UserLogin" | grep wpLoginToken | grep -o '[a-z0-9]\{32\}')

sleep 1

wget -q --no-check-certificate --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies --post-data "wpName=${WIKI_USERNAME}&wpPassword=${WIKI_PASSWORD}&wpDomain=${MW_DOMAIN}&wpRemember=1&wpLoginattempt=Log%20in&wpLoginToken=${WP_LOGIN_TOKEN}" "$INDEX_URL?title=Special:UserLogin&action=submitlogin&type=login" -O ${TARGET_DIR}/tmp

sleep 1

#not sure why this is needed, but it is (probably because mediawiki doesn't like it if you hit an 404 right after logginj in)
wget -q --no-check-certificate --load-cookies cookies.txt --keep-session-cookies --save-cookies cookies.txt "$MW_URL/index.php/${MW_PAGE}" -O ${TARGET_DIR}/tmp.html

sleep 1

/usr/local/bin/wget -t0 -T900 --limit-rate=30k --random-wait -e robots=off --no-check-certificate --load-cookies cookies.txt --keep-session-cookies --mirror --convert-links -backup-converted --html-extension --page-requisites --reject='*=*,*UserLogout*' --exclude-directories='*=*,*UserLogout*' --reject-regex='.*=.*,.*UserLogout.*'   --no-parent -P ${TARGET_DIR}  -o ${TARGET_DIR}/wget-log "$MW_URL/"

# Problem #4: the following doesn't actually work, 
# because wget decides out of its own cleverness to go into 
# background mode and I can't see a way to disable that, I smell another hack:(
#remove my username from all the pages
cd $TARGET_DIR
grep -ilr ${WIKI_USERNAME} . | xargs sed -i s/${WIKI_USERNAME}/User/g

# delete pages that include the user name
find -iname "*${WIKI_USERNAME}*" -delete


Problem #4: don't know how to force wget to not enter backrgound mode :(

Please help me in the comments..

Monday 24 June 2013

First proper prints on the h4hjozi printrbot \o/

Yesterday I finally managed to finish calibrating the 3d printer that I've been building for about a year now. I didn't spend enough time on it before, but since I've joined the 3D Printing community on Google+ I got more focused on actually finishing the thing.


This is the first non-calibration object I printed.

(I forgot to turn of the anti-gravity engines for this video, sorry).




With the addition of the fan and properly levelling the bed things started to look much better. However when printing thin walls I kept on seeing "row of dots instead of a line" and it was not laminating properly. The parameter in slic3r I found that helped was "Extrusion multiplier" and I ended up on 1.75! I just realised though that I should have rather increased then hotend temperature above the 185°C I was using... will do that next time :)

As you can see I printed some stubbys (one with a screw on bottom and its main body printed with support) and a couple of rings.


The thread actually works!


Thanks to openhardware from where the printrbot was sourced. A lot of additional community support came from Org and Gert from house4hack, thanks a lot guys!





Update: printer layout for KobusJ:


Thursday 9 May 2013

Ubuntu 13.04 (Raring Ringtail) release braai in Randburg


Unfortunately we had a very small turn out, 
but it was still fun. I met another linux geek that lives close by (Johan left), and got to hang out with Leon (right) again. We had lots of interesting conversations.



I'm on the left pretending to braai:


Not sure why the turnout was this bad, either a) the day/date/time wasn't suitable b) people are not really excited about ubuntu any more :( c) I didn't advertise well enough and widely enough d) should have aimed it more to general linux folk not just ubuntu lovers e) all of the above. 
I still think it was worthwhile. If you have any suggestions on how we can improve for the next time, please let me know in the comments. I'm thinking we should do it at a restaurant again next time, maybe people feel safe and less awkward there.


Leon's twin brother had a green hat on so that we could tell them apart..

Friday 19 April 2013

Moringa seeds sprou ting

or as I like to say 2 of my babies have hatched and a couple more seems to almost peak out the ground.
I'm growing them indoors in sort of self-watering contraptions made out of coke bottles, but I'll leave my master construction technic for another day.

Rewinding just for a bit, by first go at germinating didn't go that well. I got mould on some of my seeds and in the end only 2/6 hatched.

I sprinkled some cinnamon on the moulded seeds, but that didn't really help much.. 

I think they were not in the ideal worm area of our house either.
Then I did a much smaller container which I sterilized with boiling water, insulated with foil and kept it in a tin on top of my laptop power supply which kept it nice an snug. 4/4 white roots sprang forth this time \o/.


Carefully planting them in a mix of potting soil and river sand.

Behold one of the older boys first days, you can make out little green fingers already.



The twins are doing quite nicely so far and the quadruplets are just starting to peak out. 


I just hope they survive this weekend as we are going away for a couple of night. Mmm I should have left keys with somebody to come fill their bottles while I'm gone. Gonna miss them.




h4hjozi first fully wifi-internetted meetup in the cave

I arrived early and managed to get the wireless internet working! Dhcp forwarding made it very easy, except I don't know what the router's IP is anymore :(

Marcel and I were still standing around when Schalk and Guy flew in and had the place re-arranged to our customary layout in no time.

Wednesday 3 April 2013

Got my Moringa seeds today!

I finally got my Moringa seeds that I ordered from here.


I first heard of it on Lets Talk Possibility.
You may ask what is this good for, in short from the site where I bought my seeds from: It is
  • One of the few plants on earth whose leaves contain all the Essential Amino Acids required for Human Protein Synthesis. Essential for Vegans and Vegetarians


  • One of Nature's Richest sources of Vitamins, Minerals and anti-oxidants


  • A Rich source of bio chelated Vitamins A, B1, B2, B3, C and E


  • A Rich source of bio chelated Calcium, Magnesium, Potassium, Sulphur, Copper and Iron
etc. etc.




The minimum amount of seeds you can order from there is 120, so if you live close to me I'll be happy to sell smaller quantities of my stock, say R10 for 6.


I started soaking 6 in water immediately, so I can get some leaf ASAP :).


Then I'll stick them in a plastic container to germinate and then plant them in self watering 2 litre coke bottles indoors (because we are a bit too close to winter). When they are a bit bigger I'll plant them out outside or into bigger containers. I'll sell some plants in coke bottles too if you prefer that, say about R10 each.

Apparently the leaves are a bit bitter, so in the end I might end up mostly making powder and tea, but I'll try it fresh and in stir fry and even boil some green leafy branches like spinage etc. I have no idea how it tastes - that is why I ordered the seeds to be able to try it out - will let you know as soon as I do and I'll give some samples as soon as I have some.




Monday 25 March 2013

unprotecting xlsm or xlsx files

I had to unprotect an xlsm spreadsheet (because the author is on vacation).

I found out how here:
http://datapigtechnologies.com/blog/index.php/hack-into-a-protected-excel-2007-sheet/

I converted it into a crude bash script for in case I need to do it again:

#!/bin/bash
workdir=`dirname $1`

filename=`readlink -f "$1"`
unprotected_filname=`echo $filename | sed s/.xlsm$//`-unprotected.xlsm
tmpdir='/tmp/unprotect'
unzip "$filename" -d $tmpdir

sheetfiles=`find $tmpdir/xl/worksheets/ -iname "*.xml"`
echo $sheetfiles

echo "before replacing"
grep -c sheetProtection $sheetfiles
sed -i 's/]*\/>//g' $sheetfiles

echo "after replacing"
grep -c sheetProtection $sheetfiles

cd $tmpdir
zip -r "$unprotected_filname" *
cd -
rm -rf $tmpdir

Thursday 7 March 2013

Set zoomlevels for gwt-openlayers and openstreetmap

I tried to make the zoom level bar show the same number of zoom levels as my offline cache and I'm shocked at how little information is out there about this.

The method below is doing the trick for me now:

/**
     * @param options
     * @param minZoomLevel the minimum for this is 3 for open streetmap
     * @param maxZoomLevel
     */
    private static void setZoomLevelRange(LayerOptions options,
        int minZoomLevel, int maxZoomLevel) {
        options.getJSObject().setProperty("zoomOffset", minZoomLevel);

        int len = maxZoomLevel - minZoomLevel + 1;
        double[] resolutions = new double[len];
        double curRes = 78271.51695 / (Math.pow(2, minZoomLevel - 1));
        for (int i = 0; i < len; i++) {
            resolutions[i] = curRes;
            curRes = curRes / 2;
        }

        options.setResolutions(resolutions);
    }


// usage example:
        OSMOptions osmOptions = new OSMOptions();
      
        setZoomLevelRange(osmOptions, 5, 11);
      
        OSM baseTileLayer = new OSM("Mapnik", 
          // for offline tiles:
          GWT.getHostPageBaseURL()
            + "tiles/${z}/${x}/${y}.png", 
          osmOptions);



The keys are:

  1. there is apparently a magic zoom level 1 resolution (I have not found how it is calculated).
  2. you can add higher and lower resolutions by multiplying or dividing them by 2.
  3. it is critical that you set the zoomOffset in accordance to what you use as your  minimum zoom level.

Your welcome and yeah you may copy the code as you want.

References:



Monday 4 March 2013

Get Lucky with JRebel

Get Lucky with JRebel
Win an all expense trip for 2 to Ireland

Hello Rebel,
Feeling lucky? We are offering an all expense paid trip for two to Ireland for St. Patricks Day 2014. Everyone who activates a JRebel trial in the month of March will be entered to win. So if you've never tried JRebel, or it's been a while since you've tried it, download your trial, put an end to redeploys, and get a chance to win a trip.

Activate your JRebel trial here

Just a few points to note:
  1. For this giveaway to become active we must reach 3000 JRebel trial activations.
  2. In order to enter you need to be a java developer or managing java developers
  3. You must provide complete and accurate contact info (we will be contacting the winner)
  4. Multiple sign-ups will result in you being disqualified
  5. Each person you get to activate a JRebel trial gives you an additional entry in the contest
  6. If you tweet @JRebel with a picture of your St. Patty’s Day celebration we will also throw your name in the hat to win 
Good Luck & Happy Coding!

Oliver

--
Oliver White
Prize Guy
ZeroTurnaround


As the winner you will be free to pick which city you would like to visit for St Patrick's Day 2014 (Ireland or Boston - both known for their St. Patricks Day celebrations) If for whatever reason St. Patricks Day does not work as a travel date for you, then ZT agrees to discuss changing the dates, given the cost center stays the same The cost cap for this trip is $5000 USD
ZeroTurnaround, 545 Boylston, 4th floor, Boston MA 02116
Contact Us