2of1
half a nibble of another

Home
Projects
About
Aug

27

Arduino library for 7-segment displays

Filed Under (Arduino, Coding, Hardware, Open source) by 2of1 on 27-08-2010

Seg7 is a simple library for control of 7-segment displays using the Arduino (or any compatible clone of course).
Read the rest of this entry »

(6) Comments
Read More
Aug

23

Cross-compiling a Qt win32 app on Linux

Filed Under (Coding, Compilers, Linux, Open source) by 2of1 on 23-08-2010

I’ve been looking for a way to compile an app developed with Qt Creator on Linux for Windows.

I came across this but I needed to tweak it before it worked so I decided to blog my own mini-guide (tested working with with Qt 4.6.3).

This assumes that you already have the Qt SDK (for Linux) installed.

  1. The first thing to do is download and install the MinGW cross compiler
  2. Then download the Windows version of the Qt SDK. As it’s distributed as a Win package, you’ll need to either install it on windows and copy the necessary files across to your linux distro (what I did) or install it through Wine (not sure if this even works). You can cross-compile it as well if you’re being adventurous
  3. Place the Qt Win SDK libraries in /usr/lib32/qt4win32 and headers in /usr/include/qt4win32
  4. Copy /usr/share/qt4/mkspecs/win32-g++/ to /usr/share/qt4/win32-x-g++/
  5. In the above directory, replace qmake.conf with the one found here
  6. Make sure that the paths in qmake.conf match those of your system (see NOTE below); specifically QMAKE_CXX, QMAKE_LINK, QMAKE_INCDIR, QMAKE_INCDIR_QT, QMAKE_LIBDIR_QT
  7. Run qmake adding –spec win32-x-g++ command line arg. This should cross-compile your app.

NOTE: As my linux box is a x86_64, my /usr/lib is /usr/lib32. Please adjust this accordingly for your setup.

(2) Comments
Read More
Aug

17

Random value with limits in C

Filed Under (C, Coding) by 2of1 on 17-08-2010

There’s a quick and effective way of producing a random value in C if you only require it at most once per second using current time as a random seed:

#include <time.h>     // time_t, time()
#include <stdlib.h>   // srand(), rand()
 
time_t s;
time(&s);
srand((unsigned int)s);
 
// calc random value (limits are inclusive)
int rand_val = 1 + (int)((float)UPPER_LIMIT * 
               (rand() / (RAND_MAX + (float)LOWER_LIMIT)));

Of course reading from /dev/urandom is good too :) (on linux).

(2) Comments
Read More
Aug

17

Optimised vncviewer settings

Filed Under (Linux, Tips & tricks, VNC) by 2of1 on 17-08-2010

Run through a compresses ssh tunnel, e.g.:

ssh user@dest -L 5900:localhost:5900 -C

Optimal vncviewer command line params:

vncviewer -encodings "copyrect tight hextile zlib corre rre raw"
No Comments
Read More
Aug

16

Sqlite: Listing tables in the database

Filed Under (Coding, Sqlite) by 2of1 on 16-08-2010

There’s a special command to do this:

.tables
No Comments
Read More
Aug

05

Git: Doing an update without committing local changes

Filed Under (Coding, Git, Version control) by 2of1 on 05-08-2010

git stash
git pull --rebase
git stash apply
No Comments
Read More
Aug

03

Git: Squashing commits

Filed Under (Coding, Git, Version control) by 2of1 on 03-08-2010

Sometimes it’s useful to ’squash’ commit; in essence merging them into a single commit.

This can be done using the interactive mode of rebase:

git rebase -i origin

The commits can then be change from pick to either squash or fixup (squash that discards commit’s log message).

The order of the commits can be changed as well, so for example:

pick ea4f69f DVB: Increased signal timeout times
pick d58bac8 DVB access module format improvements
pick 5461a01 DVB-S scanning support
pick 1a5a61a DVB channel search dialog now shows ETA
pick 351bcd2 small syntax fix

Say I want to squash 351bcd2 into 5461a01 and discard the log message, I simply change it as follows:

pick ea4f69f DVB: Increased signal timeout times
pick d58bac8 DVB access module format improvements
pick 5461a01 DVB-S scanning support
fixup 351bcd2 small syntax fix
pick 1a5a61a DVB channel search dialog now shows ETA
No Comments
Read More
Aug

03

Git: Undoing a rebase (reflog)

Filed Under (Coding, Git, Version control) by 2of1 on 03-08-2010

The easiest way to undo a rebase is to find the relevant commit as it was immediately before the rebase using git reflog.

You can then reset to that commit; e.g.:

git reset --hard HEAD@{50}
No Comments
Read More
Aug

03

VLC DVB improvements

Filed Under (Apps, Coding, Open source, VLC) by 2of1 on 03-08-2010

I’m hoping to improve DVB support in VLC over the next few months.
Read the rest of this entry »

No Comments
Read More
Aug

02

Git: Revert uncommitted changes

Filed Under (Coding, Git, Version control) by 2of1 on 02-08-2010

All uncommitted changes:

git reset --hard

Specific uncommitted changes:

git checkout <file(s)>
No Comments
Read More
« Older Entries
  • Recent Posts

    • ARM long branch
    • Mini-Namco #3: (Almost) Finished
    • Mini-Namco #2: Unit construction
    • Mini-Namco #1: Design
    • Simple C hashtable code
  • Archives

    • January 2012
    • September 2011
    • August 2011
    • July 2011
    • May 2011
    • March 2011
    • February 2011
    • January 2011
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
  • GitHub

    • code
    • d2d1headers
    • locateme
    • findjerusalem
    • seg7
    • userspace-krb
    • libgmail
    • preloader
    • linhook
  • qrcode

  • Site Search

  • Categories

    • Apps (7)
      • Preloader (1)
      • Symbian S60 (1)
      • VLC (4)
      • Wordpress (1)
    • Coding (28)
      • Assembly (1)
        • ARM (1)
      • C (12)
      • Compilers (5)
      • Direct2D API (4)
      • Linux kernel (2)
      • Networking (4)
      • Python (1)
      • Sqlite (1)
      • Version control (5)
        • Git (5)
    • Hacking (4)
      • Code injection (1)
      • Reverse engineering (3)
    • Hardware (4)
      • Arduino (1)
      • PCBs (3)
    • Linux (21)
      • Bash (1)
      • Tips & tricks (13)
      • Virtualization (1)
      • VNC (2)
      • Xmonad (1)
    • Open source (30)
    • Other stuffs (3)
    • Social (3)
      • DC9723 (2)
  • OctoFinderProgramming Blogs - Blog Catalog Blog Directory

    Locations of visitors to this page

© 2of1.