An introduction to gpt for daily workflows

Integrating GPT into Daily Workflows GPT (Generative Pre-trained Transformer) is a powerful language model developed by OpenAI that can generate human-like text. It has the ability to understand and respond to natural language inputs, making it a valuable tool for various industries and professionals. One of the most significant advantages of GPT is its ability to automate repetitive tasks, such as writing emails, creating reports, or summarizing data. By integrating GPT into daily workflows, professionals can save time and increase productivity while still maintaining the quality of their work....

January 21, 2023

Soft Skills

A brief review of Soft Skills: The software developer’s life manual 1st Edition Soft Skills, written by John Sonmez, aims to capture the aspects of software engineering that extend beyond the command line and the IDE. Sonmez provides council on the following: Career - Active career management. Marketing - (Yourself). Learning - Continuing education through a hands-on approach. Productivity - Do the work. Financial - A primer on fiscal intelligence. Fitness - Physical health and where it fits in the Software Development Life cycle....

May 3, 2022

Course Schedule 2

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai. For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1. Return the ordering of courses you should take to finish all courses....

April 7, 2022

Sliding Window Max

You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window. Examples Example 1: Input: nums = [1,3,-1,-3,5,3,6,7], k = 3 Output: [3,3,5,5,6,7] Explanation: Window position Max --------------- ----- [1 3 -1] -3 5 3 6 7 3 1 [3 -1 -3] 5 3 6 7 3 1 3 [-1 -3 5] 3 6 7 5 1 3 -1 [-3 5 3] 6 7 5 1 3 -1 -3 [5 3 6] 7 6 1 3 -1 -3 5 [3 6 7] 7 Example 2: Input: nums = [1], k = 1 Output: [1] Brute force solution Time complexity : O(Nk), where N is number of elements in the array....

April 7, 2022

Design a Deck of Cards

from abc import ABCMeta, abstractmethod from enum import Enum import sys class Suit(Enum): HEART = 0 DIAMOND = 1 CLUBS = 2 SPADE = 3 class Card(metaclass=ABCMeta): def __init__(self, value, suit): self.value = value self.suit = suit self.is_available = True @property @abstractmethod def value(self): pass @value.setter @abstractmethod def value(self, other): pass class Deck(object): def __init__(self, cards): self.cards = cards self.deal_index = 0 def remaining_cards(self): return len(self.cards) - self.deal_index def deal_card(self): try: card = self....

April 7, 2022

Reconstruct Itinerary

You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. All of the tickets belong to a man who departs from “JFK”, thus, the itinerary must begin with “JFK”. If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string....

April 7, 2022

Text Justification

Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ’ ’ when necessary so that each line has exactly maxWidth characters. Extra spaces between words should be distributed as evenly as possible....

April 7, 2022

Find Median From Data Stream

The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values. MedianFinder() initializes the MedianFinder object. void addNum(int num) adds the integer num from the data stream to the data structure. double findMedian() returns the median of all elements so far. Answers within 10-5 of the actual answer will be accepted....

April 6, 2022

Subarray Sums Divisible by K

Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum is divisible by k. Example Input: nums = [4,5,0,-2,-3,1], k = 5 Output: 7 Explanation: There are 7 subarrays with a sum divisible by k = 5: [4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3] Intuitions Brute Force Approach A naive but simple solution is to use the brute force approach....

April 6, 2022

OSI Model

The OSI (Open Systems Interconnected) Model describes the universal standard of communication functions of a telecommunication system or computing system. layer Description PDU Function 7 Application Data High-level APIs, including resource sharing, remote file access 6 Presentation Data Translation of data between a networking service and an application; including character encoding, data compression and encryption/decryption 5 Session Data Managing communication sessions, i.e., continuous exchange of information in the form of multiple back-and-forth transmissions between two nodes 4 Transport Segment, Datagram Reliable transmission of data segments between points on a network, including segmentation, acknowledgement and multiplexing 3 Network Packet Structuring and managing a multi-node network, including addressing, routing and traffic control 2 Data link Frame Reliable transmission of data frames between two nodes connected by a physical layer 1 Physical Bit, Symbol Transmission and reception of raw bit streams over a physical medium

April 6, 2022

Knight Dialer

The knight in chess has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an L). Given a chess knight and a phone pad as shown below, the knight can only stand on a numeric cell 1 2 3 4 5 6 7 9 0 * 0 # Given an integer n, return how many distinct phone numbers of length n we can dial....

April 5, 2022

Meeting Rooms 2

Given an array of meeting time intervals intervals where intervals[i] = [start, end] return the minimum number of meeting rooms required. Examples Example 1 Input: intervals = [[0,30],[5,10],[15,20]] Output: 2 Example 2 Input: intervals = [[7,10],[2,4]] Output: 1 Intuition The first thought that comes to mind is that we should sort the intervals by their starting times. This would allow us to implement a priority queue, add intervals as they begin pop them off as they end and the size of the queue will represent our required meeting rooms....

