Skip to content

Instantly share code, notes, and snippets.

View carlos-jenkins's full-sized avatar

Carlos Jenkins carlos-jenkins

View GitHub Profile
@carlos-jenkins
carlos-jenkins / bytes.c
Created May 5, 2015 20:08
Bytes structure in C
// Bytes structure to handle the data pointer and size tuple together
// and using a single heap allocation
// gcc bytes.c -o bytes
// ./bytes
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef struct
@carlos-jenkins
carlos-jenkins / Makefile
Created March 26, 2015 18:47
Create a hierarchy of nodes using Graphviz and HTML
# Document variables
ENTRY = domains.html
PAGE_TPL = page.tpl
BUILDDIR = build
INPUTS = $(wildcard *.dot)
IMGS = $(INPUTS:%.dot=%.png)
BUILD_IMGS = $(addprefix $(BUILDDIR)/, $(IMGS))
HTML = $(INPUTS:%.dot=%.html)
BUILD_HTML = $(addprefix $(BUILDDIR)/, $(HTML))
@carlos-jenkins
carlos-jenkins / debug.py
Last active August 29, 2015 14:15
Python debug breakpoint
# -*- coding:utf-8 -*-
#
# When executed, this file shows to following behavior:
#
# $ python debug.py
# * Break: debug.py ::: Line 72
# * Continue with Ctrl+D...
# >>> a
# 10
# >>>
@carlos-jenkins
carlos-jenkins / fibonacci.py
Last active August 29, 2015 14:14
Different approaches to program the Fibonacci sequence algorithm.
# -*- coding:utf-8 -*-
# Different approaches to program the Fibonacci sequence algorithm.
#
# - Bottom-up stack recursion.
# - Top-down tail recursion.
# - Bottom-up iterative.
# - Bottom-up dynamic programming.
# - Top-down dynamic programming.
#
# For more information see:
from gi.repository import Gtk
from os.path import abspath, dirname, join
class MyApp(object):
def __init__(self):
"""
Build GUI
"""
@carlos-jenkins
carlos-jenkins / genetic_code.c
Last active August 29, 2015 14:07
Genetic code conversion routine implemented in constant time using a lookup table. It supports both DNA and mRNA sequences.
/*
* Copyright (C) 2014 Carlos Jenkins <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
@carlos-jenkins
carlos-jenkins / app.py
Created October 2, 2014 00:38
Example of using Font Awesome in a PyGObject application.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Carlos Jenkins <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@carlos-jenkins
carlos-jenkins / dialog.glade
Created August 23, 2014 01:33
PyGObject Dialog Example
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkDialog" id="dialog">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Entry Dialog</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
@carlos-jenkins
carlos-jenkins / app.py
Created February 11, 2014 21:41
Simple Gtk+ web browser using WebKit introspected bindings.
# -*- coding:utf-8 -*-
#
# Copyright (C) 2013 Carlos Jenkins <[email protected]>
#
# 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,
@carlos-jenkins
carlos-jenkins / app.py
Created February 10, 2014 22:42
Gtk+ 3.0 application theming using GResource. Compile using `glib-compile-resources gtktheme.gresource.xml`
# -*- coding:utf-8 -*-
#
# Copyright (C) 2013 Carlos Jenkins <[email protected]>
#
# 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,