Skip to content

Instantly share code, notes, and snippets.

View KennFatt's full-sized avatar
🌠
Stargazing

Kennan Fattahillah KennFatt

🌠
Stargazing
View GitHub Profile
@KennFatt
KennFatt / openinvscode.desktop
Created August 11, 2020 18:03
kservices5 context allows Dolphin to open specific file or folder directly to VSCode
# Original Author: https://store.kde.org/p/1202294/
#
# I made some modification due my filesystems and my code launch options kinda different.
# The code binary usually at /usr/bin/code
#
# Copy it into: ~/.local/share/kservices5/ServiceMenus
[Desktop Entry]
Name = Open in Code
Type=Service
@KennFatt
KennFatt / config.yml
Created August 5, 2020 09:13
spotify-tui configurations
behavior:
# Show loading when client try to communicate with Spotify API
# Hinting the upper right corner box
show_loading_indicator: false
# Volume increment by
volume_increment: 5
theme:
# Text
@KennFatt
KennFatt / Makefile-kennfatt
Last active August 1, 2020 18:00
My idiomatic Makefile (for a moment)
# Project name, it's depends on current directory basename.
PROJECT_NAME = $(shell basename $(PWD))
# C++ Compiler
CC = clang++
# Compile flags
CFLAGS = -Wall -std=c++17
# Static libs
CLIBS = -lsfml-window -lsfml-graphics -lsfml-system
@KennFatt
KennFatt / generic_function.rs
Created July 23, 2020 16:41
Generic function that will return a type based on the annotations.
#[derive(Debug)]
struct MyError(String);
trait Poke {
fn aw();
}
struct Lovely;
impl Poke for Lovely {
@KennFatt
KennFatt / README.md
Last active July 17, 2020 15:37
Firefox but just a container

Run a firefox profile with just an actual page and titlebar.

Enable this setting on your about:config:

toolkit.legacyUserProfileCustomizations.stylesheets: true

Then, add new folder chrome inside your profile directory and create new userChrome.css file.

@KennFatt
KennFatt / app.js
Created July 9, 2020 06:48
Asynchronous Programming with javascript
/**
* Asynchronous programming concept.
*
* Please comment one of the methods available!
*/
const GIPHY_API = "http://api.giphy.com/v1/gifs/search?api_key={YOUR_GIPHY_API_KEY}&q=";
const WORDS_API = "https://random-word-api.herokuapp.com/word?number=1&swear=0";
@KennFatt
KennFatt / kennfatt_convex_hull.cc
Created June 11, 2020 19:58
Convex Hull - Graham Scan algorithm implementation in C++17
#include <iostream>
#include <stack>
#include <stdlib.h>
struct Point {
int x, y;
Point() = delete;
Point(int _x, int _y) : x(_x), y(_y) {}
@KennFatt
KennFatt / orientation_of_3_ordered_pts.cc
Created June 11, 2020 17:06
Find the orientation of given 3 point. The formula basically is derived from Vector cross product.
#include <iostream>
struct Point {
int x;
int y;
};
/**
* Assume we have 3 points A, B, and C.
* Vector V is from A -> B or AB.
@KennFatt
KennFatt / logitech_g102.c
Created May 28, 2020 04:53
libusb 1.0 implementation with C language. It is used to write the instruction to change Mouse Logitech G102/G203 RGB color.
#include <libusb-1.0/libusb.h>
#include <stdio.h>
#include <stdlib.h>
#define VID 0x046d
#define PRID 0xc084
/**
* Sending solid RGB color bytes to Logitech G102 / G203.
* LIBRARY: -lusb-1.0
@KennFatt
KennFatt / hex2bin.c
Created May 22, 2020 11:28
Convert hex string to byte array
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
const char raw_payload[] = "11ff0e3b0001ff00ff0000000000";
const char *pos = raw_payload;
unsigned char payload[14];
size_t cnt = 0;
for (; cnt < sizeof(payload) / sizeof(payload[0]); ++cnt) {