Skip to content

Instantly share code, notes, and snippets.

View jpukg's full-sized avatar
🧭
Full Stack Developer (Java, Angular)

Jayaprakash / JP jpukg

🧭
Full Stack Developer (Java, Angular)
  • Brussels, Belgium
View GitHub Profile
@jpukg
jpukg / Java 8 Patterns Cheatsheet.md
Created May 3, 2022 15:48 — forked from jiffle/Java 8 Patterns Cheatsheet.md
Cheatsheet of Standard Design Patterns implemented using Java 8 Lambdas

Design Patterns implemented in Java 8

These patterns are implemented using Java 8 Lambdas (together with Project Lombok annotations).

Factory Pattern

Factory I : No Parameter Constructor

Enum class:

@jpukg
jpukg / CloseableTemplate.java
Created May 2, 2022 20:02 — forked from jstrachan/CloseableTemplate.java
helper class for working with closeable resources like streams
/**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@jpukg
jpukg / keyboard-listener.component.ts
Created April 27, 2022 16:21 — forked from rakia/keyboard-listener.component.ts
Handling Keyboard Listener in Angular
import { Component, HostListener } from '@angular/core';
@Component({
selector: 'app-keyboard-listener',
templateUrl: './keyboard-listener.component.html',
styleUrls: ['./keyboard-listener.component.css']
})
export class KeyboardListenerComponent {
// Listener just for one key
@jpukg
jpukg / go_cheatsheet.md
Created February 14, 2022 21:00 — forked from tysonpaul89/go_cheatsheet.md
Go Cheatsheet

Go

Go is a statically typed, compiled programming language designed at Google. Go is syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency.

This cheat sheet is prepared by refering the book Introducing Go Build Reliable, Scalable Programs by Caleb Doxsey

Topics

@jpukg
jpukg / go-notes.md
Created February 14, 2022 20:59 — forked from bnguyensn/go-notes.md
Go notes

Go Notes

CLI

The most important Go CLIs:

Command Description
go build Compile packages and dependencies
go fmt Format package sources
@jpukg
jpukg / go_note.md
Created February 14, 2022 20:59 — forked from baddri/go_note.md
Go notes
@jpukg
jpukg / map-to-struct-with-json.go
Created February 14, 2022 20:59 — forked from kwmt/map-to-struct-with-json.go
map -> json -> struct
package main
import (
"encoding/json"
"fmt"
)
type example struct {
Name string
Address string
@jpukg
jpukg / mapjson.go
Created February 14, 2022 20:59 — forked from madflojo/mapjson.go
map.vs.structs.mapjson.go
package main
import (
"encoding/json"
"fmt"
)
func main() {
// Create a map to parse the JSON
var data map[string]interface{}
@jpukg
jpukg / starbucks.go
Created February 14, 2022 10:08 — forked from arnobroekhof/starbucks.go
starbucks.go --> example
package main
import (
"fmt"
"time"
)
type Barista struct {
name string
@jpukg
jpukg / SessionCookie.go
Created February 14, 2022 10:05 — forked from simt2/SessionCookie.go
mesh-go-example SessionCookie.go
// MeshLogin logs into the mesh backend and sets the session id
func MeshLogin(username string, password string) {
body := map[string]string{
"username": USERNAME,
"password": PASSWORD,
}
payload, _ := json.Marshal(body)
r, _ := http.Post(BASEURL+"auth/login", "application/json", bytes.NewBuffer(payload))
for _, cookie := range r.Cookies() {
if cookie.Name == "mesh.session" {