Skip to content

Instantly share code, notes, and snippets.

Avatar

Velotio Technologies velotiotech

View GitHub Profile
View .c
#include <stdio.h>
char *openings[] = { "react", "c", "devops" };
char **vacancies = openings;
char ***velotio = &vacancies;
void main()
{
printf("%s\n",*++*velotio);
}
View .js
function ParentComponent() {
const [state, setState] = createSignal(0);
const stateVal = doSomeExpensiveStateCalculation(state()); // no need memoize explicity
createEffect(() => {
sendDataToServer(state());
}); // will only be fired if state changes - the effect is automatically added as a subscriber
return (
<div>
View .js
function ParentComponent() {
const [state, setState] = useState(0);
const stateVal = useMemo(() => {
return doSomeExpensiveStateCalculation(state);
}, [state]); // Explicitly memoize and make sure dependencies are accurate
useEffect(() => {
sendDataToServer(state);
}, [state]); // Explicilty call out subscription to state
View .js
createEffect(() => {
updateDataElswhere(state());
}); // effect only runs when `state` changes - an automatic subscription
View .js
const [state, setState] = useState(0);
// state -> value
// setState -> setter
const [signal, setSignal] = createSignal(0);
// signal -> getter
// setSignal -> setter
View .js
function ParentComponent() {
const [state, setState] = useState(0)
const stateVal = doSomeExpensiveStateCalculation(state()); // no need memoize explicity
createEffect(() => {
sendDataToServer(state())
}); // will only be fired if state changes - the effect is automatically added as a subscriber
return <div>
<ChildComponent stateVal={stateVal} />
</div>;
}
View .js
createEffect(() => {
updateDataElswhere(state())
}); // effect only runs when `state` changes - an automatic subscription
View .js
function ParentComponent() {
const [state, setState] = useState(0)
const stateVal = useMemo(() => {
return doSomeExpensiveStateCalculation(state)
}, [state]); // Explicitly memoize
useEffect(() => {
sendDataToServer(state)
}, [state]) // Explicilty call out subscription to state
return <div>
<ChildComponent stateVal={stateVal} />
View .js
const [state, setState] = useState(0);
// state -> value
// setState -> setter
const [signal, setSignal] = useSignal(0);
// signal -> getter
// setSignal -> setter
View .c
#include <stdio.h>
char *get_string() {
char str[] = "Hello, world!";
return str;
}
int main() {
char *s = get_string();
printf("%s\n", s);
return 0;
}