Skip to content

Instantly share code, notes, and snippets.

View nelsonprsousa's full-sized avatar
:octocat:
Working from home

Nelson Sousa nelsonprsousa

:octocat:
Working from home
View GitHub Profile
namespace XUnitTestProject
{
using Xunit;
public static class SwitchStatementMapper
{
// Don't judge me, it's only for educational purposes :)
public static bool Map(string str) => str switch
{
"true" => true,
import React, { ReactElement } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createNativeStackNavigator } from 'react-native-screens/native-stack';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/Ionicons';
import Home from 'screens/home';
import Discover from 'screens/discover';
import Itinerary from 'screens/itinerary';
import Search from 'screens/search';
import React from 'react';
import {View, Dimensions} from 'react-native';
import Animated, {
useAnimatedScrollHandler,
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated';
const BORDER_RADIUS = 10;
onPress={() => {
// Navigation.showModal({
// component: {
// name: 'DescriptionScreen',
// options: {
// topBar: {
// visible: true,
// title: {
// text: 'Modal2',
// },
@nelsonprsousa
nelsonprsousa / DeleteLocalBranches.md
Created May 3, 2021 15:34
Delete all local branches but main

git for-each-ref --format '%(refname:short)' refs/heads | grep -v main | xargs git branch -D

var dataLoader = new DataLoader();
Console.WriteLine("Executing...");
var t1 = dataLoader.LoadAsync("1");
var t2 = dataLoader.LoadAsync("1");
var t3 = dataLoader.LoadAsync("9999");
Console.WriteLine("Done Loading...");
root = true
[*.yml]
indent_style = space
indent_size = 2
[*.cs]
charset = utf-8-bom
insert_final_newline = true
indent_style = space
namespace Wanderlust.API.Presentation.Queries;
using HotChocolate.Types.Pagination;
[ExtendObjectType(OperationTypeNames.Query)]
[GraphQLName(nameof(TodoQuery))]
public class TodoQuery
{
[UsePaging]
public Connection<ITodoResult> GetTodos(string? after, int? first)
namespace Wanderlust.API.Presentation.Queries;
using System;
using System.Threading;
using HotChocolate.Types.Pagination;
[ExtendObjectType(OperationTypeNames.Query)]
[GraphQLName(nameof(TodoQuery))]
public class TodoQuery
{
@nelsonprsousa
nelsonprsousa / useScrollToTop.ts
Last active January 29, 2022 15:30
The expected native behavior of scrollable components is to respond to events from navigation that will scroll to top when tapping on the active tab as you would expect from native tab bars. Works with react-native-navigation.
import { useEffect, useRef } from 'react';
import { ScrollView } from 'react-native';
import { Navigation } from 'react-native-navigation';
const useScrollToTop = ({
selectedTabIndex,
}: {
selectedTabIndex: number;
}): React.RefObject<ScrollView> => {
const scrollViewRef = useRef<ScrollView>(null);