Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
nerding

Christophe VG christophevg

🤓
nerding
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am christophevg on github.
  • I am christophevg (https://keybase.io/christophevg) on keybase.
  • I have a public key ASAchSq6OMeHwqCkToGzHbZq1CQFLsNJDZxCg0p1hGMFhgo

To claim this, I am signing this object:

@christophevg
christophevg / hueToRGB.c
Created Dec 16, 2017
Function to convert a color to its Red, Green, and Blue components
View hueToRGB.c
// Courtesy http://www.instructables.com/id/How-to-Use-an-RGB-LED/?ALLSTEPS
// function to convert a color to its Red, Green, and Blue components.
void hueToRGB(uint8_t hue, uint8_t brightness, bool invert) {
uint16_t scaledHue = (hue * 6);
uint8_t segment = scaledHue / 256; // segment 0 to 5 around the
// color wheel
uint16_t segmentOffset =
scaledHue - (segment * 256); // position within the segment
@christophevg
christophevg / LinkedTreeViews.md
Last active Feb 16, 2017
Connecting nodes of two TreeViews using C#/WinForms
View LinkedTreeViews.md

This Gist is a combination a many different solutions found around the net. It shows how to create two TreeViews and visually connect two nodes in each of them.

Most "problems" are covered:

  • Invisible nodes (e.g. when collapsed or scrolled out of sight)
  • Back- and forth notifications of updates between TreeViews and parent Form
  • Two LinkedTreeViews are combined in LinkedTreeViews Panel
  • Drag and Drop support allows to create/remove links
View keybase.md

Keybase proof

I hereby claim:

  • I am ChristopheVG on github.
  • I am christophevg (https://keybase.io/christophevg) on keybase.
  • I have a public key whose fingerprint is F5EC FEB6 A1B8 0CB6 CFA7 FDE7 897E 3E40 AABF 2ECC

To claim this, I am signing this object:

@christophevg
christophevg / README.md
Last active Mar 16, 2016
State Machines for Dries
View README.md

State Machines for Dries

Three implementations:

  • demo_switch.c most basic, switch-based state machine
  • demo_functions.c a little nicer on the eye with functions as state handlers
  • demo_functions_results.c a more generic state machine framework with reconfigurable state transitions

Normal operation

@christophevg
christophevg / array_of_consecutive_numbers.c
Created Dec 9, 2014
How to create an array of consecutive numbers in C
View array_of_consecutive_numbers.c
#include <stdio.h> // for printf
#define START 123 // initial number to use to start sequence
#define MAX 5 // maximum number of items in the list
int main(void) {
// create list on the stack
int lst[MAX];
// fill list
@christophevg
christophevg / gist:61865cf042a68727a552
Created Nov 26, 2014
Illustration of Python generators
View gist:61865cf042a68727a552
# Illustration of Python generators
def count_down(size):
print "starting generation"
while size > 1:
print "yielding"
yield size
size -= 1
print "finishing generation"
yield size
@christophevg
christophevg / gist:789689
Created Jan 21, 2011
A QnD Solution to GeertVL's Homework ;-)
View gist:789689
// Part 1.
// Implement a function prototype extension that caches function results for
// the same input arguments of a function with one parameter.
//
// For example:
// Make sin(1) have the result of Math.sin(1), but use a cached value
// for future calls.
Function.prototype.withCaching = function withCaching() {
if( ! this.cache ) { this.cache = {}; } // lazy initialization of cache
You can’t perform that action at this time.