Skip to content

Instantly share code, notes, and snippets.

View nixolas1's full-sized avatar

Nicolas Tonne nixolas1

View GitHub Profile
@nixolas1
nixolas1 / yaps.js
Last active December 3, 2018 14:25
Yet another parallax scroller :) Uses CSS variables and translateY to calculate parallax effect, only when scrolling.
var paraElements = document.querySelectorAll('.parallax-hero__image');
var paraSpeed = 0.2;
var paraOffsets = [];
var paraScrolling = false;
// add parallax transform to all matched elements, and check their offset from top
for (var i = 0; i < paraElements.length; i++){
paraElements[i].style.transform = 'translateY( calc( var(--scrollparallax) * 1px ) )';
var bodyRect = document.body.getBoundingClientRect(),
elemRect = paraElements[i].getBoundingClientRect(),
@nixolas1
nixolas1 / deskStructure.js
Created February 17, 2020 13:16
Example of a tree-structure explorer in sanity.io
import { MdAdd, MdEdit, MdPeople, MdPersonAdd, MdPublic } from "react-icons/md"
import S from "@sanity/desk-tool/structure-builder"
import client from "part:@sanity/base/client"
export default () =>
// const disabledDefaultList = () =>
S.list()
.title("Content")
.items([
export const sha256HashString = async (message) => {
const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // hash the message
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
return hashHex;
}
@nixolas1
nixolas1 / StreamlineIcon-ReactNative.js
Created May 14, 2020 11:20
A quick react native version of the StreamlineIcon React package. Styles and classnames are missing, and would need to be remade with React-Native styling.
import React from "react"
import camelcaseKeys from "camelcase-keys"
import Svg, {G, Path} from "react-native-svg"
import {Home} from "@streamlinehq/streamline-light/lib/interface-essential"
export const StreamlineIcon = ({
icon,
fill,
size,
@nixolas1
nixolas1 / rn-swipable-panel-fork.js
Created October 19, 2020 08:48
Fixes bugs for android, removes scrolling inside panel, allows swiping up and down easier. Removed onlySmall support (Use onlyLarge with maxheight)
// Credits to https://github.com/enesozturk/rn-swipeable-panel version 1.2.1
// Removed background elements to fix Android bugs
const React = require("react")
const reactNative = require("react-native")
function _extends() {
_extends =
Object.assign ||
function(target) {
@nixolas1
nixolas1 / carplayPlugin.js
Created July 26, 2023 08:29
React Native Carplay (2.1.0) plugin for Expo 47 (Dangerous modifications)
const {createRunOncePlugin, IOSConfig, withDangerousMod} = require("@expo/config-plugins")
const fs = require("fs/promises")
const withCarPlay = (config) => {
config = withCarPlayAppDelegate(config)
config = withCarPlayAppDelegateHeader(config)
return config
}
const withCarPlayAppDelegate = (conf) => {