Skip to content

Instantly share code, notes, and snippets.

@khajavi
khajavi / create_png_image.c
Last active December 16, 2015 08:48
Hello World in Cairo
/*
* adopted from http://zetcode.com/gfx/cairo/cairobackends/
*/
#include <cairo.h>
int main() {
cairo_surface_t* surface;
cairo_t* cr;
@khajavi
khajavi / pdfviewer.c
Created April 20, 2013 05:47
pdf viewer by poppler library
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <cairo.h>
#include <poppler.h>
/* gcc `pkg-config --cflags --libs gtk+-2.0 poppler-glib` -o pdfviewer pdfviewer.c */
@khajavi
khajavi / my_first_gdk_app.c
Created April 20, 2013 08:11
My first app in GDK library
/*
* Adopted from http://james.id.au/tech/doc/gdk/
* gcc -o my_first_gdk_app.bin my_first_gdk_app.c `pkg-config gtk+-2.0 --cflags --libs`
* The GDK headers. Very important.
*/
#include <gdk/gdk.h>
/* Convenient way to suck in all the glib stuff.
*/
#include <glib.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <glib/gprintf.h>
#include <string.h>
/*
*
* Colorpicker. That's all.
*
/*
* Print entire HTML text after processed JavaScript
*
* build:
* FLAGS=`pkg-config --cflags --libs gtk+-x11-2.0 glib-2.0 webkit-1.0`
* gcc -Wall $FLAGS getbodytext.c -o getbodytext
*
* usage:
* /usr/bin/xvfb-run ./getbodytext test.html
*
@khajavi
khajavi / gdk_initialization_and_exit.c
Created April 20, 2013 09:48
GDK initialization and exit
#include <gdk/gdk.h>
int main( int argc, char* argv[] ) {
gdk_init( &argc, &argv );
gdk_exit( 0 );
return 0;
}
@khajavi
khajavi / window_with_a_little_black_sqaure_in_it.c
Created April 20, 2013 10:50
Hello World by Xlib library
/*
* Simple Xlib application drawing a box in a window.
* gcc input.c -o output -lX11
* Adopted from http://en.wikipedia.org/wiki/Xlib
*/
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <iostream>
#include <unistd.h>
int main(void) {
Display* dpy = XOpenDisplay(0);
int scr = XDefaultScreen(dpy);
Window root_window = XRootWindow(dpy, scr);
int height = DisplayHeight(dpy, scr);
@khajavi
khajavi / paste.cc
Created April 20, 2013 11:06 — forked from bmeck/paste.cc
// CODE
/* test.cc
* Compile with: g++ `pkg-config --cflags --libs x11` test.cc -o test
* Run with: ./test
*/
#include <stdio.h>//printf
#include <string.h>//strlen
#include <stdlib.h>//atexit
// g++ font_path_list.cxx $(pkg-config x11 --libs --cflags)
#include <X11/Xlib.h>
#include <cassert>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <iterator>