Skip to content

Instantly share code, notes, and snippets.

View jdnichollsc's full-sized avatar
🏠
Working from home

J.D Nicholls jdnichollsc

🏠
Working from home
View GitHub Profile
@jdnichollsc
jdnichollsc / README.md
Last active June 8, 2020 06:41
React Native plugin for Mercado Pago (Mobile Checkout)

MercadoPago for React Native (Android & iOS)

A native bridge to use Mercado Pago SDK V4 with React Native.

import MercadoPago from 'react-native-mercado-pago';

async startPayment() {
  try {
    const publicKey = 'TEST-dc0b51e0-0eb7-47ce-b145-5585a0189eb0';
 const preferenceId = '113196323-082708db-09c3-4c7d-a65a-727e237c76e0';
@jdnichollsc
jdnichollsc / demo.js
Last active August 24, 2023 23:20
Hooks with React Native for realtime connection using SignalR with NetInfo and AppState for automatic reconnection
import React, { useEffect } from 'react'
import {
Text
} from 'react-native'
import useSignalR from './useSignalR'
import { getCounterAndToken } from '../services/api'
import { hideError, showErrorAndRetryAction } from '../services/common'
/**
* A hook for getting realtime updates of a counter
@jdnichollsc
jdnichollsc / AnimatableButton.js
Last active February 22, 2020 02:01
Animatable Button using Higher Order Components with React Native and react-native-animatable
import React, { Component } from 'react'
import {
createAnimatableComponent,
initializeRegistryWithDefinitions
} from 'react-native-animatable'
import { Button } from 'native-base'
import { throttle } from 'lodash'
initializeRegistryWithDefinitions({
zoomInOut: {
@jdnichollsc
jdnichollsc / Commands.md
Last active April 12, 2019 19:38
Cordova commands
  • Available ios virtual devices: cordova run ios --list --emulator

  • Available iOS Simulators: cordova emulate ios --list

  • List the available device types: ios-sim showdevicetypes

  • Build in Legacy Mode:

@jdnichollsc
jdnichollsc / Kotlin-Demo.kt
Last active March 22, 2019 23:58
Android - Kotlin
interface Demo {
val context:Context
fun alert(mensaje:String)
{
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}
}
object SimpleSingleton {
    val answer = 42;
@jdnichollsc
jdnichollsc / React Native - iOS.md
Last active March 22, 2019 14:04
React Native - Tips
  • Get root navigation controller
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
UIViewController *rootController = [[delegate window] rootViewController];
UINavigationController *rootNavigationController = (UINavigationController *)rootController;
  • Present view controller
UIViewController *ctrl = [UIViewController new];
@jdnichollsc
jdnichollsc / index.js
Created February 23, 2019 05:43
Get areas of shapes - Hackerrank
const getArea = (shape, values) => {
let area = -1
switch(shape) {
case "square":
area = Math.pow(values[0], 2);
break;
case "rectangle":
area = values[0] * values[1];
break;
case "circle":
@jdnichollsc
jdnichollsc / Termux-config.md
Last active February 15, 2024 12:42
Run React Native apps in x86_64 devices using Termux and TermuxArch and running in a Linux chroot

Ok, if you're a newbie like me this is the process (After enable the termux storage permissions):

Initialize TermuxArch

startarch

Create a backup of your pacman configuration

tar zcf mirrorlist.tar.gz /etc/pacman.d/
cp /etc/pacman.conf storage/downloads/pacman.conf
cp /etc/pacman.d/mirrorlist storage/downloads/mirrorlist
@jdnichollsc
jdnichollsc / Tools
Created January 4, 2019 05:53
Unity Links
## Free
- NuGet For Unity - https://assetstore.unity.com/packages/tools/utilities/nuget-for-unity-104640
- HTTP and REST Client for Unity - https://github.com/proyecto26/RestClient
- Native sharing API (Save media, thumbnail for videos) - https://github.com/olokobayusuf/NatShare-API
- RTS camera - https://assetstore.unity.com/packages/tools/camera/rts-camera-43321
## Other
- Arrow to pointer (card games) - https://assetstore.unity.com/packages/tools/gui/arrow-for-tcg-97386
@jdnichollsc
jdnichollsc / App.js
Last active December 20, 2018 16:15
RenderIfAuthenticated - React Native component to validate if the user has a valid token
import { createStackNavigator } from 'react-navigation'
import LoginComponent from './components/Login'
import HomeComponent from './components/Home'
import SplashComponent from './components/Splash'
import { renderIfAuthenticated } from './components/Auth'
const Main = createStackNavigator(
{
LoginComponent: { screen: LoginComponent },