Skip to content

Instantly share code, notes, and snippets.

View kayvank's full-sized avatar
🏠
@127.0.0.1

Kayvan ≅ کیوان kayvank

🏠
@127.0.0.1
View GitHub Profile

Questions

1. Explain the performance of the following programs

def findElement(e: String, dict: Map[String, Any]): Option[Any] =
dict.get(e) 

Regardless of Map implementation, maps are key value. dict.get is a key look up that returns Some(value) or None. The performance characteristic is eC, Effectively Constant. Depending on Map implementation the performance characteristic is O(1) for hash map, O(log n) for tree implementations like.

@kayvank
kayvank / mpg
Created February 19, 2020 08:23
mpg
{
"pid": "1a003a001747373333353132",
"ts": "2020-02-19T07:26:16.337Z",
"body": {
"r": 123,
"sf": 123,
"o": 1,
"sp": 60,
"cc_st": 60,
"cc_sp": 60,
module Main where
import Split.LibSplit
main :: IO()
main = do
input <- getLine
let result = ourSplit input
print result
---------------------------
module Main where
import Split.LibSplit
main :: IO()
main = do
input <- getLine
let result = ourSplit input
print result
---------------------------
@kayvank
kayvank / journalctl -xe
Last active April 9, 2020 20:59
opensuse-tumbleweed displaylink stopped working with the last opensuse update
laptop: thinkpad p1, Intelxeon, nvidia GPU
➜ uname -r
5.6.0-1-default
cat /etc/os-release
---------------start cut&paste ----------------
NAME="openSUSE Tumbleweed"
# VERSION="20200402"
ID="opensuse-tumbleweed"
@kayvank
kayvank / sudo lspci -nnk
Created April 10, 2020 18:44
thinkpad p1 GPU Nvidia graphic
00:00.0 Host bridge [0600]: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers [8086:3ec4] (rev 0d)
Subsystem: Lenovo Device [17aa:229f]
Kernel driver in use: skl_uncore
00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) [8086:1901] (rev 0d)
Kernel driver in use: pcieport
00:02.0 VGA compatible controller [0300]: Intel Corporation UHD Graphics 630 (Mobile) [8086:3e9b] (rev 02)
Subsystem: Lenovo Device [17aa:229f]
Kernel driver in use: i915
Kernel modules: i915
00:04.0 Signal processing controller [1180]: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem [8086:1903] (rev 0d)
Map(3a0024001447373333353132 -> List(7.709459459805918, 7.8108108110592775, 7.391891892283194, 7.493243243536553, 5.942708333265634, 6.020833333185698, 5.697916666647324, 5.776041666567388, 5.733668341709829, 5.809045226055691, 5.497487437231127, 5.57286432157699, 7.314102563997921, 7.410256410053105, 7.012820512776264, 7.108974358831447), 2d0048001147373239303438 -> List(9.431034483054937, 5.3965517243001475, 14.025641023871069, 8.025641024617322), 40003b001247373333353132 -> List(4.279617477289208E-6, 1.2015849069376464E-5, 1.5294117648905088, 4.294117647050432, 1.3928571429986714, 3.910714285631921), 3f0032000251363131363432 -> List(4.591603053552664, 4.473282442797697, 4.534351145212424, 4.530534351137937, 3.8557692307306626, 3.756410256318171, 3.807692307703071, 3.804487179345762, 3.3792134831724763, 3.2921348314386285, 3.3370786517542856, 3.334269662856819, 4.105802047841151, 4.0, 4.05460750864328, 4.051194539197871), 4b005b000250483553353520 -> List(4.2526690391853, 4.2526690391853, 4.199288256217254,
@kayvank
kayvank / build.sbt
Created July 9, 2020 00:28
sbt-sample
import Dependencies._
import NativePackagerHelper._
import com.typesafe.sbt.packager.docker._
import com.typesafe.sbt.GitVersioning
import TodoListPlugin._
ThisBuild / resolvers ++= Seq(
"Apache Development Snapshot Repository" at
"https://repository.apache.org/content/repositories/snapshots/",
Resolver.mavenLocal
@kayvank
kayvank / Perms.scala
Created March 19, 2021 02:47
Permutations on a List
///////////////////////////////////////////////////////////
/// may seem more complicated thatn it realy is for:
/// 1- concat behaves diff in haskell from Scala, so I need to modify it a bit
/// 2- There is no concatMap in Scala Collection API, there is one in Scala Cats, but didnt want to use cats for this assignment
//////////////////////////////////////////////////////////////
/// About the solution:
/// The general notion is to extend the `inserts` function to the entire collection where `inserts` inserts all the way an elelemt may be inserted in a colletion
////////////////////////////////////////////////////////////
object Perms {
@kayvank
kayvank / myAsync.hs
Last active November 19, 2021 23:27
waitany haskell aync impl
#!/usr/bin/env stack
{-
stack
--resolver lts-17.13 runghc
--package HTTP
--package http-conduit
-}
--
-- chapter-8, Parallel-concurrent-programming in haskell