Skip to content

Instantly share code, notes, and snippets.

View Ketcap's full-sized avatar
🏠
Working from home

Uğur Oruç Ketcap

🏠
Working from home
View GitHub Profile
@ChronSyn
ChronSyn / CustomText.tsx
Last active May 8, 2020 00:16
CustomText componnent for Expo - loads any google font
import * as React from "react";
import RN, { Text, TextProps } from "react-native";
import { Asset } from 'expo-asset';
import { useFonts } from '@use-expo/font';
import * as fonts from "@expo-google-fonts/dev";
enum FontDisplay {
AUTO = "auto",
SWAP = "swap",
@Atinux
Atinux / async-foreach.js
Last active October 10, 2023 03:04
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@miguelmota
miguelmota / randomDate.js
Last active December 21, 2022 16:27
Random date in JavaScript
function randomDate(start, end) {
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()))
}
console.log(randomDate(new Date(2012, 0, 1), new Date()))