Skip to content

Instantly share code, notes, and snippets.

View csantarin's full-sized avatar

Cezar Andrew Villegas Santarin csantarin

View GitHub Profile
@brayhoward
brayhoward / getStatusBarHeight.ts
Last active February 10, 2023 07:32
A react hook for getting status bar height in ReactNative that works with iOS and android. This accounts for hotspot and GPS banners
import { useState, useEffect } from "react";
import { NativeModules, StatusBarIOS, Platform, StatusBar } from "react-native";
import get from "lodash/get";
const { StatusBarManager } = NativeModules;
export default function useStatusBarHeight() {
// Initialize w/ currentHeight b/c StatusBar.currentHeight works properly on android on Android
const [height, setHeight] = useState(StatusBar.currentHeight || 0);
@harveyconnor
harveyconnor / README.md
Created May 26, 2020 01:13
React Native Swift Module Singleton Pattern with Events Example

React Native Swift Module Singleton Pattern

If you are reading this tutorial please be aware that this is for advanced users that require a singleton pattern in their RN native module and some documentation detail is left out intentionally.

For the sake of this tutorial we will be using TestManager as our class.

Instructions

  1. First of all you need to setup a swift class with a bridging header, in Xcode it will generate this for you upon creating a Swift file.
  2. Create your swift class with the @objc directive.
  3. Create a second class that has a static export of the class in singleton.
  4. Follow the files below for a boilerplat example.
@koral--
koral-- / bitrise.yml
Last active December 3, 2021 14:02
Sample Bitrise workflows configuration
---
format_version: '8'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: android
trigger_map:
- push_branch: master
workflow: deploy-staging
- pull_request_source_branch: "*"
workflow: verification
- tag: "*"
@almost
almost / 1-react-native-simulator-and-device.md
Last active November 17, 2022 14:05
Test React Native on the simulator and on a device without editing the code each time!

In the default React Native app scaffolding you have to edit AppDelegate.m to change where it loads the code if you want to test on your device. I use the following snippet to detect if it's being compiled for Debug or Production and for the Simulator or a device. For Production it uses a copy of the code included in the bundle, for Debug on the simualtor it loads from a server on localhost and for Debug on a device it loads from a server on a given IP address.

NOTE: You need to edit YOUR-IP-HERE and change it to the IP to load the code from when in Debug mode on a device. You could use a service like ngrok to make this work from anywhere.

  NSURL *jsCodeLocation;

  // Loading JavaScript code
  #if DEBUG
    // For Debug build load from development server. Start the server from the repository root:
@kungpoo
kungpoo / gist:805727
Created February 1, 2011 11:22
Open new tabs in terminal that are in the same directory
# 1. Add this to your ~/.bash_profile
# 2. Relaunch Terminal
# 3. Open X number of tabs using 'tab' OR 'tab 4' etc.
function tab {
if [ -z "$1" ]; then
TABS=1;
else
TABS=$1
fi
@nruth
nruth / clonetab.rb
Created July 18, 2010 20:25
OSX open new terminal tab @ current pwd
#!/usr/bin/env ruby
require 'fileutils'
extend FileUtils
cmd1 = "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down"
cmd2 = "tell application \"Terminal\" to do script \"cd #{pwd}\" in the front window"
`osascript -e '#{cmd1}' -e '#{cmd2}'`