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
package main | |
type dessert int | |
const ( | |
ICE_CREAM dessert = iota | |
CUP_CAKES | |
GUMMY_WORMS | |
) |
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
git ls-remote --heads origin | while read sha ref; do | |
behind=`git rev-list $sha..master --count` | |
if [ $behind -ge 1000 ]; then | |
echo "$ref $behind"; | |
fi | |
done |
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
[alias] | |
rebase-since = !sh -c 'git rebase -i $(git merge-base --fork-point \"${1:-master}\" HEAD)' - | |
graph = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit --date=relative |
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
function getElemByText(text) { | |
return document.evaluate( | |
`//*[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '${text}')]`, | |
document, | |
null, | |
XPathResult.FIRST_ORDERED_NODE_TYPE, | |
null | |
).singleNodeValue; | |
} |
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'; | |
const withTheme = <P extends {}>(Comp: React.ComponentType<P>) => { | |
return Comp as any as React.ForwardRefExoticComponent< | |
React.PropsWithoutRef<P> & | |
React.RefAttributes<any> | |
> & { | |
defaultProps: typeof Comp['defaultProps']; | |
}; | |
} |
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 readyToGo; | |
function prep_load () { | |
var enclosed, | |
data = 'function setSavedScenario () {' + | |
'return function () {' + | |
'readyToGo = function () {' + | |
'window.setTimeout(function () {' + | |
// this is just to show that the code "works" | |
'document.body.className = "blue";' + |
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
/** | |
* Add mobile equivalent for contextmenu event. | |
* User touches element for a given length of time | |
*/ | |
const addLongTouch = ( | |
elem: HTMLElement, | |
callback: (event: TouchEvent) => void, | |
delay = 650 | |
): (() => void) => { | |
let timeout: number; |
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
/** Gets a typed array from Object.keys */ | |
function typedObjectKeys<T extends Record<string, any>>(a: T) { | |
return Object.keys(a) as (keyof T)[]; | |
} | |
export default typedObjectKeys; |
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
// https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgILIN4ChnLgIwQC5kQBXAW32h2QBMIYSBnMKUAc1o4AtgTyVGrgBWAawA2JAEoQEAeyh0APK3YgOAGlKVqUAHy0KIeQN3QA2gF0sAXyxYA9ACpnyAPIgJAT2QcIYMgADlDyQdBgwBDMyDChFMgAKsgA7jzQKABucBJkKMAx8jDIYN7hyADSyM6OWKXlnj7KidoV+sgAvMgACsAIYs3a2LgW3cigyGIQ3kVJViSJo1bIEAAekCB0MVUA-D3IAhCZNLYWUzPFiVaGTo7IEsAUwIFg8sjyXr6CesGh4VCRaJ1MooABCnQ8n2UqG032gNwUIFYJWiYBI4K6wzwhBIAEYAEwAZk03D4JAALABWABsJPsQA | |
/** Only get properties from T where value is of type K */ | |
type Only<T, K> = Pick<T, { | |
[P in keyof T]: T[P] extends K ? P : never | |
}[keyof T]> | |
// | |
// Writable properties from an interface | |
// |
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
User-agent: * | |
Disallow: / |