Skip to content

Instantly share code, notes, and snippets.

View rahulbanerjee26's full-sized avatar

Rahul Banerjee rahulbanerjee26

View GitHub Profile
test("should print hello world", () => {
// Run the hello command and capture the output
const output = childProcess.execSync(`tcli hello`, {
encoding: "utf8",
});
// Check that the output is correct
expect(output).to.equal("Hello, World!\n");
});
import { before, after, test } from "mocha";
import * as path from "path";
import * as childProcess from "child_process";
before(() => {
childProcess.execSync(`npm install -g`, { cwd: path.join(__dirname, "..") });
console.log("Installed CLI");
});
after(() => {
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh|bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh|bash
import requests
class HashnodePoster:
def __init__(self, token, domain):
self._token = token
self._endpoint = "https://api.hashnode.com"
self._domain = domain
self._headers = {"Authorization": self._token}
self._session = self._create_hashnode_session()
import requests
class DevtoPoster:
def __init__(self, token, domain):
self._token = token
self._domain = domain
self._endpoint = "https://dev.to/api/"
self._headers = {
"Accept": "application/json",
"api-key": self._token,
medium_post_content_html = markDownToHtml(medium_markdown_content)
medium = MediumPoster(MEDIUM_TOKEN, domain)
medium_url = medium.create_post_medium(
title,
medium_post_content_html,
canonicalUrl=wp_post_url,
tags=tags)
print(f'Find Medium Post: {medium_url}')
def create_post_medium(
self,
title,
content,
publish_status="draft",
contentFormat="html",
tags=[],
notifyFollowers = False,
canonicalUrl=None
):
def getUserID(self):
response = self._session.get(f"{self._endpoint}me")
if response.status_code == 200:
return response.json()["data"]["id"]
else:
print("Error while retreiving user id")
print(response)