Skip to content

Instantly share code, notes, and snippets.

View serkodev's full-sized avatar
💭

SerKo serkodev

💭
View GitHub Profile
@serkodev
serkodev / StringMarcoLineBreak.m
Created November 5, 2018 10:53
Obj-C Line Break String
#define __line_break_string__(s) #s
NSString *str = @__line_break_string__(
foo
bar
hello\nworld
);
#undef __line_break_string__
/*
foo bar hello
//Credit: https://stackoverflow.com/questions/1793882/how-to-make-a-macro-that-can-take-a-string
#define STRINGIFY2(x) #x
#define STRINGIFY(x) STRINGIFY2(x)
#define PASTE2(a, b) a##b
#define PASTE(a, b) PASTE2(a, b)
#define PRINTTHIS(text) \
NSLog(PASTE(@, STRINGIFY(text)));
//Result
BOOL foo = YES;
id a = @(foo);
//className: __NSCFBoolean
id b = @(YES);
//className: __NSCFBoolean
id c = foo ? @(YES) : @(NO);
//className: __NSCFBoolean
@serkodev
serkodev / README.md
Created July 14, 2019 23:03 — forked from magnetikonline/README.md
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script to:

  • Iterate all commits made within a Git repository.
  • List every object at each commit.
@serkodev
serkodev / fetchTimeout.ts
Last active March 29, 2022 12:42
Typescript fetch with timeout
function fetchTimeout(url: string, init?: RequestInit, timeout = 5000): Promise<unknown> {
return Promise.race([
fetch(url, init),
new Promise((_, reject) => setTimeout(() => reject(), timeout))
]);
}
@serkodev
serkodev / master-group.js
Created April 5, 2022 20:13
Group selector of Master styles
// Author: SerKo (https://github.com/serkodev)
function group(cls, sel) {
return function parse(cls, sel) {
if (typeof cls == "string") {
return cls.split(/\s/).reduce((a, cur) => cur ? a.concat(cur + sel) : a, []);
} else if (typeof cls == "object") {
return cls.reduce((a, cur) => a.concat(...parse(cur, sel)), []);
} else return [];
}(cls, sel || "").join(" ");
@serkodev
serkodev / calculateAlpha.js
Created October 21, 2023 09:16
Calculate alpha from background color, source color and final color
function calculateAlpha(bgColor, srcColor, finalColor) {
// Convert a hex color to its rgb components
function hexToRgb(hex) {
const bigint = parseInt(hex.replace("#", ""), 16);
return {
r: (bigint >> 16) & 255,
g: (bigint >> 8) & 255,
b: bigint & 255,
};
}
@serkodev
serkodev / git-archive-all.sh
Last active December 14, 2023 18:03
Archive current folder to zip and ignore files from gitignore
# archive folder including uncommit files
git ls-files --others --exclude-standard --cached | zip --names-stdin archive.zip
@serkodev
serkodev / vue-language-tools-v3.2.md
Last active December 23, 2025 12:18
Vue Language Tools v3.2 Release Notes