April 5, 2022

Implementing a LRU Cache

Implement an LRUCache class. Functions should include: LRUCache(int capacity) Initialize the LRU cache with positive size capacity. int get(int key) Return the value of the key if the key exists, otherwise return -1. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key....

April 5, 2022

Big O with Examples

Big O notation is a way to talk about the time or resource complexity of an algorithm. It’s commonly used to describe worst, best, and average cases while comparing one algorithm to others. Since algorithms with less complexity finish faster that those with high complexity they are more desirable. The expression O(x) pronounced “big-O of x” is used to symbolically express the asymptotic behavior of a given function. Specifically when n is an integer that tends to infinity and x is a continuous variable tending to some limit....

April 4, 2022

Two Sum

Two sum is my favorite warm up question for a coding interview. Its easy to explain and easy to solve and there aren’t too many clarifying questions that need to be asked. Its one that you can just jump into. The challenge Given an array of integers and an integer target, return indices of the two numbers that sum to the target. Each input shall have but one solution. Examples Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1]....

April 3, 2022

Client side syntax highlighting in Hugo

There are existing docs about Hugo Syntax Highliting. They indicate that generating style sheets for syntax highlighting may be required but they don’t present a complete picture. This is an attempt to create that picture. Changes to config.yaml pygmentsCodefences: true pygmentsCodefencesGuessSyntax: true pygmentsStyle: "monokai" Create a directory for the code highlighting css mkdir static/css Generate the syntax highlighting style sheet. hugo gen chromastyles --style=monokai > static/css/syntax.css

April 2, 2022

Counting Islands

A 2D binary grid represents a land map. The map consists of ‘1’s and ‘0’s where the 1’s are land and the 0’s are water. Given this map, count the number of islands Example Input: map = [ ["1","1","0","0","0"], ["1","1","0","0","0"], ["0","0","1","0","0"], ["0","0","0","1","1"] ] Output: 3 Intuition If we treat the map as an undirected graph then we can walk the associated tree structure and count islands as we go. Algorithm Walk the map, if a node’s value is ‘1’ then we initiate a depth first traversal....

April 2, 2022

Idiomatic Enums in Go

A programming idiom is the usual way to code a task in a specific language. Although Golang does not have built in support for enumerations there is an idomatic way to emulate the feature. The idiomatic way to have enumerations in Go is to use a combination of the Iota and Integer types. type TaxonomicRank int const ( Animalia TaxonomicRank = iota Plantae Fungi Protista Archaea Bacteria ) func (m TaxonomicRank) String() string { return toString[m] } var toString = map[TaxonomicRank]string{ Animalia: "Animalia", Plantae: "Plantae", Fungi: "Fungi", Protista: "Protista", Archaea: "Archaea", Bacteria: "Bacteria", } var toEnum = map[string]TaxonomicRank{ "Animalia": Animalia, "Plantae": Plantae, "Fungi": Fungi, "Protista": Protista "Archaea": Archaea "Bacteria": Bacteria, } For extra credit, as they say, we can add support for serialization support for our enum with the following...

June 19, 2021

Exploring Data Exchange in Go

A common task for a software engineer is to transform data from one format into another that is suitable for their needs. Some data formats are good for storage, others are easy to edit, and some are ideally suited for transport. Transforming data from a source format and into a target format is known as Data Exchange. There are many well known, commonly used, data formats YAML, XML, CSV, and JSON are popular text based human readable formats, binary formats like Protobufs and Flatbuffers are are gaining in popularity due to their improved serialization performance and small size when compared to text based formats....

January 9, 2021

K3 for Running Kubernetes on Raspberry pi

Rachers K3 Github Repository describes K3 as a Lightweight Kubernetes. Easy to install, half the memory, all in a binary less than 40mb. These characteristics make K3 ideal for in use in ARM deployments like Raspberry Pi. I’ve been using K3 at home for several weeks now and have found it to be a suitable replacement for a full Kubernetes deployment. In my experience installation can be performed with simple scripting and takes about two minutes....

January 5, 2020

Adding DNS entries to Pihole

Adding static DNS entries to Pihole can be accomplished by adding entries to the Pihole server’s hosts file /etc/hosts. For example: 192.168.1.100 pihole.yourdomain 192.168.1.100 blog.yourdomain 192.168.1.101 foo.yourdomain If you’ve deployed Pihole within a Kubernetes cluster then Kubernetes Hosts Aliases can be used to add static DNS entries to Pihole. hostAliases: - ip: "192.168.1.100" hostnames: - "pihole.yourdomain" - "blog.yourdomain" - ip: "192.168.1.101" hostnames: - "foo.yourdomain"

January 4, 2020