Skip to content

Instantly share code, notes, and snippets.

View rahsheen's full-sized avatar

Rahsheen Porter rahsheen

View GitHub Profile
@rahsheen
rahsheen / clone-bare-dotfiles.sh
Created March 3, 2024 16:14
Script to clone dotfiles bare repo on new system
# Based on https://www.atlassian.com/git/tutorials/dotfiles
git clone --bare https://bitbucket.org/durdn/cfg.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
@rahsheen
rahsheen / hookDaddy.ts
Last active February 7, 2024 15:16
How to see which Components are calling your hook
// Drop this into your hook
// Do not wrap in a useEffect
function whoIsMyDaddy() {
try {
throw new Error()
} catch (e) {
// matches this function, the caller and the parent
const allMatches = e.stack.match(/(\w+)@|at (\w+) \(/g)
// match parent function name
const parentMatches = allMatches[2].match(/(\w+)@|at (\w+) \(/)
@rahsheen
rahsheen / gist:b86c2a2054672155a25be7ffcbbe5234
Last active May 12, 2023 17:35
error log 1.15.1 -- /Users/rahsheen.porter/.local/state/eng-remote-env/run-20230512-173442-deploy-env.log
INIT <str> eng-remote-env@1.15.1 deploy-env
stacks.get_default_stack_name:CALL <str>
utils.read_environ:CALL <str>
utils.read_environ:ARG <str> GITHUB_USERNAME
utils.read_environ:RETURNS <str> rahsheen
stacks:DATA:login <str> rahsheen
stacks:DATA:name <str> dev-rahsheen
stacks:DATA:name <str> dev-rahsheen
stacks:DATA:name <str> dev-rahsheen
stacks:DATA:name <str> dev-rahsheen
@rahsheen
rahsheen / [...auth].ts
Created October 8, 2021 14:11
Blitz+Shopify Passport Config
import { passportAuth } from "blitz"
import db from "db"
import { Strategy as ShopifyStrategy } from "passport-shopify"
import { OAuth2Strategy as GoogleStrategy } from "passport-google-oauth"
export default passportAuth(({ ctx, req, res }) => ({
successRedirectUrl: "/",
errorRedirectUrl: "/",
strategies: [
{
@rahsheen
rahsheen / counterSlice.ts
Last active March 28, 2021 19:31
How to Break extraReducers
import {createAsyncThunk, createSlice, PayloadAction} from '@reduxjs/toolkit';
import {RootState} from '../../app/store';
interface CounterState {
value: number;
status: 'idle' | 'loading' | 'failed';
}
const initialState: CounterState = {
value: 0,
@rahsheen
rahsheen / WSL2 React Native NPM Scripts.json
Last active November 28, 2020 06:13
NPM Script modifications for running React Native projects in WSL2.
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start --host 127.0.0.1",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"stop-winadb": "/mnt/c/Users/YOURNAME/AppData/Local/Android/Sdk/platform-tools/adb.exe kill-server",
"start-winadb": "/mnt/c/Users/YOURNAME/AppData/Local/Android/Sdk/platform-tools/adb.exe -a nodaemon server start",
"winadb": "yarn stop-winadb && yarn start-winadb",
"socat": "socat -d -d TCP-LISTEN:5037,reuseaddr,fork TCP:$(ip route|grep default|cut -d ' ' -f3):5037",
@rahsheen
rahsheen / shopifyBrowserSyncServer.js
Created November 10, 2020 02:39
BrowserSync Config for Shopify (Slate) Which Can Be Modified and Used with Themekit
const browserSync = require('browser-sync');
const {getStoreValue, getThemeIdValue} = require('@shopify/slate-env');
const {getSSLKeyPath, getSSLCertPath} = require('../utilities');
class DevServer {
constructor(options) {
this.bs = browserSync.create();
this.target = `https://${getStoreValue()}`;
this.themeId = getThemeIdValue();
this.port = options.port;
@rahsheen
rahsheen / location-context.tsx
Last active July 21, 2020 13:52
Expo Location Context Provider
import React, { createContext, useEffect, useState } from "react";
import { ActivityIndicator, Text } from "react-native-paper";
import { View } from "react-native";
import * as Location from "expo-location";
interface LocationContextType {
location?: Location.LocationData;
refresh: () => void;
error: string;
loading: boolean;
import Controller from '@ember/controller';
import { action, computed } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@tracked searchString;
@action
updateSearchString(value) {
import Controller from '@ember/controller';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@action
onSelect(index) {
this.selectedIndex = index;
}