Skip to content

Instantly share code, notes, and snippets.

View vipulgupta2048's full-sized avatar
🐣
Working from home

Vipul Gupta vipulgupta2048

🐣
Working from home
View GitHub Profile
@vipulgupta2048
vipulgupta2048 / dev.sh
Last active July 11, 2023 17:21
MIGRATE THEM ALL
#!/usr/bin/env bash
# Script to migrate all local devices between balenaCloud environments. Steps:
# 1. Scan for devices (Needs balenaCLI to be installed)
# 2. SSH into devices and convert all devices to development OS variant
# 3. Once complete, migrate devices to new target environement using balena join
# 4. Shows migrated devices in the new target fleet
# 5. Optionally you can convert all devices back to production OS variant after migration
@vipulgupta2048
vipulgupta2048 / support2.txt
Created June 24, 2021 12:43
balena support gist #2
root@1001010:~# balena run --rm -v /var/run/balena.sock:/var/run/docker.sock pipex/balena-supervisor-stateUnable to find image 'pipex/balena-supervisor-state:latest' locally
latest: Pulling from pipex/balena-supervisor-state
420c7481a3a7: Pull complete
6279047160f4: Pull complete
538d61d4028e: Pull complete
21d08e06a2b7: Pull complete
2f745c6a8f20: Pull complete
b7958bee29b4: Pull complete
78b756b12246: Pull complete
5abcbdc58660: Pull complete
@vipulgupta2048
vipulgupta2048 / support1.txt
Created June 24, 2021 12:42
Support gist balena #1
root@1001010:~# balena run --rm -v /var/run/balena.sock:/var/run/docker.sock pipex/balena-supervisor-state
Unable to find image 'pipex/balena-supervisor-state:latest' locally
latest: Pulling from pipex/balena-supervisor-state
420c7481a3a7: Pull complete
6279047160f4: Pull complete
538d61d4028e: Pull complete
21d08e06a2b7: Pull complete
2f745c6a8f20: Pull complete
b7958bee29b4: Pull complete
78b756b12246: Pull complete
<style type="text/css">
.immersive-reader-button {
background-color: white;
margin-top: 5px;
border: 1px solid black;
float: right;
}
</style>
<body>
<div class="container"><button class="immersive-reader-button" data-button-style="iconAndText data-locale="en"></button>
<h1 id="ir-title">Vipul Gupta's Immersive Reader Demo</h1>
<div id="ir-content" lang="en-us">
<h2>What is Serverless?</h2>
<p>
Serverless computing is a cloud computing execution model in which the cloud provider runs the server, and
dynamically manages the allocation of machine resources. Pricing is based on the actual amount of resources
consumed by an application, rather than on pre-purchased units of capacity or bandwidth.
</p>
@vipulgupta2048
vipulgupta2048 / immersive-ready-html.html
Created April 9, 2021 07:23
Get your HTML ready for the Immersive Reader
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Vipul's Immersive Reader</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<!-- A polyfill for Promise is needed for IE11 support.-->
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script>
@vipulgupta2048
vipulgupta2048 / launch-the-immersive.js
Created April 8, 2021 21:20
Token Fetcher, Immersive Reader Launcher
tokenGetOverHereandLaunch() {
fetch(tokenURL, { credentials: `include`, cache: "no-store" })
.then(response => response.json())
.then(body => {
// https://docs.microsoft.com/en-us/azure/cognitive-services/immersive-reader/reference#chunk
const data = {
chunks: [{
content: htmlContent,
lang: "en-us",
mimeType: "text/html"
@vipulgupta2048
vipulgupta2048 / getTheToken.js
Last active April 8, 2021 21:28
Request to fetch AD token for the Immersive Reader using request
// Making a request to get the token with access to the .env file we created back in step 2
// One can wrap this into a route/endpoint for the frontend to query before starting the Immersive Reader resource
// router.get('/GetTokenAndSubdomain', function(req, res) {
request.post({
headers: { 'content-type': 'application/x-www-form-urlencoded' },
url: `https://login.windows.net/${process.env.TENANT_ID}/oauth2/token`,
form: {
grant_type: 'client_credentials',
client_id: process.env.CLIENT_ID,
@vipulgupta2048
vipulgupta2048 / resource-gen-function guide
Created April 3, 2021 15:42
Azure Immersive Reader resource generator function
Create-ImmersiveReaderResource
-SubscriptionName 'MyOrganizationSubscriptionName' [1]
-ResourceName 'MyOrganizationImmersiveReader' [0]
-ResourceSubdomain 'MyOrganizationImmersiveReader' [0]
-ResourceSKU 'S0' [0]
-ResourceLocation 'westus2' [0]
-ResourceGroupName 'MyResourceGroupName' [2]
-ResourceGroupLocation 'westus2' [2]
-AADAppDisplayName 'MyOrganizationImmersiveReaderAADApp' [3]
-AADAppIdentifierUri 'https://MyOrganizationImmersiveReaderAADApp' [3]
repoUrl: "https://github.com/balena-io-playground/balena-webdriverio"
tarballUrl: "https://github.com/balena-io-playground/balena-webdriverio/archive/master.tar.gz"
applicationConfigVariables:
- RESIN_HOST_CONFIG_gpu_mem: 128
applicationEnvironmentVariables:
- CONFIG_MODE: 0
- CUSTOM_VALUE: my_value
defaultDeviceType: 'fincm3'