Skip to content

Instantly share code, notes, and snippets.

View pSapien's full-sized avatar
💭
Finding ways to run my life with code.

Prateek Thapa pSapien

💭
Finding ways to run my life with code.
View GitHub Profile
@pSapien
pSapien / BezierBall.tsx
Created March 5, 2024 06:35
Bezier Curve Animation in react native
import React from 'react';
import { useRef } from 'react';
import { Animated, Button, StyleSheet, View, useWindowDimensions } from 'react-native';
const half = (v: number) => Math.floor(v / 2);
export function ChatContainer() {
const { height, width } = useWindowDimensions();
const animRef = useRef(new Animated.Value(0));
const ballRef = useRef<View>(null);
@pSapien
pSapien / admob.ts
Created August 3, 2023 12:45
react-native hooks that uses the native binding for yodomas sdk
import React, { useEffect, useState } from 'react';
import { NativeModules, NativeEventEmitter, EmitterSubscription, Button } from 'react-native';
const { Yodo1MASAds } = NativeModules;
const Constants = {
EVENT_NAME: 'yodo1ad',
INIT_SUCCESS: 'init-success',
INIT_FAILURE: 'init-failure',
REWARD_LOAD_SUCCESS: 'reward-load-success',
@pSapien
pSapien / Yodo1MASAds.java
Last active September 1, 2023 09:03
A bridged module for React Native and uses the Yodo1Mas android SDK to handle ads
package com.bhoos.sdk;
import android.app.Activity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
@pSapien
pSapien / Yodo1MASAds.m
Created August 2, 2023 05:33
A bridged module for React Native and uses the Yodo1Mas SDK to handle ads.
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
#import <Yodo1MasCore/Yodo1Mas.h>
NSString * const EVENT_NAME = @"yodo1ad";
NSString * const INIT_SUCCESS = @"init-success";
NSString * const INIT_FAILURE = @"init-failure";
NSString * const REWARD_LOAD_SUCCESS = @"reward-load-success";
NSString * const REWARD_LOAD_FAILURE = @"reward-load-failure";
@pSapien
pSapien / filter.type.ts
Last active May 28, 2022 06:04
filtering types from an interface or type using conditionals.
type Job = {
id: string;
salary: number;
title: string;
}
interface User {
id: string;
name: string;
company: string;
@pSapien
pSapien / homebrew-permissions-issue.md
Created December 30, 2021 06:51 — forked from irazasyed/homebrew-permissions-issue.md
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*

@pSapien
pSapien / react-native-reanimated-drag-sort_apple-music.jsx
Created June 28, 2021 04:31 — forked from eveningkid/react-native-reanimated-drag-sort_apple-music.jsx
React Native Reanimated 2 Multiple Drag and Sort: Apple Music Example
// Expo SDK40
// expo-blur: ~8.2.2
// expo-haptics: ~8.4.0
// react-native-gesture-handler: ~1.8.0
// react-native-reanimated: ^2.0.0-rc.0
// react-native-safe-area-context: 3.1.9
import React, { useState } from 'react';
import {
Image,
@pSapien
pSapien / useEvent.js
Created September 14, 2020 13:30
Event driven approach in react
/**
*. useEvent hook
*
* @example
const { dispatch, on, events } = useEvents();
useEffect(() => on('MyEvent', (data) => { ...do something...}));
*/
const events = [];
@pSapien
pSapien / regexCheatsheet.js
Created November 3, 2019 06:26 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@pSapien
pSapien / removeFirst.js
Last active October 31, 2019 12:06
remove first element of an array.
/**
* @params{array}
* remove first element of an array.
* removeFirst([4,46,312,12313,123123]) => [46, 312, 12313, 123123]
*/
function removeFirst(arr) {
return arr.slice(1);
}