Posts

Showing posts from February, 2024

react react Cannot read properties of null (reading 'useState')

 After introducing a new component into our application, we noticed the page throws up an error  " react Cannot read properties of null (reading 'useState') " After some troubleshooting and analysis, we noticed that a different react version was deployment. So instead of a single version, we have 2 version and broke it.  The fix is to change package.json to use the same react version and webpack does it thing! 

Dockerfile: NU1301: Unable to load the service index : https://api.nuget.org/

Image
  Bump into this error while trying to build a docker image via dockerfile. To resolve this, i just add a bypass proxy as shown below :-

rust debug your application by specifying parameters

To ensure that you can specify program argument - for example when you're writing a console app that requires command argument you can use the following settings to allow vscode + rust anaylzer pick these up during debug. Here I specify "-t www.google.com" as the argument. {     // Use IntelliSense to learn about possible attributes.     // Hover to view descriptions of existing attributes.     // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387     "version" : "0.2.0" ,     "configurations" : [         {             "type" : "lldb" ,             "request" : "launch" ,             "name" : "Debug executable 'nwt'" ,             "cargo" : {                 "args" : [                    ...

Getting this error Microsoft Shared/ink/en-US/micaut.dll.mui: no such file or directory

 Got this error  /Microsoft Shared/ink/en-US/micaut.dll.mui: no such file or directory while doing a docker build.  After i change to a docker windows container then it all sorted.

istio local rate limiter basic setup

 For this setup, we're going to use the httpbin example that cames with istio. You can close this repo.  Basics, run the following do the setup  istioctl install --set profile =demo -y kubectl label namespace default istio-injection=enabled go into samples\httpbin directory and then run:  kubectl apply -f .\httpbin-gateway.yaml  kubectl apply -f .\httpbin.yaml If all goes well, you will be able to do load httpbin page. To apply the local rate restriction to all route, use the following yaml (ripped off from isio docs) apiVersion : networking.istio.io/v1alpha3 kind : EnvoyFilter metadata :   name : filter-local-ratelimit-svc   namespace : default spec :   workloadSelector :     labels :       app : httpbin   configPatches :     - applyTo : HTTP_FILTER       match :         context : SIDECAR_INBOUND         listener :           ...

rust example for ? operator

 This is an example of using Result and operator ? in Rust.  Let's say I have the following division function  fn div ( self , x : f64 , y : f64 ) -> MathResult {         if y == 0.0 {             Err ( MathError :: DivisionByZero )         } else {             Ok ( x / y )         }     } When i call using the code here, it says " the `?` operator can only be used in a method that returns `Result` or `Option " fn op1 ( self , x : f64 , y : f64 ) {         // if `div` "fails", then `DivisionByZero` will be `return`ed         let ratio = self . div ( x , y ) ? ;         Ok ( 10.0 )     } Rightly pointed out so, if i change my function to this (that returns MathResult), then i was able to use the ? operator. fn op2 ( self , x : f64 , y : f64 ) -> Mat...

rust - patterns `0_u32` and `4_u32..=u32::MAX` not covered

  Weird message from rust for the actual issue If i have the following code, it will trigger this error and the reason is because I didn't cover the scenarios required fn test ( self , i : u32 )   -> Result < i8 , & ' static str > {         match i {             1 => Ok ( 1 ),             2 => Ok ( 2 ),             3 => panic ! ( "oh nonono" ),         }     } So adding a _ => panic("no value") - i was able to fix it fn test ( self , i : u32 )   -> Result < i8 , & ' static str > {         match i {             1 => Ok ( 1 ),             2 => Ok ( 2 ),             3 => panic ! ( "oh nonono" ),             _ => panic ! ( "no...

rust - cross compile to target windows

  First have to install (about 1G of additional space is required)  apt-get install gcc-mingw-w64 In case you would like to cross compile your application into windows, you can do the following  rustup target add x86_64-pc-windows-gnu This will add the require component. Then run cargo build like you normally wo cargo build --release --target x86_64-pc-windows-gnu

rust cargo compile and getting failed to run custom build command for `openssl-sys v0.9.100`

 After trying to build my application and adding reqwest library into my cargo toml, i get the error  "failed to run custom build command for `openssl-sys v0.9.100" To resolve this  apt-get update  apt install pkg-config apt install libssl-dev And then rebuild.

github push via https no longer support user/password

 github push via https no longer support user/password. If you try to do a git push, you will be prompted for a username and password. You should be using a token - as your password. You can create classic token by going to github -> developer settings -> create token. Once you have your token, try to do another git push. Instead of entering your password, enter this token.

