Skip to content

Instantly share code, notes, and snippets.

View onlyoneaman's full-sized avatar
👀
Focussed

Aman (e/acc) onlyoneaman

👀
Focussed
View GitHub Profile
import Cookies from "universal-cookie"
const COOKIE_PATH = "/"
const COOKIE_DOMAIN = "domain.com"
const COOKIE_NAME = "myAuthToken"
const cookies = new Cookies()
export function getToken() {
return cookies.get(COOKIE_NAME)
@onlyoneaman
onlyoneaman / index.js
Created February 12, 2024 18:34
LLM App Worker Code
import { Ai } from './vendor/@cloudflare/ai.js';
export default {
async fetch(request, env) {
const body = await request.json();
const ai = new Ai(env.AI);
const response = await ai.run("@hf/thebloke/llama-2-13b-chat-awq", body);
return new Response(JSON.stringify(response));
},
};
@onlyoneaman
onlyoneaman / VacationPlanner.jsx
Created December 19, 2023 09:39
JSX Component for Building a Vacation Planner using google gemini api
import { useState } from "react";
import "./App.css";
import { GoogleGenerativeAI } from "@google/generative-ai";
function App() {
const [loading, setLoading] = useState(false);
const [apiData, setApiData] = useState([]);
const [place, setPlace] = useState("Bangkok");
const [days, setDays] = useState(3);
const [preferences, setPreferences] = useState("");
@onlyoneaman
onlyoneaman / cosine_similarity.rb
Last active April 4, 2023 07:54
Cosine Similarity
class Cosine
def initialize(vecA, vecB)
@vecA = vecA
@vecB = vecB
end
def calculate_similarity
return nil unless @vecA.is_a?(Array) && @vecB.is_a?(Array) && @vecA.size == @vecB.size
dot_product = @vecA.each_with_object(0).with_index { |(v1i, sum), i| sum += v1i * @vecB[i] }
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
guntur
kakinada
kurnool
nellore
rajamahendravaram
vijayawada
visakhapatnam
warangal
guwahati
patna
@onlyoneaman
onlyoneaman / tier_1_cities.csv
Created January 10, 2023 15:52
Tier 1 Cities
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
delhi
mumbai
bangalore (bengaluru)
chennai
hyderabad
kolkata
ahmedabad
pune
@onlyoneaman
onlyoneaman / shopify_discount_cookie.js
Created August 30, 2022 19:00
Set Shopify Discount Cookie
@onlyoneaman
onlyoneaman / shopify_discount_cookie.js
Created August 25, 2022 16:33
Set Shopify Discount Code for Auto Apply
@onlyoneaman
onlyoneaman / CameraController.cs
Created November 8, 2021 13:10
Camera Controller
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
@onlyoneaman
onlyoneaman / PlayerExtension.cs
Created November 8, 2021 11:22
Roll Ball Player Extension Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
public float speed = 0;
private Rigidbody rb;