Skip to content

Instantly share code, notes, and snippets.

View Ribeiro-Tiago's full-sized avatar

Tiago Ribeiro Ribeiro-Tiago

View GitHub Profile
@Ribeiro-Tiago
Ribeiro-Tiago / request.ts
Created March 12, 2025 09:54
fetch composable for vue
// heavily inspired by nuxt's useFetch
// functionalities:
// - delayed execution
// - result prop picking
// - custom transformer
// - state related callbacks (state change, success, error)
// - auto retry
// - request caching
// - auto fetch based on watched props
// - request dedup
@Ribeiro-Tiago
Ribeiro-Tiago / axios-base-config.ts
Created March 12, 2025 09:54
base configs for axios
import Axios, { AxiosProgressEvent } from "axios";
import nProgress from "nprogress";
import { Store } from "vuex";
import { Router } from "vue-router/auto";
import { version } from "../../package.json";
const globalCancelToken = Axios.CancelToken.source();
// progress bar on top of the page on every axios request.
@Ribeiro-Tiago
Ribeiro-Tiago / git-branch-prune.txt
Last active May 27, 2021 07:44
prune git branches
// remote prune
git remote prune origin
// local prune
git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs -n 1 git branch -D
@Ribeiro-Tiago
Ribeiro-Tiago / check and update git remote origin
Last active June 12, 2020 13:18
Check and update git remote origin
// view current remote
git remote -v
// update origin
git remote set-url origin https://hostname/USERNAME/REPOSITORY.git
@Ribeiro-Tiago
Ribeiro-Tiago / mail-hosts.json
Last active September 7, 2020 14:33
mail hosts for several common servers
{
"1und1": {
"host": "smtp.1und1.de",
"port": 465,
"secure": true,
"authMethod": "LOGIN"
},
"AOL": {
"domains": [
@Ribeiro-Tiago
Ribeiro-Tiago / App.tsx
Created February 4, 2019 16:35
Code snippet for medium article
interface Props {
navigation: NavigationScreenProp<any, any>;
}
class Home extends React.Component<Props> {
render() {
return (
<View style={{ flex: 1, justifyContent: "space-around", alignItems: "center" }}>
<Text style={{ fontSize: 48, fontWeight: "bold" }}>Home Screen</Text>
<Button title="Profile" onPress={() => this.props.navigation.push("Profile")} />
const prevGetStateForAction = myStack.router.getStateForAction;
myStack.router.getStateForAction = (action, state) => {
if (state && action.type === "Navigation/COMPLETE_TRANSITION") {
let routes = state.routes;
if (routes.length === 1) {
return {
...state,
index: 0,
};
const prevGetStateForAction = myStack.router.getStateForAction;
myStack.router.getStateForAction = (action, state) => {
if (state && action.type === "Navigation/NAVIGATE") {
let routes = state.routes;
const lastScene: NavigationRoute = routes.slice(-1)[0];
const lastSceneName = lastScene.routeName;
routes = routes.filter((item: NavigationRoute, index: number) => item.routeName !== lastSceneName);
routes.push(lastScene);
const prevGetStateForAction = myStack.router.getStateForAction;
myStack.router.getStateForAction = (action , state) => {
if (state && action.type === "Navigation/NAVIGATE") {
// do stuff
}
return prevGetStateForAction(action, state);
};
export default createStackNavigator({
Home,
Settings,
Profile
}, {
transitionConfig: transitioner
})