Skip to content

Instantly share code, notes, and snippets.

View arkag's full-sized avatar

Alexander Kagno arkag

  • Denver, CO, USA
View GitHub Profile
@arkag
arkag / mod_color.c
Last active September 6, 2018 22:42
Color mod_color(Color change, bool add, uint16_t modifier) {
uint16_t addlim = 359 - modifier;
uint16_t sublim = modifier;
uint16_t leftovers;
if (add) {
if (change.h <= addlim) {
change.h += modifier;
} else {
leftovers = modifier - (359 - change.h);
change.h = 0 + leftovers;
@arkag
arkag / flash.c
Last active September 4, 2018 01:16
Flashing, need help with turning into a function!
// This is working!!
void matrix_scan_user(void) {
if (flash && !flash_on_started && !flash_off_started) {
flash_start_timer = timer_read();
flash_on_started = true;
set_color(underglow, false);
} else if (flash && flash_on_started && !flash_off_started) {
uint16_t flash_timer = timer_read();
uint16_t elapsed = flash_timer - flash_start_timer;
if (elapsed >= LED_FLASH_DELAY) {
@arkag
arkag / gist:01d9fbb770f5bf1f269743d1cc202570
Created September 1, 2018 22:47
Error Code, Plover issue maybe?
lib/lufa/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c:38:
lib/lufa/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h:365:5: error: 'const' attribute on function returning 'void' [-Werror=attributes]
void CDC_Device_Event_Stub(void) ATTR_CONST;
^~~~
lib/lufa/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h:367:10: error: 'EVENT_CDC_Device_LineEncodingChanged' alias between functions of incompatible types 'void(USB_ClassInfo_CDC_Device_t * const)' {aka 'void(struct <anonymous> * const)'} and 'void(void)' [-Werror=attribute-alias]
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/lufa/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c:356:6: note: aliased declaration here
void CDC_Device_Event_Stub(void)
^~~~~~~~~~~~~~~~~~~~~
@arkag
arkag / set_os.c
Created August 31, 2018 19:10
Set OS function for QMK with update eeprom functionality
void set_os(OS type, bool update) {
userspace_config.curr_os = type;
underlight_color = HSV_COEFFICIENT * type;
switch (type) {
case OS_MAC:
set_unicode_input_mode(UC_OSX_RALT);
userspace_config.next_os = OS_WIN;
break;
case OS_WIN:
#include QMK_KEYBOARD_H
#define _BL 0
#define _FN1 1
#define _FN2 2
#define _FN3 3
#define _FN4 4
#define LEADER_TIMEOUT 750
#define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
2/keymaps/ark/keymap.c:42:6: error: function declaration isn't a prototype [-Werror=strict-prototypes]
void toggle_os() {
^~~~~~~~~
keyboards/mechmini/v2/keymaps/ark/keymap.c: In function 'process_record_keymap':
keyboards/mechmini/v2/keymaps/ark/keymap.c:178:9: error: case label value exceeds maximum value for type [-Werror]
case TOG_OS:
^~~~
keyboards/mechmini/v2/keymaps/ark/keymap.c:181:9: error: case label value exceeds maximum value for type [-Werror]
case M_PRI_MOD:
^~~~
@arkag
arkag / process_keymap.c
Created August 28, 2018 18:04
process_record_keymap function
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case TOG_OS:
is_mac = ! is_mac;
break;
case M_GUI_CTRL:
is_mac ? tap_key(KC_CTRL) : tap_key(KC_GUI);
break;
case M_CTRL_GUI:
is_mac ? tap_key(KC_GUI) : tap_key(KC_CTRL);
@arkag
arkag / snippet.c
Last active August 23, 2018 22:02
TapDance Macro for creating code snippets
void code_snippet(void) {
SEND_STRING("``````" SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT));
}
void short_snippet(void) {
SEND_STRING("``" SS_TAP(X_LEFT));
}
void dance_grv (qk_tap_dance_state_t *state, void *user_data) {
if (state->count == 1) {
@arkag
arkag / SimulateType.ps1
Created July 13, 2018 17:05
Simulates typing and backspacing on one line
function New-BackspaceLn {
[CmdletBinding()]
Param ([String]$Sentence)
$Backspaces = "`b" * $Sentence.Length
return "$Sentence$Backspaces"
}
function Write-HostSimType {
[CmdletBinding()]
@arkag
arkag / Bootstrap.ps1
Last active July 13, 2018 23:01
Install some basic applications and configurations for all machines.
[CmdletBinding(DefaultParameterSetName = 'Set1')]
Param(
[Parameter(Mandatory, ParameterSetName = 'Set1')]
# Currently doesn't support 365 silent installers
[ValidateSet('2016OL'<#,'365IM','365MS'#>)]
[String]$Office,
[Parameter(Mandatory, ParameterSetName = 'Set2')]
[Switch]$NoOffice,
[Parameter(Mandatory)]
[String]$Name,