Skip to content

Instantly share code, notes, and snippets.

View jishanshaikh4's full-sized avatar
🌿

Jishan Shaikh jishanshaikh4

🌿
View GitHub Profile
@jishanshaikh4
jishanshaikh4 / client-local.js
Last active December 13, 2022 08:28
Sample SOAP server + client (for mentee's poc and assignments) -- Implemented clientIP usage/track
"use strict";
var soap = require('strong-soap').soap;
var fetch = require('node-fetch');
var url = 'http://localhost:8000/test?wsdl';
var options = {
endpoint: 'http://localhost:8000/test'
};
var requestArgs = {
@jishanshaikh4
jishanshaikh4 / main.scm
Last active August 21, 2022 18:50
fakeMainOutput.sc
This file has been truncated, but you can view the full file.
// *****************************************************************************************
// *****************************************************************************************
// *****************************************************************************************
// ****************************************PC SA Main Script********************************
// *****************************************************************************************
// *****************************************************************************************
// *****************************************************************************************
SCRIPT_NAME MAIN //NEW MAIN
@jishanshaikh4
jishanshaikh4 / find_thumbnail.sh
Created July 19, 2022 06:01
Find thumbnails for a file in Linux (Solved: Set cache size of thumbnails in dconf-editor)
find_thumbnail(){
full_path="file://$(realpath -s "$1")"
md5name=$(printf %s "${full_path// /%20}" | md5sum)
find ~/.thumbnails/ ~/.cache/thumbnails/ -name "${md5name%% *}.png"
}
Usage:
======
find_thumbnail /path/to/file.bmp
async function jsonFetch<T>(
url: string,
options: RequestInit = {}
): Promise<T> {
// Set the default headers correctly
const headers: HeadersInit = new Headers(options.headers);
headers.set('Accept', 'application/json');
headers.set('Content-Type', 'application/json');
return fetch(url, {
@jishanshaikh4
jishanshaikh4 / index.md
Created June 29, 2022 00:32 — forked from ericandrewlewis/index.md
C++ Pointer Tutorial

C++ Pointer Tutorial

Because pointers can be ugh

"Regular" variables (not pointers)

To understand a pointer, let's review "regular" variables first. If you're familiar with a programming language without pointers like JavaScript, this is what you think when you hear "variable".

When declaring a variable by identifier (or name), the variable is synonymous with its value.

@jishanshaikh4
jishanshaikh4 / npm-packages.md
Last active June 25, 2022 02:18 — forked from NyashaNziramasanga/npm-packages.md
Common NPM packages - Reference

Useful Node Packages

List of useful node packages

A Node Web framework

npm i express --save
@jishanshaikh4
jishanshaikh4 / promise_monad.md
Created June 19, 2022 19:37 — forked from VictorTaelin/promise_monad.md
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@jishanshaikh4
jishanshaikh4 / main.js
Created June 18, 2022 20:48
(Reference) - nodedec.js, sjcl.js, and jquery.protect.js
This file has been truncated, but you can view the full file.
/* Bundle Includes:
* sjcl.js
* nodedec.js
* js/vendor/jquery.js
* js/jquery.protect.js
*/
/** @fileOverview Javascript cryptography implementation.
*
* Crush to remove comments, shorten variable names and
@jishanshaikh4
jishanshaikh4 / setup-postgres.sh
Created June 15, 2022 04:21
Setup postgres in Ubuntu
# Install postgres
sudo apt update
sudo apt install postgresql postgresql-contrib
# Switch to your postgres account/user
sudo -i -u postgres
psql
OR
sudo -u postgres psql
@jishanshaikh4
jishanshaikh4 / regex.md
Last active June 15, 2022 17:50 — forked from cobalt88/Regex URL.md
an example of cmmmon reget