Skip to content

Instantly share code, notes, and snippets.

@loneshark99
loneshark99 / Caller.cpp
Created December 24, 2022 03:41
C++ Member Initializer List
#include "Vector3.hpp"
#include <iostream>
using namespace std;
int main()
{
Vector3 test;
cout << "X=" << test.x << " Y=" << test.y << " Z=" << test.z << endl;
}
@loneshark99
loneshark99 / Array.cpp
Last active December 24, 2022 03:41
C++ Dont Create Copies Pass by Reference as it affects performance.
#include <iostream>
#include "Array.hpp"
Array::Array()
{
std::cout << "CONSTRUCTOR CALLED" << std::endl;
for (auto i = 0; i < 100000; i++)
{
data.push_back(i*i);
}
@loneshark99
loneshark99 / Copy Assignment and Copy Constructor Operator.cpp
Created December 23, 2022 20:42
C++ Copy Assignment and Copy Constructor Operator
#include <iostream>
#include <string>
class Vector3
{
public:
float x,y,z;
};
class Array
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
@loneshark99
loneshark99 / Ubuntu.md
Created December 26, 2021 01:14
Ubuntu Learnings

Handy command line shortcut to launch a new terminal in Ubuntu

CTRL+ALT+t

@loneshark99
loneshark99 / python_learning.md
Last active December 25, 2021 22:04
Python Learnings

Python Introspection Module is very useful to inspect object/modules/functions/classes etc at runtime.

Some of the important methods

import inspect
import numpy
 
def test:
 pass
 
@loneshark99
loneshark99 / CommandLine.md
Last active December 26, 2021 08:16
Linux Commands I use...

View the wifi networks (Network Manager Command Line Interface - nmcli)

nmcli device wifi

View the Network Status

nmcli device show

Connect to a particular Wireless network

nmcli device wifi connect {% Replace SSID Name %}

GitHub CLI, this is very useful command line tool

@loneshark99
loneshark99 / .vimrc
Created December 20, 2021 06:05
Vimrc file
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
@loneshark99
loneshark99 / script.py
Last active November 26, 2021 20:53
View all keyvault keys/Secrets.
# If not installed, install az cli from https://aka.ms/installazurecliwindows
# Login to azure and then run the following script.
# az login
# python3 script.py | grep -i "YourKey"
import os
import pandas as pd
from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential, _credentials
@loneshark99
loneshark99 / lastN.py
Created October 6, 2021 23:30
(Python) Keeping the Last N items
from collections import deque
def search(lines, pattern, history=5):
previous_lines = deque(maxlen=history)
for line in lines:
if pattern in line:
yield line, previous_lines
previous_lines.append(line)