rust clap cli basics

  Clap have the concept of  a) argument - is input pass to the executing command  for example myexec helloworld.  helloworld here is the argument b) options - predefined argument that the program accept, for example myexec -n test  You will see example below  When you work with clap derive mode, you have to create a struct that derived from Parser as shown below: Simple Argument Here we will create a command line that takes in a string as input  use std :: path :: PathBuf ; use clap :: { Parser , Subcommand }; #[ derive ( Parser )] #[ command (version, about, long_about = None )] pub struct Cli {     pub name : Option < String >, } main.rs fn main () {     use clap :: Parser ;     let cli = cmd :: Cli :: parse ();     let cli = cmd :: Cli :: parse ();     println ! ( "name: { : ? } " , cli . name . as_deref ()); } To execute, run myexec test and it will output  name: test Addi...

Rust - environment setup for windows

Image
  Install Windows WSL subsystem for linux.  Install rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh Create a new application using cargo  cargo new guessing_game then fire up vscode using the following command cd guessing_game code .  Install the following extension  - rust-analyzer  - codellvm  Then with vscode, go and look for main.rs.  As you hover over the main function, there's 2 options that appears, 1. run 2. debug  You should add a breakpint and then click on debug

Unable to install modular - getting Failed to update via apt-get update

Image
  When i tried running the following command (trying to install modular), I got the following error:  Then I tried to run  sudo apt-get update Solution I got another error. As you might have guessed it, this is due to 'apt-get'install issue that related to system clock. Then run the following command :- hwclock --hctosys  After that run    sudo apt-get update Once that completed, I just re-run modular cli installation again curl https://get.modular.com | sh - && \ modular auth mut_89ef4b15a38a47bf98c3e09f25241f41 You may need to run "modular auth" separately by running the following command:-  modular auth mut_89ef4b15a38a47bf98c3e09f25241f41 Then install sdk via modular install mojo

kind requires docker to setup its clusters

grafana - pyroscope dotnet profiler

 A dotnet profiler based on datadog profiler with key improvement - so it says :)  https://github.com/grafana/pyroscope-dotnet Example of integration into your dotnet project. https://github.com/grafana/pyroscope/blob/main/examples/dotnet/rideshare/example/Program.cs

dockerfile simple image build and run in bash mode

dockerfile FROM ubuntu:latest RUN apt update && apt install -y --no-install-recommends \     curl \     tar \     && rm -rf /var/lib/apt/lists/* docker run -- rm -it --entrypoint bash dotnetprofiler

dotnet core tools like dotnet-trace are available as open source code here https://github.com/dotnet/diagnostics

keycloak customizing dockerfile with say curl, openjdk and jq command

 Use the following dockerfile and the run "docker build . -t kclocal" FROM registry.access.redhat.com/ubi9 AS ubi-micro-build RUN mkdir -p /mnt/rootfs RUN dnf install --installroot /mnt/rootfs curl java-11-openjdk-devel jq --releasever 9 --setopt install_weak_deps=false --nodocs -y && \     dnf --installroot /mnt/rootfs clean all && \     rpm --root /mnt/rootfs -e --nodeps setup FROM quay.io/keycloak/keycloak:17.0.1 COPY --from=ubi-micro-build /mnt/rootfs /

linux command to find processes without using ps

  find /proc -mindepth 2 -maxdepth 2 -name exe -exec ls -lh {} \; 2>/dev/null

Keycloak infinispan custom configuration file

To install docker  docker run --name mykeycloak -v c:\work\keycloak\conf:/opt/keycloak/conf -p 8080:8080 -p 8790:8790 -e JAVA_TOOL_OPTIONS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8790 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" -e KEYCLOAK_ADMIN=admin -e KC_HEALTH_ENABLED=true -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:17.0.1 start-dev --cache-config-file=cache.xml  Assuming you have the keycloak configuration files available in your c:\work\keycloak\conf folder. 

Website for model metrics

 https://llm.extractum.io/model/moreh%2FMoMo-72B-LoRA-V1.4,6OgUnbsThKh11WdG09lZP

openjdk releases for mac, windows and linux

  Here is the link https://jdk.java.net/archive/

jstatd having issue with permission in jdk 11

  Create a file, mypolicy grant codebase "jrt:/jdk.jstatd" { permission java.security.AllPermission; }; grant codebase "jrt:/jdk.internal.jvmstat" { permission java.security.AllPermission; }; Next, Execute with the following command :- ./jstatd -J-Djava.security.policy=mypolicy