Skip to content

Instantly share code, notes, and snippets.

View thatisuday's full-sized avatar
🤖

Uday Hiwarale thatisuday

🤖
View GitHub Profile
@thatisuday
thatisuday / electron-builder.json
Created January 8, 2021 04:32
A simple electron-builder configuration.
{
"appId": "com.thatisuday.fileio",
"productName": "Electron File IO",
"copyright": "THATISUDAY TECH PVT. LTD.",
"directories": {
"app": ".",
"output": "out",
"buildResources": "build-res"
},
"files": [
thread goroutine
OS threads are managed by kernal and has hardware dependencies. goroutines are managed by go runtime and has no hardware dependencies.
OS threads generally have fixed stack size of 1-2MB goroutines typically have 8KB (2KB since Go 1.4) of stack size in newer versions of go
Stack size is determined during compile time and can not grow Stack size of go is managed in run-time and can grow up to 1GB which is possible by allocating and freeing heap storage
There is no easy communication medium between threads. There is huge latency between inter-thread communication. goroutine use channels to communicate with other goroutines with low latency (read more).
Threads have identity. There is TID which identifies each thread in a process. goroutine do not have any identity. go implemented this because go does not have TLS([Thread Local Storage](https://msdn.microsoft.com/en-us/library/win
@thatisuday
thatisuday / fruits-iterator.dart
Created November 29, 2019 16:51
Iterator Example in Dart
// A `Fruit` object contains `name` and `color`
class Fruit {
final String name;
final String color;
Fruit( this.name, this.color );
}
// A `Fruits` collection contains the List of `Fruit` object
// `iterator` getter returns an instance of `FruitsIterator` instance
@thatisuday
thatisuday / fan-in-fan-out.go
Created November 19, 2018 15:32
fan-in and fan-out concept in go lang
package main
import (
"fmt"
"sync"
)
// return channel for input numbers
func getInputChan() <-chan int {
// make return channel
input := make(chan int, 100)
@thatisuday
thatisuday / Dockerfile
Last active August 1, 2023 07:37
A sample Dockerfile to create Go image
# parent image
FROM golang:1.15.6-alpine3.12
# workspace directory
WORKDIR /app
# copy `go.mod` and `go.sum`
ADD go.mod go.sum ./
# install dependencies
@thatisuday
thatisuday / glob-patterns.csv
Last active July 9, 2023 19:56
Glob Pattern Matching
Pattern Description Example Pattern Matches
xyz Match exactly xyz and nothing more photo.db photo.db
* Match any 0 or more characters *s.db photos.db users.db ... (files with s.db suffix)
? Matches any single character ?ing.db king.db ping.db ring.db
[...] Matches one character listed inside the brackets [pr]ing.txt ping.txt ring.txt
[start-end] Matches any character from the start till the end of a set. Supported patterns are a-z; A-Z and 0-9 [m-z]ing.* ping.db ping.txt ring.db ring.txt
[!...] Matches one character not included in the brackets [!pr]ing.txt king.txt
[!start-end] Matches any character not included from the till the end of a set [!m-z]ing.* king.db king.txt
<script type="application/ld+json">{
"@context":"http://schema.org",
"@type":"ItemList",
"itemListElement":[
{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Sign Up",
"description": "Create your example profile.",
"url":"https://example.com"
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Switch, NavLink as Link, Route } from 'react-router-dom';
import './styles.scss';
// home route component
const HomeComponent = ( props ) => {
return (
<h1>Home Component!</h1>
@thatisuday
thatisuday / tsconfig.json
Created August 5, 2020 13:00
Sample `tsconfig.json` file created using `tsc --init` command.
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
@thatisuday
thatisuday / 1. shared.h
Last active February 2, 2023 06:36
C++ Shared Library (Dynamically Linked Library) Example
#pragma once
// extern: https://docs.microsoft.com/en-us/cpp/cpp/extern-cpp?view=vs-2019
// why extern "C" : https://stackoverflow.com/a/42183390/2790983
extern "C" {
// function declaration
int add(int, int);
}