Skip to content

Instantly share code, notes, and snippets.

View ScreamZ's full-sized avatar

Andréas Hanss ScreamZ

View GitHub Profile
const chalk = require("chalk").default;
// Fail after time
function ApiError(time, theme) {
return new Promise((_, reject) => {
setTimeout(() => {
reject("=> API call " + chalk.red("failed") + " with [" + chalk.blue(theme) + "] at " + time);
}, time);
});
}
/**
* Crawl through navigation state to get route metadata.
*
* @param {*} navigationState
* @returns {*}
*/
export function getActiveRouteMetadata(navigationState) {
if (!navigationState) {
return null;
}
import { Splashscreen } from "@images";
import AppLoader from "@modules/app/AppLoader";
import { LoadingProcess } from "@modules/app/types";
import AppNavigator from "@modules/navigation/AppNavigator";
import { CountrySelectionStatus } from "@modules/onboarding/types";
import _ from "lodash";
import React from "react";
import styled from "styled-components/native";
import { useFavoriteCountry } from "@modules/app/hooks/useFavoriteCountry";
import AsyncStorage from "@react-native-community/async-storage";
import to from "await-to-js";
import { useCallback, useEffect, useState } from "react";
enum CountrySelectionStatus {
Loading = "LOADING",
NotChosen = "NOT_CHOSEN",
Skipped = "SKIPPED",
}
import { every } from "lodash";
import React, { useEffect, useState } from "react";
interface LoadingProcess {
name: string;
isReady: boolean;
}
interface Props {
/**
@ScreamZ
ScreamZ / App.tsx
Last active September 16, 2019 12:01
A working Typescript configuration for styled-components and React Native
import React, { useRef } from "react";
import { ThemeProvider } from "styled-components/native";
import AppNavigator from "@modules/navigation/AppNavigator";
import { theme } from "@modules/ui/theme";
function App() {
return (
<ThemeProvider theme={theme}>
<AppNavigator />
@ScreamZ
ScreamZ / Analytics.tsx
Last active December 20, 2021 10:44
Axeptio React
import { Router } from "next/router";
import { useEffect } from "react";
import ReactGA from "react-ga";
const Analytics: React.FC = () => {
useEffect(() => {
ReactGA.initialize(process.env.ANALYTICS_ID!);
Router.events.on("routeChangeComplete", ReactGA.pageview);
// @ts-ignore
@ScreamZ
ScreamZ / example.html
Last active March 14, 2017 16:24
In-browser js spreadsheets generation library
<script>
$('#export').on('click', function () {
var tableContent = taffyData[0].content;
var excelSheetElements = {
name: 'My fees', // Name of the sheet (tabs)
data: tableContent.map(function (el) { // An array of array containing data (each element is a line)
return [el.date, el.label, el.amount]
})
};
@ScreamZ
ScreamZ / youtubeTrackingFR
Last active September 18, 2015 08:12
[FR] Youtube state tracking code for Google Tags Manager & Google Analytics
<script>
//enable the JavaScript API for an embedded player
for (var e = document.getElementsByTagName("iframe"), x = e.length; x--;)
if (/youtube.com\/embed/.test(e[x].src))
if(e[x].src.indexOf('enablejsapi=') === -1)
e[x].src += (e[x].src.indexOf('?') ===-1 ? '?':'&') + 'enablejsapi=1';
var gtmYTListeners = []; // support multiple players on the same page
// attach our YT listener once the API is loaded
function onYouTubeIframeAPIReady() {
@ScreamZ
ScreamZ / youtubeTracking
Last active August 29, 2015 14:24
[EN] Youtube state tracking code for Google Tags Manager & Google Analytics
<script>
//enable the JavaScript API for an embedded player
for (var e = document.getElementsByTagName("iframe"), x = e.length; x--;)
if (/youtube.com\/embed/.test(e[x].src))
if(e[x].src.indexOf('enablejsapi=') === -1)
e[x].src += (e[x].src.indexOf('?') ===-1 ? '?':'&') + 'enablejsapi=1';
var gtmYTListeners = []; // support multiple players on the same page
// attach our YT listener once the API is loaded
function onYouTubeIframeAPIReady() {