Skip to content

Instantly share code, notes, and snippets.

View ivanstnsk's full-sized avatar
🎯
Focusing

Ivan Stinskyi ivanstnsk

🎯
Focusing
View GitHub Profile
<div className="card">
<img className="card-img-top" src={data?.viewer.avatarUrl} alt="Card image" />
<div className="card-body">
<h4 className="card-title">{data?.viewer.name}</h4>
<p className="font-weight-light">@{data?.viewer.login}</p>
<p className="card-text">{data?.viewer.bio}</p>
<a href="https://github.com/ivanstnsk" className="btn btn-primary">See Profile</a>
</div>
</div>
@ivanstnsk
ivanstnsk / index.js
Created January 10, 2022 15:47
Apollo server setup valid on 10 Jan 2022 (for the course https://www.linkedin.com/learning/learning-graphql-11292553)
const { createServer } = require('http');
const { execute, subscribe } = require('graphql');
const { SubscriptionServer } = require('subscriptions-transport-ws');
const { makeExecutableSchema } = require('@graphql-tools/schema');
const { ApolloServer, gql } = require('apollo-server-express');
const { MockList } = require('@graphql-tools/mock');
const { ApolloServerPluginLandingPageGraphQLPlayground } = require('apollo-server-core');
const express = require('express');
@ivanstnsk
ivanstnsk / index.js
Created January 10, 2022 12:01
Apollo server setup valid on 10 Jan 2022 (for the course https://www.linkedin.com/learning/learning-graphql-11292553)
// Requires extra step: install the package apollo-server-core
const { ApolloServer, gql } = require('apollo-server');
const { ApolloServerPluginLandingPageGraphQLPlayground } = require('apollo-server-core');
const typeDefs = gql`
type Query {
totalDays: Int!
}
`;
@ivanstnsk
ivanstnsk / update-version.sh
Last active June 15, 2021 10:24
React Native update project version on mac
#!/bin/bash
COLOR_OK='\033[1;32m'
COLOR_HEADING='\033[0;36m'
COLOR_ERROR='\033[0;31m'
NC='\033[0m'
# Set your project directory
APP_REPO_DIR=~/dev/project-dir
@ivanstnsk
ivanstnsk / useAndroidBackNavigationEffect.ts
Created July 22, 2020 10:15
use Android Back navigation effect hook React Native in Typescript
import { useCallback } from 'react';
import { BackHandler } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';
export const useAndroidBackNavigationEffect = (callback: any): void => {
useFocusEffect(
useCallback(() => {
const onBackPress = () => {
if (callback) {
callback();
@ivanstnsk
ivanstnsk / useAndroidPermissions.ts
Created May 27, 2020 12:55
use Android Permissions hook React Native in Typescript
import { useEffect, useState } from 'react';
import { PermissionsAndroid } from 'react-native';
type THook = [boolean, boolean];
interface PermissionsAndroidResponse {
[key: string]: string;
}
@ivanstnsk
ivanstnsk / useMouseScroll.ts
Created May 26, 2020 12:43
use Mouse Scroll hook React in Typescript
import { useEffect, useState, useRef } from 'react';
type THook<T extends HTMLElement> = [
React.RefObject<T>,
number,
];
export const useMouseScroll = <T extends HTMLElement>(): THook<T> => {
const [scrollY, setScrollY] = useState<number>(0);
@ivanstnsk
ivanstnsk / useWindowResize.ts
Last active October 24, 2022 11:57
use Window Resize hook React in Typescript
import { useEffect, useState } from 'react';
type TWindowSize = [number, number];
type THook = TWindowSize;
export const useWindowResize = (): THook => {
const initSize: TWindowSize = [
window.innerWidth,
@ivanstnsk
ivanstnsk / useMouseHover.ts
Last active May 24, 2020 17:55
use Mouse Hover hook React in Typescript
import { useEffect, useState, useRef } from 'react';
type THook<T extends HTMLElement> = [
React.RefObject<T>,
boolean,
];
export const useMouseHover = <T extends HTMLElement>(): THook<T> => {
const [hovered, setHovered] = useState(false);
export const delay = (timeMs: number): Promise<void> => {
return new Promise((resolve) => {
setTimeout(resolve, timeMs);
});
};
// await delay(2000);