Skip to content

Instantly share code, notes, and snippets.

View harish2704's full-sized avatar

Harish Karumuthil harish2704

View GitHub Profile
@harish2704
harish2704 / cockpit.conf
Created September 22, 2024 06:59
Cockpit config
# To expose cockpit control panel over SSL, add
Origins = https://cp.dev.mydomain.com wss://cp.dev.mydomain.com
@harish2704
harish2704 / tmux-session.sh
Created March 8, 2024 15:52
Tmux-session
#!/bin/sh
export NODE_OPTIONS=--use-openssl-ca
tmux="tmux -L damp"
$tmux attach
if [ $? -ne 0 ]; then
$tmux new-session -d
$tmux send-keys 'cd ./backend/' Enter
@harish2704
harish2704 / test.dnsmasq
Created February 18, 2024 07:19
test-dnsmasq
address=/.dev.ssrvm.org/3.110.207.103
@harish2704
harish2704 / EventBus.js
Created November 23, 2023 08:47
Simple event bus in Client side JS
// Source: https://itnext.io/handling-data-with-web-components-9e7e4a452e6e
class EventBus {
constructor() {
this._bus = document.createElement('div');
}
register(event, callback) {
this._bus.addEventListener(event, callback);
}
@harish2704
harish2704 / WebhookRelay.php
Created October 19, 2023 18:09
Simple PHP based web-hook multiplexer / relay service
<?php
// A map of "request_path" => Array of target urls.
// Any request coming to "request_path" will be forwarded/relayed to all the urls specified in its value
// fowarding is done asynchronously and concurrntly.
$conf = [
'/mywebook1' => [
'https://testing.myapp.local/webhook/webhook1',
'https://dev.myapp.local/webhook/webhook1',
],
@harish2704
harish2704 / batch-insert-with-query-param.sql
Created October 13, 2023 07:07
pass data as query parameter while using SQL insert into ( batch mode ) statement
INSERT INTO my_table (col_a, col_b)
(SELECT col_a,
col_b
FROM json_populate_recordset(NULL::my_table, ?)
)
-- Here query parameter should be a json collection ( array of objects ) which matches with column names of my_table
@harish2704
harish2704 / async-examples.js
Created July 23, 2023 16:42
async await tutorial
function log(...args) {
console.log(new Date(), ...args);
}
// Compute intensive synchronous task
function doMatrixMult(n) {
let out = 1;
for (let index = 0; index < n; index++) {
out = out + Math.sin(index);
}
@harish2704
harish2704 / simple-db-migrator.php
Created July 20, 2022 23:41
Simple database migration tool written in php
<?php
/*
* ॐ Om Brahmarppanam ॐ
*
* schema/migrator.php
* Created at: Thu Jul 20 2022 19:34:40 GMT+0530 (GMT+05:30)
*
* Copyright 2022 Harish Karumuthil <[email protected]>
*
* Use of this source code is governed by an MIT-style
@harish2704
harish2704 / mysite.nginx.conf
Last active July 16, 2021 21:39
Adminer login plugin for authenticated reverse proxy setup. for eg: auth_request in nginx
location /dba/ {
auth_request /auth/check_login/;
error_page 403 /auth/login/;
# Server running dba tool
proxy_pass http://127.0.0.1:7777/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
auth_request_set $auth_db_vendor $upstream_http_db_vendor;
@harish2704
harish2704 / zypper-print-urls.sh
Last active August 13, 2024 06:13
Print URLs of rpm package instead of downloading while using zypper package manager ( OpenSUSE )
#!/bin/bash
# Usage:
# zypper-print-urls.sh pkg1 pk2 pkg3 ...
# This script actualy create a solver state and
# then derives urls from the sovler state.
solverDir=$(zypper install --debug-solver $@ | grep 'successfully at' | sed 's#Solver test case generated successfully at \(.*\).#\1#' )