Skip to content

Instantly share code, notes, and snippets.

View dipeshdulal's full-sized avatar
💭
🙏 नमस्कार

Dipesh Dulal dipeshdulal

💭
🙏 नमस्कार
View GitHub Profile
@dipeshdulal
dipeshdulal / Description.md
Last active May 21, 2021 14:59
Custom Binding Multipart Form Data

Custom Binding of Multipart Form Data

Gin Gonic doesn't handle binding of multipart form data with custom types. This provides basic implementation of binding the form data into a struct. This code can be modified to fit ones need.

Usage:

if err := utils.CustomBind(c.Request, &user); err != nil {
	u.logger.Zap.Error(err)
	c.JSON(http.StatusInternalServerError, gin.H{
@dipeshdulal
dipeshdulal / SignalingChannel.ts
Created April 29, 2021 07:24
AntMedia Server SignalingChannel
interface AntWebsocketResponse {
command: "publish" | "start" | "takeConfiguration" | "takeCandidate" | "stop" | "play",
streamId: string;
token?: string;
type?: "offer" | "answer";
sdp?: string;
candidate?: string;
label?: string;
id?: string;
}
@dipeshdulal
dipeshdulal / queryClient.md
Created April 13, 2021 06:17
React Query QueryClient Persistence

Using dehydrate and hydrate function we can persist react query cache in localStorage or AsyncStorage in case of react-native.

Basic implementation for persistence can be made by attaching subscribe function to queryCache and upon new data store the data to persistence layer and upon the app start the persisted cache can be rehydrated.

@dipeshdulal
dipeshdulal / README.md
Last active April 1, 2021 10:49
Patch For libWebRTC ios (microphone permission)

Patch from here from ant media developers. Main change is that they are declaring to check for audio session configuration to enable input mode or not.

  RTCAudioSessionConfiguration* webRTCConfiguration =  [RTCAudioSessionConfiguration webRTCConfiguration];
  if (webRTCConfiguration.mode != AVAudioSessionModeMoviePlayback)

Issue originated from: react-native-webrtc/react-native-webrtc#263

@dipeshdulal
dipeshdulal / changes.md
Created October 16, 2020 11:35
Listen to changes in firestore

To authorize firebase:

  ctx := context.Background()

	opt := option.WithCredentialsFile("./serviceAccountKey.json")
	app, err := firebase.NewApp(ctx, nil, opt)
	if err != nil {
		log.Fatalf("Error %v \n", err)
	}
@dipeshdulal
dipeshdulal / RepoAddInstructions.MD
Last active March 25, 2025 06:14
Get a list of created PR's today.

Instructions

  1. Go to github profile page.
  2. Click on today's or some days contribution
  3. Open Inspector Window
  4. Pase the following code
let rollupWrapper = document.querySelectorAll('.TimelineItem');
@dipeshdulal
dipeshdulal / convert.md
Created September 25, 2020 13:31
File Conversion .png using convert

Bash script to covert all png files present in a directory.

for entry in *.png           
do
  convert $entry -quality 50 $entry
done
@dipeshdulal
dipeshdulal / di_all.go
Created September 19, 2020 04:57
Basic Dependency Injection using go-fx
package main
import (
"fmt"
"log"
"go.uber.org/fx"
)
// CustomString is custom string type
@dipeshdulal
dipeshdulal / minimize.js
Created August 27, 2020 09:17
Minimize Number into K, M, G, T, P, E
var minimizeNumber = (num) => {
if(!Number.isFinite(num)) return "";
const minimizeMap = ["K", "M", "G", "T", "P", "E"];
if(num < 1000) return num.toString();
const exp = Math.floor(Math.log(num)/ Math.log(1000));
const minimized = Number((num / Math.pow(1000, exp)).toFixed(2));
return minimized+minimizeMap[exp-1];
}
@dipeshdulal
dipeshdulal / FiniteStateMachine.go
Created August 18, 2020 10:09
Finite State Machine Final Code
package main
import (
"fmt"
"github.com/dipeshdulal/statemachine"
)
func main(){
machine := statemachine.Machine{