Skip to content

Instantly share code, notes, and snippets.

@chadrehm
chadrehm / filecopy.c
Last active March 13, 2021 19:18
C program to learn posix function. Copy a file.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
@chadrehm
chadrehm / tm_1.txt
Created January 29, 2021 16:54
Turing Machine test files
q1
qAccept
qReject
0,1
q1 (0,x,R) q2
q1 (1,x,R) q3
q1 (#,#,R) q8
q2 (0,0,R) q2
q2 (1,1,R) q2
q2 (#,#,R) q4
@chadrehm
chadrehm / ScrollToTopArrow.js
Created November 6, 2020 16:38
ScrollToTopArrow
export const ScrollTopArrowComponent = () => {
// Track whether the scroll arrow is needed.
const [showScroll, setShowScroll] = useState(null);
// Check the scroll state, re-memoize when scroll state changes.
const checkScrollTop = useCallback(
() => {
const headerHeight = 400;
if (!showScroll && window.pageYOffset > headerHeight) {
setShowScroll(true);