Skip to content

Instantly share code, notes, and snippets.

View cntrump's full-sized avatar
👀
Connecting...

cntrump

👀
Connecting...
View GitHub Profile
@cntrump
cntrump / hexcolor.swift
Created December 6, 2019 03:16
add CSS Hex Color support for UIColor with Swift
extension UIColor {
static func hex(_ val: UInt) -> UIColor {
var r: UInt = 0, g: UInt = 0, b: UInt = 0;
var a: UInt = 0xFF
var rgb = val
if (val & 0xFFFF0000) == 0 {
a = 0xF
if val & 0xF000 > 0 {
@cntrump
cntrump / chromastyles.sh
Created December 17, 2019 10:45
Export all chroma styles
#!/bin/zsh
styles=( \
abap \
algol \
algol_nu \
api \
arduino \
autumn \
borland \
bw \
@cntrump
cntrump / UIColor+Extension.h
Last active November 9, 2020 09:06
UIColor Extensions
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIColor (Extension)
+ (instancetype)colorWithRGB:(NSUInteger)value alpha:(CGFloat)alpha;
@end
@cntrump
cntrump / UIImage+Extension.h
Created November 9, 2020 09:05
UIImage Extensions
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIImage (Extension)
+ (instancetype)imageWithSize:(CGSize)size drawingHandler:(BOOL (^)(CGRect bounds))handler;
+ (instancetype)imageWithColor:(UIColor *)color;
@cntrump
cntrump / cl-fmt.sh
Last active April 7, 2021 13:35 — forked from leilee/cl-fmt.sh
clang-format files recursively
#!/usr/bin/env bash
set -e
# Variable that will hold the name of the clang-format command
FMT=""
# Some distros just call it clang-format. Others (e.g. Ubuntu) are insistent
# that the version number be part of the command. We prefer clang-format if
# that's present, otherwise we work backwards from highest version to lowest
@cntrump
cntrump / bcompare_patch.py
Last active November 25, 2023 07:27
Beyond Compare 4 Patcher
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import os
import sys
import platform
def useage():
print("useage: bcompare_patch.py /path/to/BCompare")
@cntrump
cntrump / str2hex.c
Last active May 10, 2022 08:05
Convert hex string to number.
int str2hex(char *str, int len) {
len = MIN(len, 8);
int hex = 0;
int bit = 0;
for (int i = len - 1; i >= 0; i--) {
int n;
char ch = str[i];
if (ch >= '0' && ch <= '9') {
n = ch - '0';
@cntrump
cntrump / office2016_retail_to_vol.bat
Last active May 10, 2022 11:01
Office 2016 Retail to VOL
@echo off
title Office2016 Retail to VOL
if exist "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles%\Microsoft Office\Office16"
if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles(x86)%\Microsoft Office\Office16"
cls
/*
* Copyright (c) 2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
@cntrump
cntrump / csv2html.py
Created July 27, 2022 11:05
CSV to HTML table
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pandas as pd
csv = pd.read_csv("codes.csv", engine = 'c')
csv.to_html("codes.html", index = False, justify='left')