Skip to content

Instantly share code, notes, and snippets.

@sagarpanda
sagarpanda / README.md
Created August 10, 2025 08:01
SSH enabled Ubuntu container

SSH enabled Ubuntu container

# Dockerfile
FROM ubuntu:latest
LABEL maintainer="Your Name <[email protected]>"

# Install OpenSSH server and sudo
RUN apt update && apt install -y openssh-server sudo
@sagarpanda
sagarpanda / Dockerfile
Created August 10, 2025 06:11
Run container as non-root
# create group and user
RUN groupadd -r myapp && useradd -g myapp myapp
# set ownership and permissions
RUN chown pr myapp:myapp /app
# switch to user
USER myapp
CMD node index.js
@sagarpanda
sagarpanda / OpenVSCode Dockerfile
Last active October 12, 2024 11:30
openvscode server
FROM gitpod/openvscode-server:latest
SHELL ["/bin/bash", "-c"]
ENV OPENVSCODE_SERVER_ROOT="/home/.openvscode-server"
ENV OPENVSCODE="${OPENVSCODE_SERVER_ROOT}/bin/openvscode-server"
ENV SERVER_BASE_PATH="/code/xyz"
USER root
RUN apt update -y
@sagarpanda
sagarpanda / in-memory-sqlite-database.js
Created November 7, 2021 07:08
SQL Lite is an in-process database which can write either to a disk file or to memory.
const sqlite3 = require('sqlite3').verbose();
let db = new sqlite3.Database(':memory:');
let db = new sqlite3.Database(':memory:', (err) => {
if (err) {
return console.error(err.message);
}
console.log('Connected to the in-memory SQlite database.');
});
variables:
GIT_USER_NAME: "Build Bot"
GIT_USER_EMAIL: "[email protected]"
GIT_REPO_URL: "[email protected]:username/repo_name.git"
CI_PROJECT_ID: "1002"
CI_JOB_TOKEN: $GH_TOKEN
GL_TOKEN: $GH_TOKEN
GL_SSH_KNOWN_HOSTS: $SSH_HOST_KEY
GL_SSH_PRIVATE_KEY: $SSH_PRIVATE_KEY
@sagarpanda
sagarpanda / global_scope.ts
Created April 23, 2020 17:17
global scope in ts
declare global {
var foo: string;
}
globalThis.foo = 'Welcome !!!';
// foo value can be checked on browser console
const shortPolling = (fn, interval) => {
let counter = 1;
const _interval = interval || 1000;
const next = (params) => {
setTimeout(() => {
counter += 1;
fn(next, counter, params);
}, _interval);
};
fn(next, counter);
async function fetchGoogleSheetFeed({spreadsheetId, sheetNum}) {
const tab = sheetNum || 1;
const fetchUrl = `https://spreadsheets.google.com/feeds/cells/${spreadsheetId}/${tab}/public/full?alt=json`;
const data = await fetch(fetchUrl).then(response => {
if(response.status === 200) {
return response.json();
} else {
return { feed: { entry: [] }};
}
});
@sagarpanda
sagarpanda / withFinal.js
Last active February 8, 2020 18:06
react final form HOC
import React from 'react';
import { Field } from 'react-final-form';
const withFinal = Component => {
const { finalProps: fnlProps } = Component;
// eslint-disable-next-line react/prop-types
const fieldRenderer = ({ input, ...rest }) => {
let extented = {};
if (fnlProps) {
const keys = Object.keys(fnlProps);
@sagarpanda
sagarpanda / node-http-server.js
Created December 28, 2019 16:46
Handle POST and GET request method in http server
var http = require('http');
var url = require('url');
function processPost(request, response, callback) {
var queryData = "";
if(typeof callback !== 'function') return null;
if(request.method == 'POST') {
request.on('data', function(data) {
queryData += data;