Skip to content

Instantly share code, notes, and snippets.

View x1unix's full-sized avatar
:shipit:
Work in progress

Denys Sedchenko x1unix

:shipit:
Work in progress
View GitHub Profile
@x1unix
x1unix / sysconf_dump.c
Last active July 18, 2022 09:49
sysconf_dump - Dump sysconf() values
#include <stdio.h>
#include <unistd.h>
#include <sys/sysctl.h>
#include <string.h>
#define SC_OPT(KEY) { .id = KEY, .label = #KEY }
typedef struct sc_opt {
int id;
char* label;
@x1unix
x1unix / app.swift
Created July 1, 2022 12:14
Swift Playgorund window
import AppKit
import PlaygroundSupport
import SwiftUI
@objc protocol _NSWindow {
var title: String? { get set }
var styleMask: UInt { get set }
func setFrame(_ frameRect: NSRect, display flag: Bool)
func center()
func makeKeyAndOrderFront(_ sender: Any?)
@x1unix
x1unix / codes.json
Created June 27, 2022 21:32
HTTP Status Codes
[
{
"code": "100",
"phrase": "Continue",
"type": "Continue"
},
{
"code": "101",
"phrase": "Switching Protocols",
"type": "SwitchingProtocols"
@x1unix
x1unix / gfcommit.py
Created June 21, 2022 21:20
Git flow commit message generator
#!/usr/bin/env python3
# brew install pygit2
# pip3 install pygit2
from pygit2 import Repository
import sys
import re
regex = r"^([a-z]{1,5})/([A-Z]{1,5}-[0-9]{1,4})"
@x1unix
x1unix / aptx.md
Created April 6, 2022 20:12
macOS | Enable AptX
  1. Launch Terminal on Mac.

  2. To enable aptX, type in the following command:

sudo defaults write bluetoothaudiod "Enable AptX codec" -bool true
  1. To enable AAC, type the following:
@x1unix
x1unix / ip.sh
Created April 3, 2022 23:59
Get public IP from terminal
curl -i https://cloudflare.com/cdn-cgi/trace | grep ip | awk -F'=' '{print $2}'
@x1unix
x1unix / state.ts
Created December 25, 2021 19:56
React - Partial state update
import React from "react";
/**
* Performs partial object update
* @param obj
* @param value
* @param path
*/
export function partialUpdateObject<T=any>(obj: T, value: any, path: string[]): T {
const key = path.pop();
@x1unix
x1unix / nvidia-remove.sh
Last active December 15, 2021 18:33
Linux - disable NVIDIA GPU
#!/bin/env bash
# nvidia-remove - Disables NVIDIA GPU
#
# See: http://us.download.nvidia.com/XFree86/Linux-x86_64/455.45.01/README/dynamicpowermanagement.html
# Root user ID
ROOT_UID=0
# NVIDIA PCI Vendor ID
NV_PCI_VENDOR_ID='0x10de'
@x1unix
x1unix / README.md
Last active December 2, 2021 19:44
Better console log formatter for Winston

About

This is a logrus-like improved CLI formatter for Winston.

Formatter supports labels and errors prerry print (from error field).

Output example

image