Skip to content

Instantly share code, notes, and snippets.

View sandeep1995's full-sized avatar
🏠
Working from home

Sandeep Acharya sandeep1995

🏠
Working from home
View GitHub Profile

Top {{[totalCount]}} Unicorns of {{[country]}}

prompt(Write some sentences on How the country {{[country]}} pushing it's tech culture) genimage(City view of {{[city]}}, {{[country]}})

{{#each countries}} prompt(SEO friendly introduction on the company {{[company]}}) Company: {{[company]}} Valuation: {{[valuation_in_billion]}} Billion dollars Investors: {{[investors]}}

@sandeep1995
sandeep1995 / bug.js
Last active January 26, 2023 18:59
Code stuck here!!!
const text = '"Before we jump into the content itself, I wanted to set a few expectations that will be really important for us to carry as we embark on this journey," James said. "And the first is that finding consensus on a preferred scenario for the future of the airport will take time because — as we’ve seen in our own advanced planning efforts over the past several years, as well as in other communities that have wrestled with airport conversions, or military base conversions, or the reuse of large public parcels — the planning process can last from a few years, if you’re lucky, up to 25 years and implementation can, and will, span decades."';
text.match(/^(\s*)(\S+(?:[ \t\v]*\S+)*)(\s*)$/);
@sandeep1995
sandeep1995 / worker.js
Created September 29, 2022 08:33
DocsWrite Complete Blogging Platform on top of Google Docs. This small code shows how to have the blog running at `/blog` using Cloudflare worker.
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
let url = new URL(request.url);
@sandeep1995
sandeep1995 / firebase.function.js
Created July 5, 2022 17:52
Docswrite sub directory hostings for firebase
exports.blog = functions.https.onRequest((request, response) => {
let url = new URL(request.url);
url.hostname = "blog.docswrite.blog"; // use your docswrite url
url.pathname = url.pathname.replace('/blog', '');
fetch(url, request).then(d => d.text()).then(res => response.send(res));
});
@sandeep1995
sandeep1995 / sub-directory-blog-cf.js
Created June 30, 2022 11:51
Docswrite.com blogs sub directory /blog hosting using Cloudflare workers
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
let url = new URL(request.url);
// add loading="lazy" for all images
const images = dom.window.document.querySelectorAll('img[src]');
Array.prototype.forEach.call(images, (img) => {
img.setAttribute('loading', 'lazy');
});

Keybase proof

I hereby claim:

  • I am sandeep1995 on github.
  • I am isandeep (https://keybase.io/isandeep) on keybase.
  • I have a public key ASACYsNw_AFa2O7dxPCjTBB11MbfIlpHPY3Qc3vnyWNzMAo

To claim this, I am signing this object:

@sandeep1995
sandeep1995 / main.js
Created July 23, 2018 12:49
Guess the output of the following javascript code snippet.
const log = (msg) => console.log(msg);
log('First');
Promise.resolve().then(() => {
log('From promise');
})
requestAnimationFrame(() => {
log('From animation frame');
@sandeep1995
sandeep1995 / lifeCycleManager.demo.js
Last active June 12, 2018 06:37
Example of promise based event hooking
const lifeCycleInstance = Symbol('LifeCycleInstance');
const singletonEnforcer = Symbol('SingletonEnforcer');
const VU_DRAWN_EVT = 'visual-unit.drawn';
const CANVAS_INIT_EVT = 'canvas.init';
const EVENT_LIST = [VU_DRAWN_EVT, CANVAS_INIT_EVT];
const resolver = resolveFn => notifier => resolveFn(notifier);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">