Skip to content

Instantly share code, notes, and snippets.

@fracek
fracek / CMakeLists.txt
Last active June 22, 2024 21:33
CMake and GTK+ 3
# Thanks to @danger89 and @Ilothar for updating the gist.
# Set the name and the supported language of the project
project(hello-world C CXX)
# Set the minimum version of cmake required to build this project
cmake_minimum_required(VERSION 3.10)
# Use the package PkgConfig to detect GTK+ headers/library files
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtkmm-3.0)
@cgoldberg
cgoldberg / camel.pl
Created December 18, 2012 21:26
Perl Camel code - render 4 ascii camels from camel-styled source code.
#!/usr/bin/perl -w # camel code
use strict;
$_='ev
al("seek\040D
ATA,0, 0;");foreach(1..3)
{<DATA>;}my @camel1hump;my$camel;
my$Camel ;while( <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary 1=split(//);if(defined($
_=<DATA>)){@camel1hum p=split(//);}while(@dromeda
/*
* Simple MD5 implementation
*
* Compile with: gcc -o md5 -O3 -lm md5.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
@akoskovacs
akoskovacs / MyList.hs
Last active September 3, 2023 09:46
A simple Haskell linked list implementation
module MyList where
data MyList a = Cons a (MyList a)
| MyNil deriving (Show, Eq)
{-
A simple linked list module
Some examples:
mylist = (Cons 10 (Cons 99 (Cons 11 (Cons 1 MyNil))))
myHead myList # => 10
myTail myList # => Cons 99 (Cons 11 (Cons 1 MyNil))
@barodeur
barodeur / main.c
Created March 19, 2013 12:32
libev example
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <ev.h>
#include <strings.h>
#define PORT_NO 3033
#define BUFFER_SIZE 1024
void accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents);
@rofl0r
rofl0r / init.c
Created August 6, 2013 21:15
minimal init daemon by rich felker, author of musl libc
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>
int main()
{
sigset_t set;
int status;
if (getpid() != 1) return 1;
@luser-dr00g
luser-dr00g / font_transform_test.c
Created September 23, 2014 07:55
testing FT_Set_Transform with FT_Render_Glyph and accessing advance vector
//make font_transform_test CFLAGS=`freetype-config --cflags ` LDLIBS=`freetype-config --libs` LDLIBS+=`pkg-config fontconfig --libs` LDLIBS+='-lm'
/*
* Xpost - a Level-2 Postscript interpreter
* Copyright (C) 2013, Michael Joshua Ryan
* Copyright (C) 2013, Vincent Torri
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@CallumDev
CallumDev / fontconfig.c
Created January 21, 2015 14:08
FontConfig sample in C
//compiled gcc fonttest.c -o fonttest -lfontconfig
//Sample output: /usr/share/fonts/steam-fonts/arial.ttf
#include <stdio.h>
#include <stdlib.h>
#include <fontconfig/fontconfig.h>
int main()
{
FcConfig* config = FcInitLoadConfigAndFonts();
//make pattern from font name
FcPattern* pat = FcNameParse((const FcChar8*)"Arial");
@def-
def- / mainpage.c
Created February 19, 2015 10:05
CSFML example
#include <SFML/Audio.h>
#include <SFML/Graphics.h>
int main()
{
sfVideoMode mode = {800, 600, 32};
sfRenderWindow* window;
sfTexture* texture;
sfSprite* sprite;
sfFont* font;
@dcat
dcat / xresource_test.c
Created June 2, 2015 00:01
Xresource example
/* $CC -o xresources_test xresources_test.c -lX11 */
#include <X11/Xresource.h>
#include <string.h>
#include <stdio.h>
#define XRESOURCE_LOAD_STRING(NAME, DST) \
XrmGetResource(db, NAME, "String", &type, &ret); \
if (ret.addr != NULL && !strncmp("String", type, 64)) \
DST = ret.addr;