Skip to content

Instantly share code, notes, and snippets.

View SufyanDahalan's full-sized avatar

Sufyan Dahalan SufyanDahalan

View GitHub Profile
@SufyanDahalan
SufyanDahalan / ExampleChildComponent.tsx
Last active March 7, 2025 11:29
Function for react that emitates the vue-slot behaviour.
import { ReactElement } from "react";
import deconstructChildren from "./deconstructChildren.ts";
export default function ChildComponent({ children = [] }: { children?: ReactElement[] }) {
let { TitleText, SubText } = deconstructChildren(children);
return (
<div>
{TitleText ? <h1>{TitleText}</h1> : <div>Fallback Text</div>}
<p>We want to use the two components in two different place in the code. They might be sepeterated by other components, or we might want to show some parts conditionally.</p>
<span>{SubText}</span>
@SufyanDahalan
SufyanDahalan / startProcess.go
Created April 29, 2023 01:14 — forked from lee8oi/startProcess.go
Using os.StartProcess() in Go for platform-independent system command execution.
package main
import (
"os"
"os/exec"
)
func Start(args ...string) (p *os.Process, err error) {
if args[0], err = exec.LookPath(args[0]); err == nil {
var procAttr os.ProcAttr