Some APIs only return a certain property if it’s supported in that context. This makes using the traditional {{#if}}
block helper difficult, even when passing in the little known includeZero=true
; the property value might be null
, and in some edge cases even undefined
.
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 React, { useState, useEffect } from 'react' | |
import { useDebounce } from './use-debounce' | |
const MySearchComponent = props => { | |
const [search, setSearch, { | |
signal, | |
debouncing | |
}] = useDebounce('') | |
const [results, setResults] = useState([]) |
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
const People = () => { | |
const peopleContext = useContext(PeopleContext) | |
const [people, sort, setSortField] = useSort({ | |
items: peopleContext.people ?? [], | |
fields: { | |
name: { | |
method: 'compare', | |
getValue: ({ firstName, lastName }) => `${lastName} ${firstName}`, | |
order: 'asc' |
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 React from 'react' | |
import Svg, { Path } from 'react-native-svg' | |
const icons = { | |
'confirm': 'm503 127l-46-45c-12-12-32-12-45 0l-217 226l-82-82c-12-13-33-13-45 0l-45 45c-13 12-13 33 0 45l150 150c12 13 32 13 45 0l68-68l217-225c6-7 9-15 9-23l0 0c0-8-3-16-9-23z', | |
'dismiss': 'm439 363l-102-102l102-102c12-12 12-33 0-45l-46-45c-12-13-32-13-45 0l-102 102l-102-102c-12-13-32-13-45 0l-45 45c-12 12-12 33 0 45l102 102l-102 102c-12 12-12 33 0 45l45 45c13 13 33 13 46 0l101-101l102 101c13 13 33 13 45 0l46-45c12-12 12-33 0-45z', | |
'notifications-on': 'm384 288c0-58 0-169-97-189c0-1 1-2 1-3c0-18-14-32-32-32c-18 0-32 14-32 32c0 1 1 2 1 3c-97 20-97 131-97 189c0 64-64 96-64 96l0 32l384 0l0-32c0 0-64-32-64-96z m-160 192l64 0c18 0 32-14 32-32l-128 0c0 18 14 32 32 32z', | |
'notifications-off': 'm352 107c-15-19-35-34-65-40c0-1 1-2 1-3c0-18-14-32-32-32c-18 0-32 14-32 32c0 1 1 2 1 3c-97 20-97 131-97 189c0 64-64 96-64 96l0 32l11 0z m32 149l-128 128l192 0l0-32c0 0-64-32-64-96z m-185 185c6 8 15 13 25 13l64 0c18 0 32-14 3 |
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 React from 'react' | |
import { Text } from 'react-native' | |
import emojiRegex from 'emoji-regex' | |
import { map, split, reduce, get, last } from 'lodash' | |
export default ({ text, textStyle = {}, emojiStyle = {}, keySalt = Date.now() }) => { | |
const taggedSymbols = map(split(text, ''), symbol => ({ symbol, emoji: emojiRegex().test(symbol) })) | |
const sectionedSymbols = reduce(taggedSymbols, (sections, taggedSymbol, index) => { | |
if(taggedSymbol.emoji !== get(taggedSymbols, `${index - 1}.emoji`)) { |
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 React, { Component } from 'react' | |
import Icon from './icon' | |
export default class Sp00x extends Component { | |
componentDidMount() { | |
// I got the spooks | |
} | |
render() { | |
return <Icon name="sp00x" /> |
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
// ==UserScript== | |
// @name Couchsurfing: Show week days in Dashboard overview | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Less cognitive load! | |
// @author Hein Haraldson Berg | |
// @match https://www.couchsurfing.com/dashboard | |
// @grant none | |
// ==/UserScript== |
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
// ==UserScript== | |
// @name Couchsurfing: Just a reply! | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Sometimes, even saying ’Maybe’ is too much of a commitment. There might be too little information, or you just don’t want to get their hopes up. | |
// @author Hein Haraldson Berg | |
// @match https://www.couchsurfing.com/messages/* | |
// @grant none | |
// ==/UserScript== |
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 api from 'utilities/api' | |
// Actions | |
const fetchingEvents = () => { | |
return { | |
type: 'events:fetching' | |
} | |
} | |
const fetchEventsFailure = (error) => { |
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
var NoWrapRegion = Backbone.Marionette.Region.extend({ | |
attachHtml: function (view) { | |
this.el.innerHTML=""; | |
var children = view.el.childNodes; | |
while (children.length > 0) { | |
this.el.appendChild(children[0]); | |
} | |
view.setElement(this.el, true) | |
} | |
}); |
NewerOlder