Skip to content

Instantly share code, notes, and snippets.

View hemanth's full-sized avatar
🐜
🧘‍♂️

Hemanth HM hemanth

🐜
🧘‍♂️
View GitHub Profile
@hemanth
hemanth / summary.py
Created March 12, 2024 00:24
Summarize URL with llama_index and ollama
from llama_index.core import VectorStoreIndex, download_loader
from llama_index.llms.ollama import Ollama
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.core import Settings
from llama_index.llms.ollama import Ollama
from IPython.display import display
Settings.llm = Ollama(model="mistral:latest", request_timeout=30.0)
Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
@hemanth
hemanth / es6-dom-extend.js
Last active January 27, 2024 12:38
Extend DOM elements ES6
class SmartButton extends HTMLButtonElement {
constructor() {}
}
let sb = new SmartButton();
document.body.appendChild(sb);
/*
I get the below error:
TypeError: Failed to execute 'appendChild'
function cd() {
async() {
{
$2 $($1)
}&
}
notify_callback() {
[[ $1 > 0 ]] && echo "You have new stuff to pull!"
}
@hemanth
hemanth / index.js
Created February 24, 2015 09:07
requirebin sketch
clear = require('clear-canvas');
//canvas setup
var canvas = document.createElement('canvas');
canvas.width = '500';
canvas.height = '300';
canvas.style.outline = "1px solid black";
document.body.appendChild(canvas);
// Get the context.
@hemanth
hemanth / devtool.bash
Created November 23, 2013 06:31
Hacking Chrome DevTools Setup
#!/usr/bin/env bash
# Setup script for hacking chrome devtools
# Source -> https://medium.com/p/8c8896f5cef3
echo "Creating folder and initialize a git repo"
mkdir devtools-frontend && cd devtools-frontend
git init
echo "Adding chromium remote and initialize sparse checkout"
git remote add upstream https://chromium.googlesource.com/chromium/blink
@hemanth
hemanth / factorial.py
Created June 27, 2010 09:08 — forked from ghoseb/factorial.py
factorial.py
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@hemanth
hemanth / fast.md
Created September 13, 2012 16:19
Guido van Rossum's Tips for fast Python

Guido van Rossum11 Sep 2012 - Public

Some patterns for fast Python. Know any others?

  • Avoid overengineering datastructures. Tuples are better than objects (try namedtuple too though). Prefer simple fields over getter/setter functions.

  • Built-in datatypes are your friends. Use more numbers, strings, tuples, lists, sets, dicts. Also check out the collections library, esp. deque.

  • Be suspicious of function/method calls; creating a stack frame is expensive.

@hemanth
hemanth / link_list
Created April 9, 2013 05:18
Ask HN: What's the best technical talk you've heard? [Links]
@hemanth
hemanth / Chrome_Features.md
Last active September 25, 2021 18:20
Current Chrome browser features.

img srcset => Enable a responsive images solution by providing the browser multiple resources in varying resolutions for a single image.

Arrow function => The arrow (=>) takes the place of the function keyword

Box Alignment => CSS properties for aligning boxes within their container. Allows for true vertical centering among other features.

DOM3 Keyboard Events => KeyboardEvent: keydown, keyup

Default parameter => Allows formal parameters to be initialized with default values if no value or 2 is passed.

@hemanth
hemanth / chrome-devtools-setup.bash
Last active May 29, 2021 15:22
Build chrome devtools
#!/usr/bin/bash
function colorPrint {
RED='\033[0;31m'
NC='\033[0m' # No Color
printf "${RED}$*${NC}\n"
}
function cloneDepTools {
colorPrint "Cloning depot_tools"