Skip to content

Instantly share code, notes, and snippets.

View ShawonAshraf's full-sized avatar

Shawon Ashraf ShawonAshraf

View GitHub Profile
@ShawonAshraf
ShawonAshraf / main.py
Created April 12, 2024 15:18
Ollama + Distilabel
import os
import shutil
if os.path.exists(".cache/distilabel"):
shutil.rmtree(".cache/distilabel")
from distilabel.steps.tasks import TextGeneration
from distilabel.steps import LoadHubDataset
from distilabel.pipeline.local import Pipeline
@ShawonAshraf
ShawonAshraf / main.py
Created April 11, 2024 20:11
vllm request
import openai
from pydantic import BaseModel, Field
import json
class ResponseStructure(BaseModel):
bookname: str = Field(..., title="Book Name")
author: str = Field(..., title="Author")
reading_list_name: str = Field(..., title="Reading List Name")
@ShawonAshraf
ShawonAshraf / phase.c
Created October 11, 2023 22:00
STM32 Phase Change
#include "stm32f4xx.h"
#include "stm32f4xx_hal.h"
ADC_HandleTypeDef hadc1;
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC1_Init(void);
int main(void) {
@ShawonAshraf
ShawonAshraf / NatualScrollingInWindows.ps1
Created April 30, 2021 02:06 — forked from 101v/NatualScrollingInWindows.ps1
Powershell script to enable natural scrolling in Windows
# View registry settings
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0
# Change registry settings
# Reverse mouse wheel scroll FlipFlopWheel = 1
# Normal mouse wheel scroll FlipFlopWheel = 0
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }
# Restore default scroll direction
# Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 1 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 0 }
@ShawonAshraf
ShawonAshraf / JSPForm.jsp
Created March 28, 2017 10:16 — forked from abirAbuAsim/JSPForm.jsp
A simple JSP form to insert form data into mySQL database
<!DOCTYPE HTML>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<HTML>
<head>
<title>This is a jsp page</title>
</head>
<body>
import UIKit
import ImageIO
extension CGImagePropertyOrientation {
/**
Converts a `UIImageOrientation` to a corresponding
`CGImagePropertyOrientation`. The cases for each
orientation are represented by different raw values.
- Tag: ConvertOrientation
# Import the required libraries
from collections import defaultdict
# Define the Chu-Liu/Edmonds algorithm function
def chu_liu_edmonds(graph):
# Step 1: Contract the graph to a single node
contracted_node = max(graph.keys()) + 1
contracted_graph = defaultdict(list)
for node in graph:
for (weight, child) in graph[node]:
import pynvml
pynvml.nvmlInit()
device_count = pynvml.nvmlDeviceGetCount()
for i in range(device_count):
try:
handle = pynvml.nvmlDeviceGetHandleByIndex(i)
util = pynvml.nvmlDeviceGetUtilizationRates(handle)
@ShawonAshraf
ShawonAshraf / install_packages.sh
Created March 9, 2017 17:59 — forked from luiscape/install_packages.sh
Install Python dependency packages from requirements.txt using conda.
#
# Original solution via StackOverflow:
# http://stackoverflow.com/questions/35802939/install-only-available-packages-using-conda-install-yes-file-requirements-t
#
#
# Install via `conda` directly.
# This will fail to install all
# dependencies. If one fails,
# all dependencies will fail to install.
import torch.nn as nn
from einops.layers.torch import Rearrange
from transformers import AutoModel
class DummyModel(nn.Module):
def __init__(self, textmodel_weight_name, task_name, batch_size, freeze_text_model=False):
super(DummyModel, self).__init__()
self.task_name = task_name