Skip to content

Instantly share code, notes, and snippets.

View nikosolihin's full-sized avatar

Niko Solihin nikosolihin

  • Grand Rapids, MI
View GitHub Profile

Using JSDOC-Based TypeScript

Get Started

Choose your editor

  • WebStorm, Rider
    • Partial support, not enough intelli hints
    • Toggle on TypeScript language service
  • VSCode
@nikosolihin
nikosolihin / string-utils.js
Created June 17, 2021 16:15 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@nikosolihin
nikosolihin / gist.ts
Created November 19, 2020 03:23 — forked from mattpocock/gist.ts
const endpointToPromiseMap = {
[ApiEndpoint.FetchAllGoals]: fetchUserGoals,
[ApiEndpoint.CurrentUser]: currentUser,
};
type PromiseValue<T extends Promise<any>> = T extends Promise<infer U>
? U
: never;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@nikosolihin
nikosolihin / typescript-assets.ts
Created November 19, 2020 03:22 — forked from loilo/typescript-assets.ts
Some types I found useful during some tricky TypeScript programming
/*
* These are some types I found useful during some tricky TypeScript programming.
* Many of them are not too common or intuitive to come up with, this is why I'm writing them down here for future lookup.
*
* Note: Be careful when copy-pasting, some of these types depend on others.
*/
/**
* Various utilities for working with classes
@nikosolihin
nikosolihin / pipenv_cheat_sheet.md
Created July 23, 2019 02:24 — forked from bradtraversy/pipenv_cheat_sheet.md
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell
@nikosolihin
nikosolihin / list.py
Created July 19, 2019 03:52 — forked from RatulSaha/list.py
Useful List tricks in Python
#List traversal
range(start, stop, hop)
range(n) # [0,1,...,n-1]
range(1,n) # [1,...,n-1]
range(1,n,2) # [1,3,5,...,n-1] if n is even, or [1,3,5,...,n-2] if n is odd
range(n,-1,-1) # [n,n-1,n-2,...,0]
range(len(arr)) # Provides indices of an array arr
range(len(arr)-1,-1,-1) # Provides indices of arr backwards
# List slicing
@nikosolihin
nikosolihin / cpu.js
Created June 28, 2019 08:12 — forked from bag-man/cpu.js
How to calculate the current CPU load with Node.js; without using any external modules or OS specific calls.
var os = require("os");
//Create function to get CPU information
function cpuAverage() {
//Initialise sum of idle and time of cores and fetch CPU info
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
//Loop through CPU cores
const startDate =
location.state && location.state.startDate ? location.state.startDate : today
const prevStartRef = useRef(startDate)
let transitionDirection
if (prevStartRef.current !== startDate) {
transitionDirection = startDate < prevStartRef.current ? "earlier" : "later"
prevStartRef.current = startDate
}
@nikosolihin
nikosolihin / package.json
Created November 7, 2018 04:54 — forked from mburakerman/package.json
Webpack 4 config.js (SCSS to CSS and Babel) 👌 The Simplest Usage 👌
{
"name": "webpack-sass",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
@nikosolihin
nikosolihin / index.jsx
Created November 4, 2018 07:20 — forked from drcmda/index.jsx
react-spring with react-native
import React from 'react'
import { StyleSheet, Text, View, TouchableWithoutFeedback } from 'react-native'
import { Spring, animated } from 'react-spring/dist/native'
const styles = {
flex: 1,
margin: 0,
borderRadius: 35,
backgroundColor: 'red',
alignItems: 'center',