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 / gist:83d49f529dc84eb7f1e0d8d9a551949e
Created September 19, 2018 06:51 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@pSapien
pSapien / putAtTheEnd.js
Last active October 17, 2019 06:05
a helper function to generate a new array starting from the index next to the lastItem
/**
* a helper function to generate a new array starting from the index next to the *lastItem*
* Eg: insertAtTheEnd(['a', 'b', 'c', 'd'], c) => ['d', 'a', 'b', 'c']
*/
function putAtTheEnd(arr, lastItem) {
const lastIndex = arr.findIndex(n => n === lastItem);
return arr.map((_, i) => {
const startIdx = (lastIndex + i + 1) % arr.length;
return arr[startIdx];
@pSapien
pSapien / capitalize.js
Created October 23, 2019 05:06
capitalize the first character of a string
/**
* @params{string}
* capitalizes the first character of the string
* capitalize('small') => 'Small'
*/
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
@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);
}
@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 / 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 / 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 / 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 / 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 / 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";