Skip to content

Instantly share code, notes, and snippets.

View lukebrandonfarrell's full-sized avatar
✌️
fixing bugs since 1996

Luke Brandon Farrell lukebrandonfarrell

✌️
fixing bugs since 1996
View GitHub Profile
@lukebrandonfarrell
lukebrandonfarrell / ExifData.swift
Created June 8, 2022 16:10
A Swift class for extracting exif data from URL, UIImage or Data types 🔭
//
// ExifData.swift
// Qeepsake
//
// Created by Luke Farrell on 26/05/2022.
//
import Foundation
import ImageIO
@lukebrandonfarrell
lukebrandonfarrell / collapsable.js
Last active January 29, 2024 14:49
Collapsable header in React Native
import React, { useRef } from "react";
import { View, Animated, Image, ScrollView, Text } from "react-native";
const H_MAX_HEIGHT = 150;
const H_MIN_HEIGHT = 52;
const H_SCROLL_DISTANCE = H_MAX_HEIGHT - H_MIN_HEIGHT;
const CollapsibleHeader = () => {
const scrollOffsetY = useRef(new Animated.Value(0)).current;
const headerScrollHeight = scrollOffsetY.interpolate({
@lukebrandonfarrell
lukebrandonfarrell / latest_googleplay_version_code.rb
Created February 22, 2021 10:50
Gets the latest Google Play version code using Fastlane google_play_track_version_codes
def latest_googleplay_version_code
productionVersionCodes = google_play_track_version_codes(track: 'production')
betaVersionCodes = google_play_track_version_codes(track: 'beta')
alphaVersionCodes = google_play_track_version_codes(track: 'alpha')
internalVersionCodes = google_play_track_version_codes(track: 'internal')
# puts version codes from all tracks into the same array
versionCodes = [
productionVersionCodes,
betaVersionCodes,
import React, { ReactElement } from 'react';
import { StyleSheet, TouchableOpacity } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons';
import { Subtitle } from '../subtitle/subtitle';
import { defaultStyle } from '../../styles/theme.style';
interface DateSelectProps {
label: string | undefined;
handlePickerOpen: () => void;
testID?: string;
@lukebrandonfarrell
lukebrandonfarrell / ActionReducer.js
Last active March 4, 2023 12:57
A hook to listen to Redux actions in your component.
const initialState = {
type: null,
payload: null,
meta: null,
error: false
};
export default (state = initialState, action) => {
return {
...state,
@lukebrandonfarrell
lukebrandonfarrell / Sourcemaps.ruby
Created May 16, 2022 12:09
Fastlane / Sentry Sourcemaps
lane :upload_sourcemaps do |options|
platform = options[:platform] || "ios"
version = options[:version] || get_version_number(xcodeproj: './ios/qeepsake.xcodeproj')
build_number = options[:build_number] || (platform == "ios" ? get_build_number(xcodeproj: "./ios/qeepsake.xcodeproj") : get_version_code())
bundle_name = platform == "ios" ? "main.jsbundle" : "index.android.bundle"
app_id = platform == "ios" ? "co.qeepsake.qeepsake" : "co.qeepsake.qeepsakeApp"
os_bin = platform == "ios" ? "osx-bin" : "linux64-bin"
puts "uploading sourcemaps for platform #{platform}, version #{version}, and build #{build_number}..."
sh("cd .. &&
@lukebrandonfarrell
lukebrandonfarrell / workspace-screen.js
Created May 25, 2021 10:37
Example of Animated re-ordering of a list in React Native using React Spring
/* NPM - Node Package Manage */
import React from 'react';
import { View, ScrollView } from 'react-native';
import { useTransition, animated } from "@react-spring/native";
/** Constants */
const AnimatedView = animated(View);
const ListItemHeight = 190;
export function WorkspaceScreen() {
const edges = [...];
@lukebrandonfarrell
lukebrandonfarrell / useKeyboardStatus.js
Created October 11, 2019 11:27
Hook to return if the react-native keyboard is open / closed
import React, { useState, useRef } from "react";
import { Keyboard } from "react-native";
/**
* Returns if the keyboard is open / closed
*
* @return {bool} isOpen
*/
export function useKeyboardStatus(){
const [isOpen, setIsOpen] = useState(false);
@lukebrandonfarrell
lukebrandonfarrell / AppDelegate.m
Last active April 13, 2021 17:30
Perfect splash screen for iOS in React Native with fade animation (no dependancies!)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"MyApp" initialProperties:nil];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
@lukebrandonfarrell
lukebrandonfarrell / handleBackPress.js
Last active August 20, 2020 14:10
Hook to handle back press on Android in React Native with an exit alert.
import { Alert, BackHandler } from "react-native";
/*
* If we are using React Native Navigation
* the BackHandler.exitApp() will in some
* cases invoke a pop instead of exiting
* the application. Using the following
* library solves this issue:
*
* import RNExitApp from "react-native-exit-app";