Skip to content

Instantly share code, notes, and snippets.

@GingerBear
GingerBear / npm_link_rn.md
Last active May 29, 2018 15:32
npm link in react native
@GingerBear
GingerBear / codepush_release.md
Created April 24, 2018 03:42
codepush release
  • install appcenter cli https://github.com/Microsoft/appcenter-cli
  • appcenter login
  • update "name": "GNCUAT", in package.json
  • add "react-native": "0.0.0", to dependencies in package.json
  • appcenter codepush release-react -a Branding-Brand/GNCIOS -d Latest
@GingerBear
GingerBear / union_type_check.ts
Last active April 19, 2018 20:08
union type check
type typeA = { a: string };
type typeB = { b: string };
type typeAorB = typeA | typeB;
// type check for union type
function isA(foo: typeA | typeB): foo is typeA {
return (<typeA>foo).a !== undefined;
}
// usage
@GingerBear
GingerBear / react-native-git-upgrade-workaround.md
Last active March 2, 2018 15:48
in case react-native-git-upgrade is not working

to update react-native in BBRN:

  • update package.json name to bbrn
  • react-native-git-upgrade 0.54.0
  • will noticed that nothing happened
  • do the following steps perform the actual upgrade

facebook/react-native#12112 (comment)

@GingerBear
GingerBear / gist:2c5eea66180deba994b5c93dc83c506c
Created March 3, 2017 16:29
build.gradle to make react-native-device-info and react-native-maps work together
compile(project(':react-native-device-info')){
exclude group: 'com.google.android.gms', module: 'play-services-gcm'
}
compile 'com.google.android.gms:play-services-gcm:9.8.0'
compile project(':react-native-maps')
@GingerBear
GingerBear / gist:d95fe862a506a2db605ad6026a18bf1c
Last active June 23, 2017 05:12
add text position adjust to tabbar label RCCTabBarController.m
    id imageInsets = tabItemLayout[@"props"][@"iconInsets"];
    if (imageInsets && imageInsets != (id)[NSNull null])
    {
      id topInset = imageInsets[@"top"];
      id leftInset = imageInsets[@"left"];
      id bottomInset = imageInsets[@"bottom"];
      id rightInset = imageInsets[@"right"];
      
      CGFloat top = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:topInset] : 0;
@GingerBear
GingerBear / rename_xcode_project.sh
Created June 7, 2017 16:24
rename xcode project name
# change xcode project name from "BadNamedProject" to "GoodNamedProject"
# change code
grep -r 'BadNamedProject' -l --null . | xargs -0 sed -i '' 's#BadNamedProject#GoodNamedProject#g'
# change filename
find . -depth -name "*BadNamedProject*" -execdir sh -c 'mv {} $(echo {} | sed "s/BadNamedProject/GoodNamedProject/")' \;
@GingerBear
GingerBear / injectCSSToHide.js
Last active May 10, 2017 16:48
inject css to hide elements
function injectCSS(css) {
var style = document.createElement('style');
style.innerHTML = css;
document.head.appendChild(style);
}
document.addEventListener('DOMContentLoaded', function() {
injectCSS('.header-widget {display: none}')
@GingerBear
GingerBear / highlight.js
Last active April 27, 2017 18:47
highlights string by keyword, split into pieces, keep character case
function highlightStr(name, query) {
if (!query)
return [
{
str: name,
isHighlight: false
}
];
const queryRegx = new RegExp(query, "ig");