Skip to content

Instantly share code, notes, and snippets.

@khajavi
khajavi / builder.cpp
Created February 10, 2013 11:27 — forked from pazdera/builder.cpp
/*
* Example of `builder' design pattern.
* Copyright (C) 2011 Radek Pazdera
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@khajavi
khajavi / builder.cpp
Created February 10, 2013 11:28 — forked from pazdera/builder.cpp
/*
* Example of `builder' design pattern.
* Copyright (C) 2011 Radek Pazdera
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@khajavi
khajavi / adapter.cpp
Created February 26, 2013 06:35 — forked from pazdera/adapter.cpp
/*
* Example of `adapter' design pattern
* Copyright (C) 2011 Radek Pazdera
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
#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
*
#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>
// Written by Pioz.
// Compile with: gcc -o autoclick autoclick.c -lX11
#include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
// Simulate mouse click
void
click (Display *display, int button)
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kthread.h>
struct task_struct* ts;
static int thread_func(void)
{
while (1)
{