Skip to content

Instantly share code, notes, and snippets.

View cjgajard's full-sized avatar
😸
にゃあ

Carlos Gajardo cjgajard

😸
にゃあ
  • Santiago de Chile
View GitHub Profile
@cjgajard
cjgajard / example.c
Created September 18, 2020 09:47
Template for command line with ncurses in C
#include <ctype.h>
#include <curses.h>
#include <locale.h>
#include <string.h>
#include <time.h>
#define CTRL(c) ((c) & 0x1f)
#define FPS 30
static int columns = 80;
@cjgajard
cjgajard / lch.c
Created September 4, 2020 22:18
Conversion algorithm from LCH(ab) to RGB.
/*
* Conversion algorithm from LCH(ab) to RGB. Following the directives from w3.
* https://www.w3.org/TR/css-color-4/#lab-to-rgb
*
* Tags: luma,chroma,hue,lab,lch,cielab,c,windows,win10
* Author: Carlos Gajardo (github.com/cjgajard).
* Date: 2020-09-04
*/
#define _USE_MATH_DEFINES
#include <math.h>
@cjgajard
cjgajard / swapkeys.c
Created March 24, 2020 23:43
Proof of concept for my symmetrical keyboard.
/*
* Based on https://renenyffenegger.ch/notes/Windows/tools/swap-keys_c
* This code uses Windows' hooks to catch and redirect input.
* This code is not yet tested for DLL compilation.
*/
#include <stdio.h>
#ifdef __CYGWIN__ // 2017-07-18 (tsettgchabe)
#define _WIN32_WINNT 0x0500 /* 0x0404 */
#endif
#include <windows.h>
@cjgajard
cjgajard / hover-class.directive.ts
Last active March 20, 2017 21:06 — forked from TigorC/hover-class.directive.ts
Angular 2 hover class directive ES6
import { Directive, ElementRef, Renderer } from '@angular/core';
/*
* Adds a class to a DOM element when the mouse is over its box (:hover).
* This DOESN'T support adding multiple classes separated by spaces.
* Usage:
* <button class="btn" hoverClass="btn-success">
*/
const HoverClassDirective = class {
constructor(elementRef, renderer) {
@cjgajard
cjgajard / app.cr
Last active September 12, 2019 08:20
Kemal controllers pattern
# src/{{app_name}}.cr
require "kemal"
require "./controllers/*"
alias Env = HTTP::Server::Context # this could be provided by Kemal
module Main
get "/", &->index(Env)
get "/:name", &->greet(Env)
end