Skip to content

Instantly share code, notes, and snippets.

View tobob's full-sized avatar
😼
wanna something?

Wojciech Bożek tobob

😼
wanna something?
View GitHub Profile
@tobob
tobob / defaultPageQuery.js
Created December 30, 2020 11:01
Modular Gatsby Contenful
export const pageQuery = graphql`
query BlogPostBySlug($slug: String!) {
contentfulBlogPost(slug: { eq: $slug }) {
title
publishDate(formatString: "MMMM Do, YYYY")
heroImage {
fluid(maxWidth: 1180, background: "rgb:000000") {
...GatsbyContentfulFluid_tracedSVG
}
}
import React, {useContext} from 'react';
import {View, Text, TouchableOpacity, StyleSheet} from 'react-native';
import {ToastContext} from './ToastContext';
const HomeScreen = () => {
const {show} = useContext(ToastContext);
return (
<View style={styles.container}>
<TouchableOpacity onPress={() => show({message: 'Ama simple Toast!'})}>
@tobob
tobob / App.js
Created December 18, 2019 10:58
import React from 'react';
import AppNavigation from './AppNavigation';
import {ToastProvider} from './ToastContext';
import Toast from './Toast';
const App = () => (
<ToastProvider>
<Toast />
<AppNavigation />
</ToastProvider>
@tobob
tobob / App.js
Created December 18, 2019 10:57
import React from 'react';
import AppNavigation from './AppNavigation';
import {ToastProvider} from './ToastContext';
import Toast from './Toast';
export default class App extends React.Component {
render() {
return (
<ToastProvider>
<Toast />
useEffect(() => {
if (toast.visible) {
timeout.current = setTimeout(hide, 1500);
return () => {
if (timeout.current) {
clearTimeout(timeout.current);
}
};
}
}, [hide, toast]);
useEffect(() => {
if (toast.visible) {
timeout.current = setTimeout(hide, 1500);
return () => {
if (timeout.current) {
clearTimeout(timeout.current);
}
};
}
}, [hide, toast]);
const styles = StyleSheet.create({
toast: {
borderRadius: 4,
marginHorizontal: 16,
padding: 4,
position: 'absolute',
top: 0,
zIndex: 2,
right: 0,
left: 0,
import React, {useContext, useEffect, useRef} from 'react';
import {ToastContext} from './ToastContext';
import {
Text,
Animated,
Easing,
TouchableOpacity,
StyleSheet,
} from 'react-native';
import React, {
createContext,
useState,
useEffect,
useRef,
useCallback,
} from 'react';
const initialToast = {
message: '',
ok = false
while(!ok)
users_list_ids = User.all.pluck(:id).shuffle
User.all.each_with_index do |user, index|
user.update_attribute(:target_id, users_list_ids[index])
end
ania_ok = User.find_by(name: 'Ania').target.name != 'Damian'