Skip to content

Instantly share code, notes, and snippets.

View arcdev1's full-sized avatar

Bill Sourour arcdev1

  • Arcnovus
  • Ottawa, Canada
View GitHub Profile
import {
Form,
FormGroup,
TextInput,
SubmitButton,
DefaultTemplate,
} from "@arcnovus/wet-boew-react";
import { MultiCheckboxSelect } from "../../components/MultiCheckboxSelect";
export default function FormExample() {
@arcdev1
arcdev1 / register-wet-component.ts
Last active June 24, 2021 17:38
Register WET Component
/**
* Lets WET-BOEW know about a new component that was added to the page so that
* WET-BOEW can apply the WET-BOEW JavaScript to it.
*
* @param {string} selector an HTML selector, usually the class
* name prefixed with a period.
*/
async function registerWbComponent(selector: string): Promise<void> {
if (typeof window !== "undefined") {
const wet: WetBoew = (window as any).wb as WetBoew;
@arcdev1
arcdev1 / NonEmptyString.ts
Last active April 11, 2021 20:20
FP-Value Object in TypeScript
‎‎​
@arcdev1
arcdev1 / machine.js
Last active November 26, 2019 19:17
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@arcdev1
arcdev1 / machine.js
Created November 25, 2019 06:16
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@arcdev1
arcdev1 / use-ck-editor.js
Last active March 10, 2023 16:33
A custom React Hook for using CKEditor with SSR particularly with NextJS. https://ckeditor.com | https://nextjs.org
// A custom React Hook for using CKEditor with SSR
// particularly with NextJS.
// https://ckeditor.com | https://nextjs.org
import React, { useRef, useState, useEffect } from 'react'
export default function useCKEditor () {
const editorRef = useRef()
const [isEditorLoaded, setIsEditorLoaded] = useState(false)
const { CKEditor, InlineEditor } = editorRef.current || {}
'use strict'; // avoid ambiguity and sloppy errors
/**
* Tests whether or not a given string is a Palindrome
* @param {string} stringToTest - the string to test.
*/
function isPalindrome(stringToTest) {
if (typeof stringToTest !== "string") {
throw new TypeError("isPalindrome() expected a string, but got " +
Object.prototype.toString.call(stringToTest) + " instead!");
function requiredParam (param) {
const requiredParamError = new Error(
`Required parameter, "${param}" is missing.`
)
// preserve original stack trace
if (typeof Error.captureStackTrace === ‘function’) {
Error.captureStackTrace(
requiredParamError,
requiredParam
)
var s = "some_string_to_change",
result = s.replace(/_./g, rep); // do a global search (g) for an "_" followed by a single character (.) and run the rep function each time
function rep(v) {
return v[1].toUpperCase(); // return the second character of the matched string, uppercased.
}
console.log(result);
var s = "some_string_to_change",
a = s.split("_"), // this gives us 4 strings and removes the underscore
result = a[0]; // this adds the first string to our result
for(i=1;i<a.length;i++) { // loop through each string
result+= a[i][0].toUpperCase(); // append the uppercase first letter of the string
result+= a[i].substring(1); // append the rest of the string
}
console.log(result); // log the result to the console