Skip to content

Instantly share code, notes, and snippets.

View Ribeiro-Tiago's full-sized avatar

Tiago Ribeiro Ribeiro-Tiago

  • Barreiro
View GitHub Profile
@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
})
const transitioner = (): TransitionConfig => {
return {
transitionSpec: {
duration: 400
},
screenInterpolator: (transitionProps: NavigationTransitionProps) => {
const { position, scene } = transitionProps;
const index = scene.index;
}
}
const stack = createStackNavigator({
Home,
Settings,
Profile
})