2unco

Code snippets, failed recipes and randings

Menu

Skip to content
  • Home
  • How to
  • Snippets

[OSX] Build and install PostgreSQL manually

Leave a reply
cd /usr/local/
tar -xvzf ~/Downloads/postgresql-9.2.3.tar
cd postgresql-9.2.3/
mkdir build_dir
cd build_dir/
../configure --prefix=`pwd`/../psql --with-libxml
# --with-libxml is optional, I only put it here to illustrate where you include libraries in the build
make
make install

Continue reading →

This entry was posted in How to and tagged Command Line, Environment, OSX, PostgreSQL on April 4, 2013 by 2unco.

[C] int to RGB

Leave a reply
// x is the (base16) integer you'd like to convert to RGB
int x = 0x9900cc;

int r, g, b;
r = (x >> 16) & 0xff;
g = (x >> 8) & 0xff;
b = x & 0xff;
// r, g and b now contain their respective colour values

Continue reading →

This entry was posted in Snippets and tagged C, Convert, Integer, RGB on March 23, 2013 by 2unco.

[C] int to char array

Leave a reply
// x is the (base10) integer you'd like to convert
int x = 555;

int size = x < 0 ? 3 : 2, tempX = x;
while((tempX = tempX / 10) != 0)
    size++;
char buf[size];

snprintf(buf, size, "%d", x);
// buf now tightly contains your converted integer

Continue reading →

This entry was posted in Snippets and tagged C, Convert, Integer, String on March 22, 2013 by 2unco.

Recent Posts

  • [OSX] Build and install PostgreSQL manually April 4, 2013
  • [C] int to RGB March 23, 2013
  • [C] int to char array March 22, 2013

Recent Comments

    Archives

    • April 2013
    • March 2013

    Categories

    • How to
    • Snippets

    Tags

    C Command Line Convert Environment Integer OSX PostgreSQL RGB String

    Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
    Proudly powered by WordPress