Skip to content

Instantly share code, notes, and snippets.

Avatar

Espen Hovlandsdal rexxars

View GitHub Profile
@rexxars
rexxars / ProductInput.js
Created Feb 5, 2021
Custom product input, barebones
View ProductInput.js
import React from 'react'
import Preview from 'part:@sanity/base/preview'
import FormField from 'part:@sanity/components/formfields/default'
import SearchableSelect from 'part:@sanity/components/selects/searchable'
import PatchEvent, {set, setIfMissing, unset} from 'part:@sanity/form-builder/patch-event'
const products = [
{
title: 'Adidas Superstar Canvas Green',
handle: 'canvas-grene',
View keybase.md

Keybase proof

I hereby claim:

  • I am rexxars on github.
  • I am rexxars (https://keybase.io/rexxars) on keybase.
  • I have a public key ASAZscecEP8CIxmTKGtiZKIwB3c9jOYVvQMG5QE0OO_0zQo

To claim this, I am signing this object:

@rexxars
rexxars / npm-use-yarn-if-lockfile.zsh
Created May 4, 2020
Use yarn instead of npm if there is a `yarn.lock`
View npm-use-yarn-if-lockfile.zsh
npm() {
if [[ ($1 == "i" || $1 == "install") && -e yarn.lock ]]; then
read "REPLY?Use yarn (Y/n)? "
echo ""
if [[ $REPLY =~ ^[Yy]$ || $REPLY == "" ]]; then
if [[ $2 == "--save-dev" ]]; then
echo "yarn add --dev ${@:3}"
command yarn add --dev "${@:3}"
return $?
elif [[ $2 == "--save" ]]; then
@rexxars
rexxars / blocksToHtml.vue
Created Feb 14, 2018
Temporary "block content to vue"
View blocksToHtml.vue
<template>
<div v-html="renderHtml(content)"></div>
</template>
<script>
const blocksToHtml = require("@sanity/block-content-to-html")
const h = blocksToHtml.h
const serializers = {
View image-render.php
<?php
require_once './vendor/autoload.php';
$client = new Sanity\Client([
'projectId' => '3do82whm',
'dataset' => 'production',
'useCdn' => true,
]);
$doc = $client->getDocument('47abbe60-f184-4eff-99e0-3a85c5c07c3a');
$html = Sanity\BlockContent::toHtml($doc['body'], [
View input.js
// Reduced/boiled down from a webpack bundle, obviously not the real thing
var zing = {};
(function foo(module, exports, __webpack_require__) {
"use strict";
exports.default = sortableContainer;
function sortableContainer(WrappedComponent) {
var _class,
@rexxars
rexxars / index.js
Last active Nov 10, 2017
Webpack test
View index.js
var React = require('react');
var ReactDOM = require('react-dom');
var ReactMarkdown = require('react-markdown');
var input = '# This is a header\n\nAnd this is a paragraph';
ReactDOM.render(
React.createElement(ReactMarkdown, {source: input}),
document.getElementById('container')
);
@rexxars
rexxars / example.php
Created Jun 27, 2017
Image renderer, PHP-client
View example.php
<?php
require_once './vendor/autoload.php';
$client = new Sanity\Client([
'projectId' => '3do82whm',
'dataset' => 'production',
]);
$doc = $client->getDocument('47abbe60-f184-4eff-99e0-3a85c5c07c3a');
$html = Sanity\BlockContent::toHtml($doc['body'], [
@rexxars
rexxars / jsondump.jsx
Last active Dec 19, 2019
React JSON dump component
View jsondump.jsx
import React from 'react';
class JsonDump extends React.Component {
static propTypes = {
children: React.PropTypes.any
}
render() {
return <pre>{JSON.stringify(this.props.children, null, 4)}</pre>
}
View gist:1336dead6f1f31d2c825
2 bokser kokosmelk
4 dl vann
7-8 teskjer green curry paste
1 sjalottløk
1 rødløk
3 fedd hvitløk
"En god dæsj" fiskesaus (1 ss? 2 ss?)
4 chili
1 gulerot