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 / nvidia_settings.py
Created May 8, 2020 12:14
NVIDIA X Server Settings - Presistance configuration python script
#!/usr/bin/python
from os import popen
def main():
# Retrieve information for current renderer hw
# it depends on `optimus-manager` package, you could download it on AUR.
current_renderer = popen(
"optimus-manager --print-mode").read().strip().split(":")[1].strip()
@KennFatt
KennFatt / terminal_size.cpp
Last active April 26, 2020 10:26
Terminal size using ncurses
#include <ncurses.h>
void onRender() {
while (1) {
mvprintw(0, 0, "Size: Cols(%d), Lines(%d)", COLS, LINES);
switch (getch()) {
case KEY_F(1): {
return;
};
@KennFatt
KennFatt / traverse_2d_array.cpp
Created April 14, 2020 08:46
PoC traversing 2d array by its _row_ is **MUCH** way better than the _column_ ones.
#include <cstdint>
int main() {
/**
* Debugger: LLDB on x86_64 machine
*
* Assume that address of `a` is located at: 0x00007fffffffecf0
* Then for each element:
* 1 -> 0x00007fffffffecf0
* 2 -> 0x00007fffffffecf0 + 2
@KennFatt
KennFatt / .clang-format
Last active March 20, 2020 17:23
C++ clang-format with my own code style!
---
BasedOnStyle: Chromium
AccessModifierOffset: '-4'
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignTrailingComments: 'false'
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'true'
@KennFatt
KennFatt / dijkstra.py
Last active March 12, 2020 09:03
Djikstra's algorithm implementation in Python
#
# Djikstra's algorithm: The shortest path
# @KennFatt
#
class Node(object):
def __init__(self, identifier):
self.__identifier = identifier
self.__adjacents = {}
@KennFatt
KennFatt / erase_png.php
Created January 4, 2020 05:17
Replace existing png image with nothing.
<?php
declare(strict_types=1);
function eraseImageContent(string $fileName) : void {
$baseImage = imagecreatefrompng($fileName);
$w = imagesx($baseImage);
$h = imagesy($baseImage);
imagedestroy($baseImage);
import java.util.Scanner;
import java.util.Date;
public class Laundry {
// Jenis laundry
private static final int JENIS_PAKAIAN = 0;
private static final int JENIS_TAS = 1;
private static final int JENIS_SEPATU = 2;
private static final int JENIS_KARPET = 3;
@KennFatt
KennFatt / msss_wmi_workaround.md
Last active November 18, 2019 08:26
Workaround for WMI Error message of MS SQL Server.

Workaround for WMI Error message while opening the MSSS Configurations.

mofcomp %programfiles(x86)%\Microsoft SQL Server\:number\Shared\sqlmgmproviderxpsp2up.mof

Change the :number with your version:

  • 90 : MS SS 2005
  • 100 : MS SS 2008
  • 100 : MS SS 2008 R2
<?php
declare(strict_types=1);
/**
* Copy all fonts file from path `types` to `temp`.
* This make me easier to install multiple fonts to the machine.
*/
/** @var $iterator \RecursiveIteratorIterator */
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("types"));
@KennFatt
KennFatt / TypeSize.pas
Last active October 24, 2019 07:11
Pascal ordinal type size
Program TypeSize;
Uses sysutils;
Var
a : Byte; // u8
b : ShortInt; // i8
c : SmallInt; // i16
d : Word; // u16
e : Integer; // i16 or i32 (compiler depends, fpc use i16 by default)