Posts

MS SQL Server Suspect Query

Image
This is trouble shoot guide for SQL Server suspected database caused by storage issue. Using the Server Studio run the following script EXEC sp_resetstatus 'yourDBname'; ALTER DATABASE yourDBname SET EMERGENCY DBCC checkdb('yourDBname') ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE DBCC CheckDB ('yourDBname', REPAIR_ALLOW_DATA_LOSS) ALTER DATABASE yourDBname SET MULTI_USER Replace the yourDBName with suspected databasee.

Using Drizzle ORM with Nextjs and Sqlite

Image
Drizzle is comparatively simple and performant and easy to use Typescript ORM when compared to other ORMs like Prisma. It is a light weight and has zero dependencies. 

How to redirect a Nextjs route

Image
 We can use the redirect function from next/navigation module to redirect another route. In the route components page just import the module and specify the path to redirect, as follows.           import { redirect } from "next/navigation" ; export default function Home () {   redirect ( '/dashboard' )   return ( ..... .... )     

How to import JSON data in Nextjs with TS Type

Image
 Nextjs is a powerful Reactjs framework which has a good developer experience. In this post I like to show you how to import JSON data file into the Nextjs project with Typescript Type.

How to run HugginFace models in Python

  Hugging Face Hugging face is a machine learning community where you can share pre trained models and explore other trained models, which are suited for many use cases. Many of the models already trained well and ready to use. Without delay get started! Python setup Open your Jupiter notebook or for easy startup without python installation on local machine, use Colab . In this example we are using mistralai/Mistral-7B-v0.1 model. Let's install the transformers module which is the primary dependency for HuggingFace.   conda install transformers Following script will work like a charm . # mistrel model test from transformers import AutoModelForCausalLM, AutoTokenizer model_id = "mistralai/Mistral-7B-v0.1" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id) text = "Hello my name is" inputs = tokenizer(text, return_tensors="pt") outputs = model.generate(**inputs, max_new_tokens=20) print(tokenizer.d...

Zustland : a minimal data store to consider for the Next React Project

 I have been depending on Context for passing state through components in React and eventually things complicated when data is become complex. Move on to beautiful Redux but it is much complex to digest. For learning Redux I have spent lots of time and Redux Toolkit, easy to use Redux, sav ed me a lot. Even though RTK is ok, it is not a simple library. I am fan of Svelte store and Vuex , Pinia store. Is there any such library for React ? I recently found Zustand a minimal store for React. Love it. 😍 Create a store Binding Updating the state Create a store Create a store using the create an d export the custom hook. <pre class='language-javascript'> <code> import create from 'zustand' const useBearStore = create((set) => ({ bears: 0, increasePopulation: () => set((state) => ({ bears: state.bears + 1 })), removeAllBears: () => set({ bears: 0 }), })) </code></pre> Binding In your component use the ho...