Skip to content

Instantly share code, notes, and snippets.

View itsmunim's full-sized avatar
💂‍♂️
Extension over Modification...please!

Md Abdul Munim itsmunim

💂‍♂️
Extension over Modification...please!
View GitHub Profile

Using scss in NextJS components/modules, the traditional way e.g. by passing the actual classname like a-b-c instead of styles['a-b-c'] might seem a bit harder than expected. But actually it's supported out of the box. Just the next.config.js requires a bit of tweaking.

next.config.js changes

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  webpack(config) {
apiVersion: v1
kind: ConfigMap
metadata:
name: init-container-script
data:
init.sh: |-
#!/bin/sh
echo "Setting up the dependencies..."
# Setup secrethub cli
apk add --repository https://alpine.secrethub.io/alpine/edge/main --allow-untrusted secrethub-cli
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
template:
spec:
# All the volumes we will need
volumes:
# Secrethub service account that will be mounted by kubernetes from specified secret name
# First obtain your doks cluster details
data "digitalocean_kubernetes_cluster" "my_cluster" {
name = var.my_cluster_name # The name of your doks cluster
}
# Supply the cluster details to kubernetes provider
provider "kubernetes" {
host = data.digitalocean_kubernetes_cluster.my_cluster.endpoint
token = data.digitalocean_kubernetes_cluster.my_cluster.kube_config[0].token
cluster_ca_certificate = base64decode(
name: apply-iac
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
@itsmunim
itsmunim / render-helper.js
Created September 28, 2022 02:30
A render helper for react components, supporting SSR too
import { createElement as e } from 'react';
import { createRoot, hydrateRoot } from 'react-dom/client';
/**
* All the root container refs have to be maintained for re-rendering purpose.
*/
const rootMap = {};
/**
* For id less root elements, this will generate a specific prefixed id.
@itsmunim
itsmunim / sample-post.js
Created September 28, 2022 02:15
Sample of a widget library rendering
import { renderToString } from 'react-dom/server';
import { createElement } from 'react';
import * as allWidgets from 'widget-library';
// POST /api/render
const render = (req, res) => {
const { widgetName, props } = req.body;
if (!(widgetName in allWidgets)) {
return res.status(404).json({ error: `Widget with name ${widgetName} not found.` });
scenario1:
matches:
- name: search experience
run:
actions:
- name: open dropdown
selector: id--filter-dropdown
type: click
- name: select prop type
selector: class--filter-prop-type
apiVersion: v1
kind: ConfigMap
metadata:
name: app-secrets
data:
app.env: |-
AWS_ACCESS_KEY={{my-app/credentials/aws/access-key}}
AWS_SECRET_KEY={{my-app/credentials/aws/access-secret}}
MYSQL_USERNAME={{my-app/credentials/mysql/username}}
MYSQL_PASSWORD={{my-app/credentials/mysql/password}}
@itsmunim
itsmunim / deploy-from-pr.yaml
Created December 29, 2021 06:54
A github action workflow, which gets triggered if a PR is opened against master, does deployment from the PR to a DO kubernetes cluster
name: deploy-from-pr
on:
pull_request:
branches:
- master
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}