Skip to content

Instantly share code, notes, and snippets.

View harish2704's full-sized avatar

Harish Karumuthil harish2704

View GitHub Profile
@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#' )
@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 / example.my.cnf
Last active February 16, 2024 07:26
local mysql server for testing
[mysqld]
innodb_buffer_pool_size=10G
query_cache_size=64M
skip-name-resolve
max_heap_table_size=64M
tmp_table_size=64M
max_connections = 200
innodb_read_io_threads = 64
innodb_write_io_threads = 64
@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 / README.md
Last active November 8, 2023 11:09
A dummy express server which will dump headers , url , method & body of the request

express-dummy-server

@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 / lodash.get.js
Last active June 3, 2023 23:41
Simple lodash.get function in javascript
/* Implementation of lodash.get function */
function getProp( object, keys, defaultVal ){
keys = Array.isArray( keys )? keys : keys.split('.');
object = object[keys[0]];
if( object && keys.length>1 ){
return getProp( object, keys.slice(1) );
}
return object === undefined? defaultVal : object;
}