Skip to content

Instantly share code, notes, and snippets.

View phuctm97's full-sized avatar
👨‍💻
Coding

Minh-Phuc Tran phuctm97

👨‍💻
Coding
View GitHub Profile
const url = "http://localhost:8080/login#eyJpbml0Ijp7ImNsaWVudElkIjoiQkMwMXBfanM1S1VJanZxWVlBeldsREt0NmZ0LS01am9WMFRiWkVLTzdZYkRUcW5tVTV2MHNxXzR3Z2t5aDBRQWZaWkFpLXY2bktENGtjeGtBcVB1ajhVIiwibmV0d29yayI6Im1haW5uZXQiLCJyZWRpcmVjdFVybCI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9fQ";
@phuctm97
phuctm97 / .gitconfig
Last active May 24, 2021 10:21
Setup macOS Big Sur
[user]
email = 25026967+phuctm97@users.noreply.github.com
name = Minh-Phuc Tran
[pull]
ff = only
@phuctm97
phuctm97 / torus-firebase-react.js
Created May 5, 2021 04:08
Integrate Torus CustomAuth with Firebase (React)
import { useState } from "react";
import TorusSdk from "@toruslabs/torus-direct-web-sdk";
const App = () => {
const [torusSdk, setTorusSdk] = useState();
const onMount = async () => {
const sdk = new TorusSdk({
baseUrl: `${window.location.origin}/auth`,
enableLogging: true,
@phuctm97
phuctm97 / react.js
Last active May 5, 2022 04:01
Torus React/Firebase login
import { useState } from "react";
import TorusSdk from "@toruslabs/torus-direct-web-sdk";
const App = () => {
const [torusSdk, setTorusSdk] = useState();
const onMount = async () => {
const sdk = new TorusSdk({
baseUrl: `${window.location.origin}/auth`,
enableLogging: true,
@phuctm97
phuctm97 / rn.js
Last active May 5, 2022 04:01
Torus RN Cognito login
import TorusSdk from "@toruslabs/torus-direct-react-native-sdk";
const App = () => {
const onMount = async () => {
await TorusSdk.init({
browserRedirectUri: "YOUR APP REDIRECT URI",
redirectUri: "YOUR APP REDIRECT URI",
network: "testnet"
});
};
@phuctm97
phuctm97 / install-xcode-command-line-tools.sh
Created April 17, 2020 08:15
🔨 Install Xcode Command Line Tools and wait until it's done
#!/bin/bash
# Install XCode Command Line Tools.
xcode-select --install &> /dev/null
# Wait until XCode Command Line Tools installation has finished.
until $(xcode-select --print-path &> /dev/null); do
sleep 5;
done
@phuctm97
phuctm97 / sudo-auth-touch-id-macos.sh
Last active November 7, 2020 01:54
💻 Authenticate sudo using Touch ID on macOS
#!/bin/bash
# This script enables authenticating `sudo` commands using Touch ID on macOS by adding a
# line 'auth sufficient pam_tid.so' to '/etc/pam.d/sudo'.
sudo python <<HEREDOC
import re
pam_cfg = '/etc/pam.d/sudo'
auth_re = re.compile(r'^auth\s+sufficient\s+')
@phuctm97
phuctm97 / get-webpack-alias-from-tsconfig.js
Last active November 2, 2022 06:32
📎 Get Webpack alias from tsconfig.json, aka. convert tsconfig.json paths to Webpack alias
const path = require('path');
/**
* Helper function infers Webpack aliases from tsconfig.json compilerOptions.baseUrl and
* compilerOptions.paths.
*
* @param {string} tsconfigPath - Path to tsconfig.json (can be either relative or absolute path).
* @return {object} An object representing analogous Webpack alias.
*/
module.exports = (tsconfigPath = './tsconfig.json') => {
@phuctm97
phuctm97 / apply.sh
Last active March 19, 2020 12:42
Automation script to configure macOS preferences from command line
#!/bin/bash
osascript -il JavaScript prefs.js
@phuctm97
phuctm97 / dock.sh
Last active March 14, 2020 10:45
macOS preferences
#!/bin/bash
# Enable auto hide.
defaults write com.apple.dock autohide -bool true
# Hide process indicators.
defaults write com.apple.dock show-process-indicators -bool false
# Set orientation.
defaults write com.apple.dock orientation -string left