This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sharp from 'sharp'; | |
export default async function handler(req, res) { | |
const { url, logo } = req.query || []; | |
const imgRes = await fetch(url); | |
const logoRes = await fetch(logo); | |
//return res.status(200).json({ url, status: imgRes.status }); | |
const imgBuffer = Buffer.from(await imgRes.arrayBuffer()); | |
const logoBuffer = Buffer.from(await logoRes.arrayBuffer()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tailwinds Styles | |
import '../styles/globals.css'; | |
import { useRouter } from 'next/router'; | |
import { useState, useEffect } from 'react'; | |
import classNames from 'classnames'; | |
function MyApp({ Component, pageProps }) { | |
const [transition, setTransition] = useState('opacity-100'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let data = { | |
title: "Hello ", | |
address: { | |
house: "123", | |
street: "ok" | |
}, | |
list: [{a:1,b:2}] | |
} | |
let transformations = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Transform props { listingEditQuery: { Listing: { title: 'Title' }} => { listing: { title: 'Title' }} | |
withProps(R.compose(R.objOf('listing'), R.path(['listingEditQuery', 'Listing']))) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inputChange = (e) => { | |
console.log('inputChange', e.currentTarget.name, e.currentTarget.value ); | |
this.props.apolloClient.writeFragment({ | |
id: 'new', //this.props.profileQuery.Profile.id, | |
fragment: gql` | |
fragment Profile on Profile { | |
__typename | |
${e.currentTarget.name} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To allow c9 workspace to push to github org repository you must allow it in 3rd party access setup https://github.com/organizations/<org>/settings/oauth_application_policy | |
Either remove restrictions or allow it from your https://github.com/settings/applications |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* browsers that support svg support multiple bg those that dont browsers will fallback to image */ | |
.css{ | |
background: url('image.png'); | |
background: none, url('vector.svg'); | |
} | |
Most modernd browsers support svg in images, just use conditional comments to serve images instead for old IE | |
<!--[if lte IE 8]><img src="logo.png" /><![endif]--> | |
<!--[if gt IE 8]><img src="logo.svg" /><![endif]--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instead of copying js plugins to assets/ import them from a url. | |
// Obviously works best with pre-compiled assets | |
<%=open('https://raw.github.com/documentcloud/backbone/master/backbone.js | |
').read%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Indexer | |
# Add indexed fields to model | |
# TODO - make this work in embedded e.g. self.index_embedded(*names) | |
module Indexes | |
extend ActiveSupport::Concern | |
included do | |
class_attribute :_index_fields | |
class_attribute :_index_texts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%-# items is an array on object e.g. object.items = [1,2,3], we want to display as list of fields, and post back as an array - note the backwards ][ which makes is do this! -%> | |
<% @object.items.each do |i| %> | |
<%=f.text_field "items][",:value=>i,:id=>"item-#{SecureRandom.uuid}" %> | |
<% end %> |
NewerOlder