Skip to content

Instantly share code, notes, and snippets.

View marvinkome's full-sized avatar
🧪
Cooking

Marvin Kome marvinkome

🧪
Cooking
View GitHub Profile
import axios, { AxiosInstance, AxiosResponse } from 'axios'
// -----------------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------------
const TOKEN_EXPIRY = {
ACCESS_TOKEN: 1800,
REFRESH_TOKEN: 2592000,
} as const
import fs from "fs/promises";
import path from "path";
import { env } from "@/libs/env/server";
import { AppStoreServerAPIClient, Environment, SignedDataVerifier } from "@apple/app-store-server-library";
const loadRootCertificate = async () => {
const certificatesDirectory = path.join(process.cwd(), "./apple-root-certificates");
return Promise.all([
fs.readFile(path.join(certificatesDirectory, "./cert-1.cer")),
@marvinkome
marvinkome / api.js
Last active February 27, 2023 14:44
NextAPI - Template
const LOG_TAG = "";
export default function handle(req, res) {
try {
const { method, body, query } = req;
switch (method) {
case "GET": {
@marvinkome
marvinkome / refetchPageData.js
Last active October 17, 2022 12:09
nextjs refetch page data
import Router from "next/router";
// How to refresh server data without reloading the page
// https://www.joshwcomeau.com/nextjs/refreshing-server-side-props/
// https://twitter.com/flybayer/status/1333081016995622914
export function refetchPageData(path: string) {
return new Promise<void>((res, rej) => {
Router.events.on("routeChangeComplete", () => {
res();
function addUpPrimes(n) {
// using the seive of Eratosthenes get all primes
const list = [];
for (let i = 2; i <= n; i++) {
list[i] = { index: i, value: true };
}
// our limit
const limit = Math.sqrt(n);
// Import Modules
import numeral from 'numeral';
import fetch from 'isomorphic-fetch';
const cc = require('cryptocompare');
// Fetch currency functions
const get_currency = async (currency, url) => {
// Helper function that gets currency quantity and formats the result
try {
const response = await fetch(url);
/**
* ./src/components/post/view/topbar
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import { logoutUser } from '../../js/redux/actions';
import img from '../../img/default-pic.png';