Skip to content

Instantly share code, notes, and snippets.

View sakshamsaxena's full-sized avatar

Saksham Saxena sakshamsaxena

View GitHub Profile
@sakshamsaxena
sakshamsaxena / main.go
Created December 13, 2022 17:07
Go program to print odd and even numbers of a stream in sequence but in two different goroutines
package main
import (
"fmt"
)
func main() {
/*
Given a stream of numbers,
use two goroutines to print odd and even numbers by each
package main
import (
"bufio"
"io/ioutil"
"os"
"sort"
"strconv"
)
@sakshamsaxena
sakshamsaxena / ManagingVariablesInAnsible.md
Last active February 14, 2019 07:30
A simple gist dscribing how to manage variables for Ansible Inventory

3 Ways To Manage Variables in Ansible Inventory

Written with Ansible 2.7.6

1. Straight Up Simple

Define remote hosts in /etc/ansible/hosts preferably in groups along with their variable groups. Write the variables simply in plain text.

# Inventory File /etc/ansible/hosts
[home]
const protoLoader = require('@grpc/proto-loader');
const grpcLibrary = require('grpc');
const options = {
includeDirs: [
'./tensorflow_serving/apis/',
'./tensorflow_serving/config/',
'./tensorflow_serving/core/',
'./tensorflow_serving/util/',
'./tensorflow_serving/sources/',

Find all HTML Style Comment Blocks

(?s)<!--.*?-->

The second question mark makes it non-greedy, and the first (?s) is the dotall identifier to include newlines in search.

using System;
namespace DemoApp
{
public class Almira
{
private Door Door { get; set; }
public void LockAlmira()
{
this.Door.LockDoor();
@sakshamsaxena
sakshamsaxena / Upgradation.md
Created June 17, 2018 11:08
How to Update Sublime Text 3 on Linux
  1. Download the tarball
  2. Extract the tarball. Let's say it is extracted to ~/Downloads/sublime_text_3
  3. Check where your current Sublime Text lies by running which subl or which sublime or whatever you've named it currently
  4. Move and overwrite the extracted folder over to the current Sublime's folder which you found above.
  5. Done!
@sakshamsaxena
sakshamsaxena / GFGExtractor.js
Last active October 19, 2018 08:07
A simple JavaScript Snippet to get the list of all the links with titles on it's "Must Do Coding Questions" page.
// Extracted from "https://www.geeksforgeeks.org/must-do-coding-questions-for-companies-like-amazon-microsoft-adobe/" on April 7, 2018
/* How To Use :
1. Install Node.js
2. Fire up your console and create a fresh directory and enter it.
3. Run `npm init -y && npm i superagent cheerio`
4. Save this file in that directory.
5. Run it with `node GFGExtractor.js`
*/
/*
Required Modules

Programming

Sorting Algorithms

Name Best Average Worst Memory
Insertion n n^2 n^2 1
Selection n^2 n^2 n^2 1
Merge nlogn nlogn nlogn n
Heap nlogn nlogn nlogn 1

JavaScript

Closures are special objects or functions that refer to independent variables and/or functions defined in a scope. These keep intact the environment in which they were created.

Normally, the local variables within a function only exist for the duration of that function's execution. However, a Closure retains the function as well as the "environment" (variables in that scope). Thus, the existence of that variable will be accounted for if we're using closures.

Closure definitions returns an accessible quantity like an object (in case of module pattern design) or a function (in case of attaching event listeners dynamically).