Skip to content

Instantly share code, notes, and snippets.

View mbelsky's full-sized avatar
😈
--no-verify

Max Belsky mbelsky

😈
--no-verify
View GitHub Profile
@mbelsky
mbelsky / .gitignore
Created June 12, 2015 01:56
android-studio-gitignore
# Created by https://www.gitignore.io
# Edited by mbelsky
### Android ###
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
@mbelsky
mbelsky / android-custom-apk-file-name.gradle
Created June 25, 2015 08:08
Snippet for adding current version value in android apk release file name
/**
* 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)
@mbelsky
mbelsky / android-custom-release-keystore.gradle
Created June 25, 2015 08:18
Snippet to custom keystore file for release apk file.
/**
* 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 "******"
@mbelsky
mbelsky / android-sdk-setup.sh
Last active August 29, 2015 14:27 — forked from johnjohndoe/android-sdk-setup.sh
Creating symbolic links in Android SDK folder. After Android-Studio resp. IntelliJ will work with Maven and Gradle.
#!/bin/bash
# Author: Tobias Preuss
# Version: 2015-03-26
echo "Creating symbolic links in Android SDK folder"
echo "============================================="
echo
if [ -z "$ANDROID_HOME" ] ; then
@mbelsky
mbelsky / .gitignore
Last active February 13, 2017 17:28
.gitignore file for Objective-C, Swift, xCode 7, CocoaPods
####
# 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
@mbelsky
mbelsky / adb shell
Last active April 7, 2016 11:11
Useful 'adb shell' commands
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>
@mbelsky
mbelsky / android-custom-res-folder.gradle
Last active April 4, 2016 07:37
Code to split wide 'res' folder
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',
@mbelsky
mbelsky / ImageRedrawer.m
Last active April 4, 2016 07:35
Redraw an image for new size
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();
}
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
import { useRef, useState, useEffect } from 'react';
// Usage
function App() {
const [hoverRef, isHovered] = useHover();
return (
<div ref={hoverRef}>
{isHovered ? '😁' : '☹️'}
</div>