Skip to main content

Posts

C++ - Print Size of Fundamental Types

  #include <iostream> using namespace std; int main() { cout << "sizeof(char) is " << sizeof(char) << " bytes " << endl; cout << "sizeof(short) is " << sizeof(short) << " bytes " << endl; cout << "sizeof(int) is " << sizeof(int) << " bytes " << endl; cout << "sizeof(long) is " << sizeof(long) << " bytes " << endl; cout << "sizeof(float) is " << sizeof(float) << " bytes " << endl; cout << "sizeof(double) is " << sizeof(double) << " bytes " << endl; cout << "sizeof(bool) is " << sizeof(bool) << " bytes " << endl; return 0; }
Recent posts

C++ assert.h

  #include #include int test_assert(int x) { assert(x <= 4); return x; } int main() { int i; for (i=0; i<=9; i++) { test_assert(i); printf("i = %d\n", i); } return 0; }

Simple Ubuntu install script

  #!/bin/sh # update & upgrade # sudo apt-get update sudo apt-get upgrade # add custom sources and PPA's # sudo sh -c "echo '## PPA ###' >> /etc/apt/sources.list" # ubuntuzilla sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C1289A29 sudo sh -c "echo 'deb http://downloads.sourceforge.net/project/ubuntuzilla/mozilla/apt all main #Ubuntuzilla' >>/etc/apt/sources.list" # vlc sudo add-apt-repository ppa:c-korn/vlc # getdeb wget -q -O- http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add - sudo sh -c "echo 'deb http://archive.getdeb.net/ubuntu karmic-getdeb apps #getdeb' >> /etc/apt/sources.list" # medibuntu echo deb http://packages.medibuntu.org/ karmic free non-free | sudo tee -a /etc/apt/sources.list wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add - # update & upgrade # sudo apt-get update sudo apt-get upgrade # REMOVE some unneeded apps # sudo

Java - Move cursor position (Any System)

import java.awt.Robot; import java.util.Random; public class MouseMover { public static final int FIVE_SECONDS = 5000; public static final int MAX_Y = 400; public static final int MAX_X = 400; public static void main(String... args) throws Exception { Robot robot = new Robot(); Random random = new Random(); while (true) { robot.mouseMove(random.nextInt(MAX_X), random.nextInt(MAX_Y)); Thread.sleep(FIVE_SECONDS); } } }