Skip to content

Instantly share code, notes, and snippets.

View kneerunjun's full-sized avatar
🖥️
Working for the love of programming

kneerunjun kneerunjun

🖥️
Working for the love of programming
View GitHub Profile
@kneerunjun
kneerunjun / basicconcurr.go
Last active September 22, 2023 23:49
Interview tidbits
package main
/* For a given number say N, 2 threads (coroutines) namely foo thread, bar thread each are capable of printing "foo" and "bar"
Purpose of this program though is to print "foobar" for n times
*/
import (
"fmt"
"sync"
)
const (
"todohighlight.keywords": [
{
"text": "NOTE:",
"color": "#ecf0f1",
"backgroundColor": "#16a085",
"overviewRulerColor": "grey",
"isWholeLine": false
},
{
"text": "IMP:",
@kneerunjun
kneerunjun / data.go
Last active January 9, 2023 07:07
This demonstrates typical pitfalls when you make a datamodel in Go and expect it work smoothly with mgo or mongo-driver, but it does not.
package data
import(
"gopkg.in/mgo.v2/bson"
)
type User struct {
ID bson.ObjectId `bson:"_id"`
Name string `bson:"name"`
Email string `bson:"email"`
}
// for seeding purposes, testing environmen

go get any intended version


Whilst writing your own GO libraries, we GoPhers have a sound understanding of the packages and GO modules. but somehow when making our own libraries we tend to miss out on a small detail that can limit your versioning on git. I have put this up just so that you can benefit from my experience / exploration of solutions on the internet.

Lets see the problem first hand and then I bring out the solution/tweak.

We are writing this small uni-file library (for brevity sake Im assuming we have this small library)

go mod init github.com/kneerunjun/mylog
dpkg -l | grep -i docker
sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock

What is the need of getting such upstarted services on linux ?


I have tested a code working fine on my Raspbery. While much of effort has gone into hardware debugging and getting the ports to work as expected, It still is a challenge to run this program evrytime I have to showcase things to people.Fo each instance I have to connect the hardware along with the peripherals and then carefull issue commands to start the desired program

  1. Logistics of the peripherals is cumbersome
  2. Peripherals sdo consume more amperage

Would it not be good if there was a way th program upstarts with the machine itself ?

Or one up - wait for me in suspension to get started and sensing.

/*
date : 25-AUG-2017
author : kneerunjun@gmail.com
purpose : to try measuring Analog inputs on Rpi using an ADS1115 over I2C and then connect a MQ135 Co2 measurement unit
compilation : gcc ./i2ctest.c -o ./bin/i2ctest -lwiringPi -lwiringPiDev -lm
run : ./bin/i2ctest
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h> // exit, delay
  • Design Automation using CATIA VBA

    • Pre requisites

      • Mechanical design fundamentals
      • Mechanical Computer Aided Design (CAD)
      • VB.NET syntax, OO programming
      • Understanding of COM principles & Interface based design
    • The need for CATIA v5VBA (Why) :

      • State: CATIA is authorititive/popular CAD tool used for virtual mechanical design. Althought when it comes to repititive tasks that need precision it can get some assitance from the CATIA VBA tools.
      • VB code run without human interventions atop CATIA (CATIA VBA) leads to better efficiency + precision.Saves time for the engineers so that they can concentrate on higher, more innovative tasks.
  • For large engineering organizations,since the business logic becomes **less

Getting docker started on Linux machine

Like me I expect you to have a Linux machine running atop VMbox that may inturn running on either Win10 or Mac. This also means that you have a linux machine already and all your docker commands are fired from a linux machine. Which gets me to the straight point - no need for docker-machine commands

Installing docker on your linux machine

Im using Anteregos(Arch) with Gnome desktop

Problem description: 

  1. Create an application which requires the users to input username and password to register.
  2. Write a program to check the validity of password input by users.

Following are the criteria for checking the password:

  1. At least 1 letter between [a-z]
  2. At least 1 number between [0-9]
  3. At least 1 letter between [A-Z]
  4. At least 1 character from [$#@]