Skip to content

Instantly share code, notes, and snippets.

View aquiseb's full-sized avatar

Sébastien aquiseb

View GitHub Profile
@aquiseb
aquiseb / react-vr-get-current-angle-of-view.js
Last active February 27, 2018 00:01
Get current angle of view in React VR
// Some explanation here https://medium.com/p/a928ca90f489
import React from 'react';
import { AppRegistry, asset, Pano, Text, View, VrHeadModel } from 'react-vr';
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
class WelcomeToVR extends React.Component {
constructor(props) {
super(props);
this.state = {
@aquiseb
aquiseb / graphql-go-mongodb-example.go
Last active August 7, 2022 23:39
Minimal example of GraphQL Golang and MongoDB playing nicely together. Edit
// Embedded in this article https://medium.com/p/c98e491015b6
package main
import (
"fmt"
"log"
"net/http"
"time"
"github.com/graph-gophers/graphql-go"
@aquiseb
aquiseb / MyComponent.jsx
Last active April 28, 2018 19:16
Reactjs Nextjs HOC
import React from 'react'
import { Enhance } from "../components/Enhance";
class MyComponent extends React.Component {
render() {
if (!this.props.data) return <div>Waiting...</div>;
return <div>{this.props.data}</div>;
}
}
/* eslint-disable */
import React from 'react';
import PropTypes from 'prop-types';
class App extends React.Component {
static displayName = `App`;
static propTypes = {
// eslint-disable-next-line react/forbid-prop-types
children: PropTypes.node.isRequired
@aquiseb
aquiseb / React.16.3_Context.js
Last active April 28, 2018 19:15
React 16.3 Context example
import React, { Component } from "react";
import { render } from "react-dom";
const PostContext = React.createContext();
class PostProvider extends Component {
state = {
review: "bad"
};
render() {
import React from 'react';
class Cat extends React.Component {
render() {
const mouseposition = this.props.mouseposition;
return (
<img src="https://dummyimage.com/30x30/000/fff" style={{ position: 'absolute', left: mouseposition.x -30, top: mouseposition.y -30 }} />
);
}
}
@aquiseb
aquiseb / Go_Context.go
Last active September 12, 2022 19:54
Golang context package examples
package main
import (
"bufio"
"context"
"fmt"
"log"
"os"
"time"
)
import React from 'react';
const initialData = "hello from initial data"
function iterateOverChildren(children) {
return React.Children.map(children, child => {
if (!React.isValidElement(child)) {
return child;
}
@aquiseb
aquiseb / Go_Friendly-configs-1_start.sh
Last active May 1, 2018 07:12
Go Friendly Configs
#! /bin/bash
# ------------------------------------------------------------
# Downloads required packages
# ------------------------------------------------------------
# Realize is a Golang Task Runner performing live reloading
if [ ! -f $GOPATH/bin/realize ] && [ ! -d $GOPATH/src/github.com/oxequa/realize ]; then
echo "Realize not found. Downloading it for you..."
// PARENT
const query = graphql.experimental`
query MyRootComponentQuery($employeeId: String!, $includeOvertime: Boolean) {
employee(id: $employeeId) {
fullName
...MyFragmentComponent_employee @arguments(includeOvertime: $includeOvertime)
}
}
`