Skip to content

Instantly share code, notes, and snippets.

View GerardKetuma's full-sized avatar
🎯
Focusing

Gerard Ketuma GerardKetuma

🎯
Focusing
View GitHub Profile
@GerardKetuma
GerardKetuma / node-create-post.js
Created September 30, 2021 20:20
Node script to create a new post template for my blog.
#! /usr/bin/env node
const fs = require('fs');
const slugify = require('slug');
const inquirer = require('inquirer');
const open = require('open');
const pkgDir = require('pkg-dir');
inquirer.registerPrompt('datetime', require('inquirer-datepicker-prompt'));
@GerardKetuma
GerardKetuma / typescript-generics.ts
Created February 28, 2020 19:51
Generics in TypeScript
// See blog post at https://ketuma.com/lessons/typescript-generics
// Generics
@GerardKetuma
GerardKetuma / typescript-functions.ts
Last active February 28, 2020 19:50
Functions in TypeScript
// See blog post at https://ketuma.com/lessons/typescript-functions
// Functions
// Fully Typed Function
const multiply: (str: string, num: number) => string = function(str: string, num: number): string {
return `${str} `.repeat(num).trim()
}
console.log(multiply('Jake', 3)) // Jake Jake Jake
@GerardKetuma
GerardKetuma / typescript-classes.ts
Last active February 26, 2020 18:43
Classes in TypeScript
// See blog post at https://ketuma.com/lessons/typescript-classes
//Classes
interface IMatrix {
width: number
height: number
content: string[]
dimensions: string
getElement(x: number, y: number): string
setElement(x: number, y: number, value: string): void
@GerardKetuma
GerardKetuma / typescript-interfaces.ts
Last active February 21, 2020 19:09
Interfaces in TypeScript
// See blog post at https://ketuma.com/lessons/typescript-interfaces
//Interfaces
interface Account {
name: string
amount: number
accountNumber: string
}
@GerardKetuma
GerardKetuma / typescript-basic-types.ts
Last active February 21, 2020 15:54
Basic types in TypeScript
// See blog post at https://ketuma.com/lessons/typescript-basic-types
//Boolean
const isOdd: boolean = true
const isEven: boolean = false
//Number
const fibonacci: number = 34 //decimal
const color: number = 0xbada55 //hexadecimal
const adder: number = 0b1011 //binary
@function em($target, $context: $base-font-size) {
@if $target == 0 { @return 0 }
@return $target / $context + 0em;
}
$base-font-size: 15px;
h1 {
font-size: em(21px, 15px); // Outputs 1.4em
}