- Channel synchronization
- Timeout
- Non-blocking channel operation
- Timer
- Ticker
- Worker pool
- Rate limiting
- Automic counter
- Stateful goroutine
- Collection function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
// Create a map to parse the JSON | |
var data map[string]interface{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
type Barista struct { | |
name string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 }') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |