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, {useRef, useEffect} from 'react' | |
import {createPortal} from 'react-dom' | |
type PortalProps = { | |
children: React.ReactNode | |
} | |
function Portal({children}: PortalProps): JSX.Element { | |
const modalContainer = document.body | |
const modalElementRef = useRef<HTMLDivElement>() |
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 { useRef, useState, useEffect } from 'react'; | |
// Usage | |
function App() { | |
const [hoverRef, isHovered] = useHover(); | |
return ( | |
<div ref={hoverRef}> | |
{isHovered ? '😁' : '☹️'} | |
</div> |
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 {useState, useCallback, useRef} from 'react' | |
// Hook | |
const useHover = <T extends HTMLElement>(): [ | |
(node?: T | null) => void, | |
boolean, | |
] => { | |
const [value, setValue] = useState(false) | |
// Wrap in useCallback so we can use in dependencies below |
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
UIImage *image = [[UIImage alloc] initWith: something]; | |
if (image.size.width != kAppIconSize || image.size.height != kAppIconSize) { | |
CGSize itemSize = CGSizeMake(kAppIconSize, kAppIconSize); | |
UIGraphicsBeginImageContextWithOptions(itemSize, NO, 0.0f); | |
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height); | |
[image drawInRect:imageRect]; | |
self.appRecord.appIcon = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
} |
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
sourceSets { | |
main { | |
res.srcDirs = [ | |
'src/main/res-main', | |
'src/main/res-screen/about', | |
'src/main/res-screen/chat', | |
'src/main/res-screen/event-detail', | |
'src/main/res-screen/event-list', | |
'src/main/res-screen/home', | |
'src/main/res-screen/login', |
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
adb shell dumpsys activity | grep -I 'PACKAGE_NAME' | |
adb shell am start -n PACKAGE_NAME/.PATH_TO_ACTIVITY.ACTIVITY_NAME | |
# Grant or revoke one or more permissions: | |
adb shell pm [grant|revoke] <PACKAGE> <PERMISSION> |
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
#### | |
# OS X temporary files that should never be committed | |
# | |
# c.f. http://www.westwind.com/reference/os-x/invisibles.html | |
.DS_Store | |
# c.f. http://www.westwind.com/reference/os-x/invisibles.html | |
.Trashes |
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
#!/bin/bash | |
# Author: Tobias Preuss | |
# Version: 2015-03-26 | |
echo "Creating symbolic links in Android SDK folder" | |
echo "=============================================" | |
echo | |
if [ -z "$ANDROID_HOME" ] ; then |
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
/** | |
* Create your key store: keytool -genkey -v -keystore release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 | |
* and after update your build.gradle file. | |
*/ | |
android { | |
signingConfigs { | |
release { | |
storeFile file("release.keystore") | |
storePassword "******" | |
keyAlias "******" |
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
/** | |
* Define 'APP_MODULE_NAME' and 'APK_NAME' vars in gradle.properties file. | |
*/ | |
android { | |
applicationVariants.all { variant -> | |
variant.outputs.each { output -> | |
def outputFile = output.outputFile | |
if (outputFile != null && outputFile.name.endsWith('.apk')) { | |
def fileName = outputFile.name.replace('.apk', "-${versionName}.apk") | |
fileName = fileName.replace(APP_MODULE_NAME, APK_NAME) |
NewerOlder