Skip to content

Instantly share code, notes, and snippets.

@kishlaya
kishlaya / miller-rabin.hs
Last active January 22, 2021 10:17
Miller Rabin Primality Testing in Haskell
import System.Random
import Data.List
main = do
let n = 2^16384 - 1
isPrime n >>= print
isPrime :: Integer -> IO Bool
isPrime n = do
-- if number is small then use deterministic bases
@kishlaya
kishlaya / README.md
Last active December 13, 2018 05:36
Google Vision Text Extraction

Here are the steps to run the google vision API -

  • Install Google Vision API - npm install --save @google-cloud/vision
  • Set enivroenment variable for Google creds - set GOOGLE_APPLICATION_CREDENTIALS=path_to_credentials.json
  • Save all your images to 'images' folder
  • Execute the index.js file - node index.js
@kishlaya
kishlaya / brightness.sh
Created July 23, 2018 06:59
Brightness controller for Linux
#!/bin/sh
xrandr --output LVDS --brightness $1
@kishlaya
kishlaya / Schema.md
Last active June 9, 2018 05:40
MongoDB schema design for storing DEB data

Problem

We need to solve the problem of storing the DEB data efficiently into the MongoDB databse so that the following use cases are covered -

  • For a given ticker. fetch the data from all the indicators
  • For a given indicator, fetch all the data from each ticker.

Proposal 1

Let's say we have m tickers, call them {ticker_1, ticker_2, ..., ticker_m} and n indicators, call them {indicator_1, indicator_2, ..., indicator_n}

@kishlaya
kishlaya / servant-opaleye.hs
Last active May 9, 2018 15:44
Simple CRUD app in Haskell (using servant and opaleye)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
5 20
73
91
66
85
16
33
96
3
74
@kishlaya
kishlaya / fibonacci.hs
Created August 5, 2017 07:17
Fibonacci List Generator in Haskell
fib :: [Integer]
fib = 0 : 1 : zipWith (+) fib (tail fib)