This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from 'react'; | |
import { AppState } from 'react-native'; | |
/** | |
* Accepts a function that contains imperative, possibly effectful code. | |
* Same as useEffect but has not effect when app is in background | |
* | |
* If the depencies changes while being in background, the effect will be executed after the app is in foreground again | |
* | |
* @param {*} effect Imperative function that can return a cleanup function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name of the main target (= executable name) | |
TARGET = target_name | |
# Compiler command to use | |
CC = gcc | |
# Flags to add to the compiler command | |
CFLAGS = --std=c11 -g -Wall -Wextra -Wunused -pedantic -D_XOPEN_SOURCE=700 | |
# Ncurse specific flag | |
# LDFLAGS=-lncurses # UNCOMMENT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd $(git rev-parse --show-toplevel) | |
echo "Cleaning all make files" | |
make clean 2> /dev/null | |
for d in */ ; do | |
cd $d | |
make clean 2> /dev/null && echo "Cleaning $d" | |
cd .. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
headerFile="header.txt" | |
fileExt=".java" | |
red=`tput setaf 1` | |
green=`tput setaf 2` | |
cyan=`tput setaf 6` | |
yellow=`tput setaf 3` | |
reset=`tput sgr0` | |
function main () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package yourpackage; | |
import java.util.Scanner; | |
public class ScannerUtils { | |
/** | |
* Wait for the user to enter any string in the terminal | |
* | |
* @param prefix text prefix to display on the same line as the user input |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
interface Props { | |
someProp: string; | |
} | |
const ComponentName = (props: Props): JSX.Element => { | |
const { | |
someProp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { | |
createContext, useContext | |
} from 'react'; | |
interface MyContextProps { | |
attribute: unknown, | |
} | |
const MyContext = createContext<MyContextProps>({} as MyContextProps); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
/** | |
* Check is an HTML element is in the middle of the window | |
* @param ref The HTML element to check | |
* @param range The range in which that define the middle zone | |
* @returns true if the provided ref is in the middle of the window | |
*/ | |
export default const useOnMiddleOfScreen = (ref: React.RefObject<HTMLDivElement>, range: number): boolean => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface myInterface { | |
myValue: any, | |
} | |
// The variable for which we will need to check the type | |
let myVariable: any | myInterface; | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef } from 'react'; | |
const safeDocument: Document = document; | |
/** | |
* Usage: | |
* const [blockScroll, allowScroll] = useScrollBlock(); | |
*/ | |
export const useScrollBlock = (): [() => void, () => void] => { | |
const scrollBlocked = useRef(false); |