Skip to content

Instantly share code, notes, and snippets.

@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 / react-native-start-with-link.js
Last active January 5, 2023 01:19
start react native bunlder with link
@GingerBear
GingerBear / npm_link_rn.md
Last active May 29, 2018 15:32
npm link in react native
@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 / 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");
@GingerBear
GingerBear / gist:6aedca970faae3d4cbd662e01b982f85
Created March 15, 2017 22:39
react-navigation push and pop
// "react-native": "0.42.0",
// "react-navigation": "^1.0.0-beta.7"
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@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 / gist:36efef9b179bb79ec6b551fed6e6fc99
Created March 8, 2017 19:57
inject js to ios that put catch
document.querySelector('#printLink').addEventListener('click', function() {
var iframe = document.querySelector('.printLink-iframe');
if (!iframe) {
iframe = document.createElement('div');
iframe.style.display = 'none';
iframe.classList.add('printLink-iframe');
}
iframe.innerHTML = '<iframe src="/printLink-iframe"></iframe>';
document.body.appendChild(iframe);