This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gi.repository import Gtk | |
from os.path import abspath, dirname, join | |
class MyApp(object): | |
def __init__(self): | |
""" | |
Build GUI | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 | |
# >>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of a memory mapped register structure: | |
// | |
// gcc register.c -o register | |
// ./register | |
// | |
// This assumes register size is 8bits. | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
// | |
// Define a thing to store in sections | |
// | |
struct mything { | |
const char* name; | |
int num; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
# | |
# Copyright (C) 2015 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_digits_optimized(num): | |
""" | |
Recursively sum al digits of a number until result is one digit. | |
Optimized version using simple integer logic. | |
:param int num: Number to sum all it's digits. | |
:rtype: int | |
:return: The recusive sum of all digits. | |
""" | |
result = 0 |