Skip to content

Instantly share code, notes, and snippets.

View tibotiber's full-sized avatar

Thibaut Tiberghien tibotiber

View GitHub Profile
@tibotiber
tibotiber / smartTooltip.ts
Created January 24, 2024 02:14
Smart position of tooltips so it adapts to the position on screen
const viewerElement = document.getElementById('test') as HTMLElement
const tooltipInLeftHalfOfViewer = hoverState.tooltipPosition.screenX < viewerElement.clientWidth / 2
const tooltipInTopThirdOfViewer = hoverState.tooltipPosition.screenY < viewerElement.clientHeight / 3
const tooltipInBottomThirdOfViewer = hoverState.tooltipPosition.screenY > (2 * viewerElement.clientHeight) / 3
tooltipElement?.style.setProperty('display', 'block')
tooltipElement?.style.setProperty('top', `${hoverState.tooltipPosition.screenY}px`)
let tX: string, tY: string
if (tooltipInLeftHalfOfViewer) {
tooltipElement?.style.setProperty('left', `${hoverState.tooltipPosition.screenX}px`)
tooltipElement?.style.setProperty('right', 'unset')
@tibotiber
tibotiber / pointerDragBehavior.js
Last active November 16, 2021 08:29
Babylon.js PointerDragBehavior for thin instances
import { Behavior } from "../../Behaviors/behavior";
import { Mesh } from "../../Meshes/mesh";
import { AbstractMesh } from "../../Meshes/abstractMesh";
import { Scene } from "../../scene";
import { Nullable } from "../../types";
import { Observer, Observable } from "../../Misc/observable";
import { Vector3 } from "../../Maths/math.vector";
import { PointerInfo, PointerEventTypes } from "../../Events/pointerEvents";
import { Ray } from "../../Culling/ray";
import { PivotTools } from '../../Misc/pivotTools';
@tibotiber
tibotiber / build-extras.sh
Last active March 19, 2019 01:07
Medium: Deploy private source maps with Netlify
# ... build and push to gcloud ... #
# install sentry cli
echo "Installing and configuring sentry cli"
curl -L -o sentry-cli https://github.com/getsentry/sentry-cli/releases/download/1.40.0/sentry-cli-Linux-x86_64
chmod u+x sentry-cli
./sentry-cli --version
export SENTRY_ORG=<sentry-org>
export SENTRY_PROJECT=<sentry-project>
# create sentry release and upload source maps
@tibotiber
tibotiber / build.sh
Last active March 10, 2019 08:39
Medium: Deploy private source maps with Netlify
#!/bin/bash
# build
yarn react-app-rewired build
# install gcloud cli
echo "Installing gcloud sdk"
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-237.0.0-linux-x86_64.tar.gz
tar -xzf google-cloud-sdk-237.0.0-linux-x86_64.tar.gz
./google-cloud-sdk/bin/gcloud --version
# authenticate to gcloud
echo "Authenticating to gcloud"
@tibotiber
tibotiber / config-overrides.js
Last active March 13, 2019 07:06
Medium: Deploy private source maps with Netlify
const webpack = require('webpack')
function setSourceMaps (config, env) {
config.devtool = false
if (!config.plugins) {
config.plugins = []
}
config.plugins.push(
new webpack.SourceMapDevToolPlugin({
append:
const R = require('ramda')
const interfaces = {...}
const unpackSelectionFromAST = R.map(s => {
switch (s.kind) {
case 'Field':
if (!s.selectionSet) {
return s.name.value
} else {
const { makeSelection, formatPrimitiveFields } = require('./interfaces')
const Query = {
characters (parent, args, ctx, info) {
return ctx.db.query
.dbCharacters(
args,
makeSelection(info)
)
.then(formatPrimitiveFields)
const interfaces = {
Character: {
__resolveType (obj) {
// resolve the type of the incoming interface data
if (obj.primaryFunction) {
return 'Droid'
} else {
return 'Human'
}
}
const { interfaces } = require('./interfaces')
const { Query } = require('./Query')
module.exports = {
...interfaces,
Query
}
# import {} from "./generated/prisma.graphql"
type Query {
characters(
where: DbCharacterWhereInput
orderBy: DbCharacterOrderByInput
skip: Int
after: String
before: String
first: Int