Skip to content

Instantly share code, notes, and snippets.

View insyri's full-sized avatar
🚴
...faster

insyri insyri

🚴
...faster
View GitHub Profile

Keybase proof

I hereby claim:

  • I am insyri on github.
  • I am insyri (https://keybase.io/insyri) on keybase.
  • I have a public key ASCV12hBIZMmF8msFsZBgc6JD-1F1Mho1zW0cfJ9X9ifLQo

To claim this, I am signing this object:

@insyri
insyri / cron.ts
Created May 12, 2022 15:48
attempt at making a type level cron validation, licensed under WTFPL, but reference me for inspiration somewhere
type Length<T extends any[]> = T extends {length: infer L} ? L: never;
type BuildTuple<L extends number, T extends any[] = []> = T extends {length: L} ? T: BuildTuple<L, [...T, any]>;
type Subtract<A extends number, B extends number> = BuildTuple<A> extends [...(infer U), ...BuildTuple<B>] ? Length<U> : never;
// prettier-ignore
type To59 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59;
// prettier-ignore
type To31 = Exclude<To59, 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59>
type To30 = Exclude<To31, 31>;
// prettier-ignore
-- use like this:
local err, res = parseToURLArgs()
-- thanks golang for this idea
function parseToURLArgs(tb)
function Err(err) return err, nil end
function Ok(res) return nil, res end
-- err checking
// There are two ways you can do this, the first being using a globals.d.ts file.
// Here, you would specify types like this..
// .d.ts
namespace NodeJS {
interface ProcessEnv {
SUPER_SECRET_TOKEN: string;
}
}
const commmands: Map<String, Function> = new Map();
commmands.set("help", () => console.log("This is the help command"));
const message = "/help".slice(1);
commmands.has(message)
? commmands.get(message)()
: console.log("Command not found");
// https://docs.microsoft.com/en-us/javascript/api/@azure/keyvault-certificates/requireatleastone
export type RequireAtLeastOne<T> = {
[K in keyof T]-?: Required<Pick<T, K>> &
Partial<Pick<T, Exclude<keyof T, K>>>;
}[keyof T];
export type ExampleOne = RequireAtLeastOne<{
optionOne: string;
optionTwo: string;
}>
@insyri
insyri / avid-lsq.md
Last active August 20, 2021 00:35
AVID Learning Style Questionnaire, shows what kind of learner you are.

Learning Style Questionnare

Directions:

Circle the response that best matches what you would do in the given situation.

When I listen to a class lecture...

  • a. I listen very closely.
  • b. I try to be close to the speaker and watch the speaker.
  • c. I take notes during the lecture.

I like to solve word problems by...

<!--This is a just that is literally a copypaste for connecting CSS and JS to your html page.-->
<link rel="stylesheet" type="text/css" href="file.css">
<script src="./file.js"></script>
function endSession(message, reason) {
var newembed = new Discord.MessageEmbed()
newembed.setDescription(`Session ended (${reason}).`)
newembed.setColor(0xd90479)
message.edit(newembed)
}
function completeSession(message, reason) {
var newembed = new Discord.MessageEmbed()
newembed.setDescription(reason)