Skip to content

Instantly share code, notes, and snippets.

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

Fenil Gandhi fenilgandhi

🏠
Working from home
View GitHub Profile
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AFRAME = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
"use strict";module.exports={createLink:function(e,t){var a=document.head||document.getElementsByTagName("head")[0],n=document.createElement("link");n.href=e,n.rel="stylesheet";
"""
For the given dataframe add a column `result` with specifies whether a student
has passed or failed in their term. Any student is considered pass if all their scores are equal
or above 35
"""
import numpy
import pandas
df = pandas.DataFrame([
{
@fenilgandhi
fenilgandhi / foobar.py
Last active September 14, 2022 07:33
"""
Provide the definition of a function foo which returns the summation of
the given three integers when called as follows
"""
# Add function definition here
## Here result should be 12
import json
class IntHash():
"""
Creates a runtime integer from a given list of integer, strings.
"""
@classmethod
#!/bin/bash
CONFIG_FILE="/tmp/pg_script_config.tmp"
# Function to check if a command is available
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to delete the config file
"""
You are given with two lists, popular_products_ids and viewed_products_ids
- The first list is the list of ids of all popular products that any user would like to view
sorted on their popularity in descending order
- The second list is a list of ids of all products that this user has already viewed.
- Write a function get_fresh_products which return the products which are not yet viewed by
the user while maintaining the sorted order of popularity in an efficient manner
"""
popular_products_ids = list(map(id, range(50000)))
@fenilgandhi
fenilgandhi / compress.py
Created August 12, 2024 19:00
Generate pdf from a images folder
import os
import img2pdf
from PIL import Image
def resize_image(img, max_resolution):
"""Resize image to the maximum resolution while maintaining the aspect ratio."""
width, height = img.size
if max(width, height) > max_resolution:
scaling_factor = max_resolution / float(max(width, height))
new_size = (int(width * scaling_factor), int(height * scaling_factor))