Skip to content

Instantly share code, notes, and snippets.

@thibaut-d
thibaut-d / clean_corpus.R
Created January 14, 2022 22:21
Data cleaning function in R
clean_corpus = function(x){
# Replace redundant white spaces and line jumps such as \n
x = replace_white(x)
# Replace or remove non ASCII characters
x = replace_non_ascii(x)
# Replace contractions such as "you're" by expanded such as "you are"
x = replace_contraction(x)
# Replace elongations. Ex: "heyyyyy" is replaced by "Hey"
x = replace_word_elongation(x)
# Replace emoji by plain text
@thibaut-d
thibaut-d / linux.md
Last active January 5, 2022 16:05
Memo

Memo

Download a directory with scp

scp -r thibaut@172.29.4.12:/home/thibaut/project backups/project

Run in background

nohup python myscript.py &
library(tidyverse)
library(textshape)
library(lexicon)
library(textclean)
library(hunspell)
library(qdapRegex)
#' Detect and correct misspells in a string
#' @param x string.
#' @return corrected string
sudo apt-get update -y
sudo apt-get install -y python3-pip git-all awscli
sudo pip3 install flask jupyter boto3
sudo pip3 install --upgrade awscli
cd /home/ubuntu
jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root
@thibaut-d
thibaut-d / gitflow-cheatsheet.md
Last active November 6, 2020 20:03
Gitflow cheatsheet (without the Gitflow extension)
@thibaut-d
thibaut-d / ScreenName.tsx
Last active September 16, 2020 14:10
React Navigator's StackNavigator and a screen
import React, { useEffect, useState, useContext, FC } from 'react'
import { StyleSheet, SafeAreaView, FlatList } from 'react-native'
import { StackNavigationProp } from '@react-navigation/stack'
import { RouteProp } from '@react-navigation/native'
import { HomeScreenStackParamList } from '../navigation/navigationTypes'
interface Props {
navigation: StackNavigationProp<ScreenNameStackParamList, 'Home'>
route: RouteProp<ScreenNameStackParamList, 'Home'>
}
@thibaut-d
thibaut-d / CustomHookContext.tsx
Last active September 16, 2020 14:03
Shared state management with React Native and the Context API
import React, { createContext, FC } from 'react'
import useCustomHook, { UseCustomHookType, initialCustomHookContext } from './useCustomHook'
// Props type
interface Props {
/** Children components place, shall not be needed here with FC type, yet eslint requires it... */
children: React.ReactNode
}
// Create the context objects
@thibaut-d
thibaut-d / ReactNativeFunctionalComponentWithState.tsx
Created September 16, 2020 13:52
React Native functional component with internal state management
import React, { FC, useEffect, useState } from 'react'
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
interface Props {
/** prop documentation */
restart?: number
}
/**
* Component description
@thibaut-d
thibaut-d / ReactNativeFonctionalComponent.tsx
Created September 16, 2020 13:40
Basic functional component for React Native with TypeScript
import React, { FC } from 'react'
import { StyleSheet, Text, View } from 'react-native'
interface Props {
/** prop1 documentation */
prop1: string
}
/**
* Component description
@thibaut-d
thibaut-d / 00 - React Native CLI Cheatsheet.sh
Last active June 21, 2020 21:12
React Native CheatSheet
# Start With TypeScript
npx react-native init AwesomeTSProject --template react-native-template-typescript
# Run the app locally
npx react-native start
npx react-native run-android
npx react-native run-ios