Skip to content

Instantly share code, notes, and snippets.

View naishe's full-sized avatar
🚀
Let's Launch This Thing!

Nishant Neeraj naishe

🚀
Let's Launch This Thing!
View GitHub Profile
@naishe
naishe / restore-rkestate-file.md
Created April 4, 2023 15:12 — forked from superseb/restore-rkestate-file.md
Recover cluster.rkestate file from controlplane node

Recover cluster.rkestate file from controlplane node

RKE

Run on controlplane node, uses any found hyperkube image

k8s 1.19 and higher

docker run --rm --net=host -v $(docker inspect kubelet --format '{{ range .Mounts }}{{ if eq .Destination "/etc/kubernetes" }}{{ .Source }}{{ end }}{{ end }}')/ssl:/etc/kubernetes/ssl:ro --entrypoint bash $(docker inspect $(docker images -q --filter=label=org.label-schema.vcs-url=https://github.com/rancher/hyperkube-base.git) --format='{{index .RepoTags 0}}' | tail -1) -c 'kubectl --kubeconfig /etc/kubernetes/ssl/kubecfg-kube-node.yaml -n kube-system get configmap full-cluster-state -o json | jq -r .data.\"full-cluster-state\" | jq -r .' > cluster.rkestate
@naishe
naishe / get-kube-admin-kubecfg-certs-from-cluster-rkestate.md
Created April 4, 2023 15:11 — forked from superseb/get-kube-admin-kubecfg-certs-from-cluster-rkestate.md
Get kube-admin kubeconfig and certificates from cluster.rkestate

Get kube-admin kubeconfig and certificates from cluster.rkestate

See how to retrieve cluster.rkestate from controlplane node here: https://gist.github.com/superseb/e9f2628d1033cb20e54f6ee268683a7a

Get kube-admin kubeconfig from cluster.rkestate

cat cluster.rkestate | jq -r '.currentState.certificatesBundle."kube-admin".config' > kube-admin-kubeconfig.yml
@naishe
naishe / SomeComponent.tsx
Created October 15, 2021 11:45
fetch version from package.json
{/** Relative path of package.json from the component */}
<Text>{require('../../package.json').version}</Text>
@naishe
naishe / package.json
Created October 15, 2021 11:40
postversion script
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
// Append this new lifecycle script
"postversion": "cd android && ./gradlew bundleRelease"
},
@naishe
naishe / build.gradle
Created October 15, 2021 11:30
Update the version section
defaultConfig {
applicationId YOUR_APPLICATION_ID
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
// UPDATE THESE VALUES WITH THE FUNCTION CALLS
versionCode getNumericVersionFromNpm()
versionName getVersionFromNpm()
}
@naishe
naishe / build.gradle
Created October 15, 2021 11:23
Add Scripts to android/app/build.gradle to pick version code and version name from package.json
// Import JSON parser, place it at the top of the file
import groovy.json.JsonSlurper
// Read package.json and return `version` field
def getVersionFromNpm() {
// Read and parse package.json file from project root
def inputFile = new File("$rootDir/../package.json")
def packageJson = new JsonSlurper().parseText(inputFile.text)
@naishe
naishe / App.jsx
Created December 6, 2020 10:06
Deep Linking Push Notifications with React Navigation #0
// Simple scenario without nested routes, without path parameters
function App() {
const navigation = useNavigation();
const [loading, setLoading] = useState(true);
const [initialRoute, setInitialRoute] = useState('Home');
useEffect(() => {
// Assume a message-notification contains a "type" property in the data payload of the screen to open
@naishe
naishe / App.tsx
Created December 6, 2020 09:51
Deep Linking Push Notifications with React Navigation #6
// App.tsx
// only new changes shown, refer: https://gist.github.com/naishe/46dfb1e23612398e4bd525f03c001dd9
const linking: LinkingOptions = {
prefixes: ['myapp://', 'https://app.myapp.com'],
config: deepLinksConf,
async getInitialURL() { /* redacted */ },
subscribe(listener) {
const onReceiveURL = ({url}: {url: string}) => listener(url);
@naishe
naishe / App.tsx
Created December 6, 2020 09:46
Deep Linking Push Notifications with React Navigation #5
// App.tsx
// only new changes shown, refer: https://gist.github.com/naishe/da4830b72eeb81f8a5e29b6e45692d86
const linking: LinkingOptions = {
prefixes: ['myapp://', 'https://app.myapp.com'],
config: deepLinksConf,
async getInitialURL() {
// Check if app was opened from a deep link
const url = await Linking.getInitialURL();
@naishe
naishe / open-app.sh
Last active December 6, 2020 09:37
Deep Linking Push Notifications with React Navigation #4
# Assuming you have a key, “settings”, configured in your
# linking config that points to a valid screen
# The following command should show you a popup asking
# which app you want to use to open this link and offer you
# two options (normally) between the browser and your app.
npx uri-scheme open https://app.myapp.com/settings --android
# The following command should open your app
# and lands you on the settings page