Skip to content

Instantly share code, notes, and snippets.

View lindesvard's full-sized avatar

Carl-Gerhard Lindesvärd lindesvard

  • Stockholm, Sweden
View GitHub Profile
import React, { createContext } from 'react';
import { useWindowDimensions, View } from 'react-native';
import Animated, {
useAnimatedStyle,
useSharedValue,
withSpring,
} from 'react-native-reanimated';
import { LinearGradient } from 'expo-linear-gradient';
import { Stack } from 'expo-router';
import { COLORS } from '@/constants';
// Pure JS
const input = document.querySelector('input')
if(input) {
input.addEventListener('blur', (event) => {
window.op('event', 'search', {
query: event.target.value
})
})
}
@lindesvard
lindesvard / nextjs-13-clean-html.ts
Created April 26, 2023 18:09
# Nextjs 13 - Clean rsc data from all html files
import fs from 'fs'
import path from 'path'
function findRecursive(startPath: string, filter: string): string[] {
if (!fs.existsSync(startPath)) {
return []
}
const found = []
const files = fs.readdirSync(startPath)
for (let i = 0; i < files.length; i++) {
@lindesvard
lindesvard / Query.hack.js
Created May 23, 2019 10:43
Query.hack.js
// this file is imported by the entry point before any React code runs
import { Query } from 'react-apollo'
/**
* partialRefetch should always be true, but it defaults to false for reasons
* that are totally unimaginable to me. this hacks it on for us.
*
* note: today, Query has no defaultProps but this Object.assign ensures it works either way
* and will explicitly override any current or future value for `partialRefetch`.
@lindesvard
lindesvard / createApolloClient.js
Created June 13, 2018 11:09
ApolloClient with JWT auth and refetch jwt token with refreshtoken
import config from 'config'
import { getAccessToken } from 'libs/storage'
import { ApolloClient } from 'apollo-client'
import { createHttpLink } from 'apollo-link-http'
import { setContext } from 'apollo-link-context'
import { InMemoryCache } from 'apollo-cache-inmemory'
import customFetch from './customFetch'
const httpLink = createHttpLink({
uri: config.GRAPHQL_URL,
@lindesvard
lindesvard / resize-image.js
Created March 26, 2018 13:16
Resize image with Jimp
var Jimp = require("jimp");
var url =
"http://cdn.wonderfulengineering.com/wp-content/uploads/2016/01/Desktop-Wallpaper-2.jpg";
const saveAndResize = (image, name, width, height, extension) => {
image
.clone()
.cover(width, height)
.quality(50)