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 / 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" {
@jpukg
jpukg / 00_go_examples.md
Created February 14, 2022 09:57 — forked from tramamte/00_go_examples.md
Go examples
  1. Channel synchronization
  2. Timeout
  3. Non-blocking channel operation
  4. Timer
  5. Ticker
  6. Worker pool
  7. Rate limiting
  8. Automic counter
  9. Stateful goroutine
  10. Collection function
roles, err := svc.ListRoles(&iam.ListRolesInput{})
var jsonMap map[string]interface{}
unquote, err := url.PathUnescape(aws.StringValue(roles.Roles[0].AssumeRolePolicyDocument))
json.Unmarshal([]byte(unquote), &jsonMap)
data := model.Statement{}
json.Unmarshal([]byte(aws.StringValue(roles.Roles[0].AssumeRolePolicyDocument)), &data)
fmt.Printf("Operation: %s", data)
public static ObjectMapper configureMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return mapper;
}
public static void main(String[] args) throws JsonProcessingException {
@jpukg
jpukg / ZipUtility.java
Created January 17, 2022 12:56 — forked from anna-dolbina/ZipUtility.java
This sample demonstrates how to add a new file (or overwrite the existing one) in a ZIP archive
import java.io.*;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
public class ZipUtility {
private final File zipFilePath;
@jpukg
jpukg / xxeftp.py
Created December 27, 2021 21:50 — forked from ruevaughn/xxeftp.py
Python FTP server for XXE
#!/usr/env/python
from __future__ import print_function
import socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('0.0.0.0',2121))
s.listen(1)
print('XXE-FTP listening ')
conn,addr = s.accept()
print('Connected by %s',addr)
@jpukg
jpukg / delete-old-branches.sh
Created December 27, 2021 21:47 — forked from JeffBelback/delete-old-branches.sh
Git helper functions
#!/bin/bash
# Deletes branches that have been removed on origin
function no_remote() {
if git rev-parse --git-dir >/dev/null 2>&1; then
git fetch --prune
echo "Branches with no remote:"
git branch -vv | cut -c 3- | awk '$3 !~/\[/ { printf " %s\n", $1 }'
echo -e "\nDeleting branches with deleted remote:"
del=$(git branch -vv | awk '$4 ~/gone\]/ { printf "git branch -D %s && ", $1 }')
@jpukg
jpukg / docker-destroy-all.sh
Created December 27, 2021 09:20 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers