Skip to content

Instantly share code, notes, and snippets.

View f0-x's full-sized avatar
:bowtie:

Sushant Rajbanshi f0-x

:bowtie:
View GitHub Profile
@f0-x
f0-x / check_limit_response.js
Last active June 26, 2024 07:33
Response Format for check-limit POST API.
{
"success": true | false,
"status_code": 403 | 200,
"message": "Payment limit exceeded" | "Payment can be processed",
"payload": [
{
"limit_exceeds": true | false,
// 'message' is null when none of the limits are exceeded
"message": string | null,
"method_id": 34 | 35 | 36 | 37,
@f0-x
f0-x / flexbox_formula.css
Created March 15, 2024 04:26
Flexbox 1-liner with `calc` & Custom Props
/*🎉 The formula:
calc((100% / var(--columns)) - var(--gap) + (var(--gap) / var(--columns)));
*/
.parent {
--gap: 20px;
--columns: 4;
display: flex;
gap: var(--gap);
flex-wrap: wrap;
@f0-x
f0-x / async_class.ts
Last active March 13, 2024 09:57
Async TS classes using PVT methods
// Erroneous Async Class Declaration ❌
class ConfigurationLoader {
public config: any;
constructor() {
// TypeScript/Javascript Compile-time Error: Constructors cannot contain 'await'
this.config = await fetchConfiguration();
}
}
@f0-x
f0-x / validate_yt_vimeo.ts
Created July 3, 2023 04:27
Validate the existence of Youtube and Vimeo Video
/**
* The function validates whether a given URL is a valid YouTube or Vimeo video link.
* @param {string} url - a string representing the URL of a video from either YouTube or Vimeo.
* @returns A function that takes a string parameter `url` and returns a Promise. The function checks
* if the `url` matches a YouTube URL regex and if the video ID is 11 characters long. If it is a
* YouTube URL, the function creates an image element with the video thumbnail URL and checks if the
* image has a width of 120 pixels. If it does, the function rejects the Promise with
*/
const YOUTUBE_URL_REGEX = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/;
@f0-x
f0-x / funding_eligibility_check.js
Created May 19, 2023 10:15
POST: Check Project's Eligibility
// POST: /checkFundingEligibility
// This API will check if the project is eligible for specific funding option of a funding cycle.
// 'request.json'
{
// As each funding category is going to be unique with its own unique requirements
//
"fundingCategoryId": "1.0.6159e.c100c123",
"projectId": "1.0.3439e.c10012sf"
}
@f0-x
f0-x / Hopin API Collection.postman_collection.json
Created May 16, 2023 06:51
Hopin API Collection for Mihail
{
"info": {
"_postman_id": "b30bce21-92e6-4a66-823f-0be4ff103ac3",
"name": "Hopin API Collection",
"description": "This is the collection of the Hopin External APIs, for more info about APIs, visit [https://developer.hopin.com/external-api](https://developer.hopin.com/external-apiYou)\n\nYou may need to set some variables to execute the APIs as described given below.\n\nOnce you have the ID for the Organization you will need to update the variable value for `organizationId` under the collection folder titled `Hopin API Collection`. \nClick `Hopin API Collection` > `Variables`, update the `organizationId` with your Organization external ID and click `Save`. You can do the same to change/override any variable value.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Health Check",
@f0-x
f0-x / fundingSubmissions.js
Last active June 23, 2023 04:33
Funding Submissions 📝
// After the successfull project's eligiblity check for the specific funding option
// user can trigger this POST Http Call to submit their project for review round 🔍
// POST: /fundingSubmissions 📝
{
"fundingCategoryId": "Unique id of the specific Funding Option of the current funding cycle",
"memberId": "Id of the member who submitted the application",
"projectId": "Id of the project submitted for this funding option",
"projectPosters": [
{
"id": "1.1.64116.af00006c",
@f0-x
f0-x / fundingCycles.js
Last active June 30, 2023 03:56
Funding Cycles 💴
// GET: "fundingCycles" HTTP call should return an array of past, present & future funding cycles/events on Centerframe
// GET: "fundingCycles/id" should return the specific funding cycle/event be it in Past, Present or Future
[
{
"id": "Unique id of the funding cycle",
"title": "Summer Funding Season",
"description": "Description of the Funding Cycle",
"submissionOpensAt": "2023-01-17T08:56:44Z",
"submissionEndsAt": "2023-01-20T08:56:44Z",
// Verifications/Approval of submissions by the Centerframe team
@f0-x
f0-x / react-player.jsx
Created May 1, 2023 05:19
Custom react-player that supports XHR Headers
<ReactPlayer
url={`/bin.oms/${videoId}`}
config={{
file: {
hlsOptions: {
forceHLS: true,
debug: false,
xhrSetup: function (xhr, url) {
xhr.withCredentials = true; // do send cookies
xhr.setRequestHeader(
@f0-x
f0-x / webpageinfo.json
Last active April 20, 2023 03:42
GET : Updated response schema for Webpageinfo endpoint
{
"id": "1.0.6159e.c100dd1b",
"hasCarouselInfo": [
{
"id": "1.0.6159e.c100dd1a",
"content": "0.0.6159e.c100dc10",
"mimeType": "image/png",
"title": "Ravers",
"logLine": "log-line and not empty",
"description": "description and not empty",