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 / ABC.md
Last active April 16, 2024 03:40
The Job Interview Guide

The Job Interview Guide 💼

And English is a Work in Progress ⌛

@jdnichollsc
jdnichollsc / RandomNumber.sol
Last active March 18, 2024 15:16
Create a Random Number with Chainlink
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import {VRFCoordinatorV2Interface} from "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import {VRFConsumerBaseV2} from "@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.sol";
import {ConfirmedOwner} from "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol";
// Fuji Testnet: 0xb9477bfbCAe729643b8251404Fa6E4356bB3d9A3
contract RandomNumber is VRFConsumerBaseV2 {
VRFCoordinatorV2Interface COORDINATOR;
@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 / storage.ts
Last active February 8, 2024 10:17
Upload Base64/Blob files to Google Cloud Storage
import { join } from 'path'
import { get } from 'lodash'
import { Storage } from '@google-cloud/storage'
import { BUCKET_NAME } from '../constants'
import { base64MimeType } from '../utils'
const gcloudPathKey = join(__dirname, '../gcloud-key.json')
const storage = new Storage({
projectId: 'my-project-id',
@jdnichollsc
jdnichollsc / boot.js
Last active January 7, 2024 02:34
Phaser Landscape Orientation
var bootState = {
preload: function () {
this.game.load.image('loading', 'assets/loading.png'); //Load images to show progress bar in the next state
this.game.load.image('loadingborder', 'assets/loadingborder.png');
this.game.stage.backgroundColor = '#A5DEF1'; //Change background color if you want
},
create: function () {
//Configure plugins like better transitions
this.game.stateTransition = this.game.plugins.add(Phaser.Plugin.StateTransition);
this.game.stateTransition.configure({
@jdnichollsc
jdnichollsc / b64toBlob.js
Last active December 11, 2023 07:21
Convert to Blob with Javascript
//By https://codedump.io/share/Fd3DmsM6UAeS/1/creating-a-blob-from-a-base64-string-in-javascript
//Example
//var blob = b64toBlob(b64Data, contentType);
//var blobUrl = URL.createObjectURL(blob);
function b64toBlob(b64Data, contentType, sliceSize) {
contentType = contentType || 'image/png';
sliceSize = sliceSize || 512;
var byteCharacters = atob(b64Data);
var byteArrays = [];
@jdnichollsc
jdnichollsc / CHAINLINK.md
Last active November 5, 2023 15:42
Bootcamp para Desarrolladores de Smart Contracts
@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 / useMarketplace.ts
Created July 1, 2023 00:50
Custom hook for infinite scrolling using React Query
import { useInfiniteQuery } from '@tanstack/react-query';
import { MarketplaceItem } from '../models';
import { getMarketplaceItems } from '../services';
export type UseMarketplaceItemsProps = {
query: string;
initialData?: MarketplaceItem[];
from?: number;
size?: number;
@jdnichollsc
jdnichollsc / alternative_for_own_packages.js
Last active June 23, 2023 02:13
Fix RemixJS issues; "process is not defined" & "Buffer is not defined" - discussion related https://github.com/remix-run/remix/discussions/4906
// This is optional, only for building your own npm packages using those polyfills
// This is not useful to fix issues from external packages like web3 dependencies
import { Buffer } from "buffer"
import * as process from "process"
globalThis.Buffer = Buffer as unknown as BufferConstructor;
globalThis.process = process as unknown as NodeJS.Process;
// So only use this alternative if you don't want to use the below patch fix for RemixJS!