Skip to content

Instantly share code, notes, and snippets.

View ariesmcrae's full-sized avatar
💭
typescript, node.js, aws, java, go (golang)

A. M. ariesmcrae

💭
typescript, node.js, aws, java, go (golang)
View GitHub Profile
@ariesmcrae
ariesmcrae / Minimum.java
Created August 1, 2018 00:42
Get minimum using java lambda
//Pick the cheapest plan
final AdjustmentPlan plan = plans.stream()
.min(Comparator.comparing(AdjustmentPlan::getMultiplier))
.orElse(null);
final Double multiplier = plan != null ? plan.getMultiplier() : 1.0;
List<String> exceptions = new ArrayList<>();
if (plan != null && PlanType.EXCEPTION.equals(plan.getPlanType())) {
@ariesmcrae
ariesmcrae / main.go
Created October 3, 2018 02:05
golang: Unmarshall json to struct
// play.golang.org/p/-fTKnXVctQ0
package main
import (
"encoding/json"
"fmt"
)
type Employee struct {
@ariesmcrae
ariesmcrae / main.com
Last active March 28, 2019 05:36
golang: Marshal struct to json string
// play.golang.org/p/IAGoPiUdUMc
package main
import (
"encoding/json"
"fmt"
)
type Employee struct {
@ariesmcrae
ariesmcrae / util.go
Created October 4, 2018 23:54
secret: go json struct unmarshall util
package util
import (
"encoding/json"
)
func Unmarshall(jsonPayload string, v interface{}) error {
return json.Unmarshal([]byte(jsonPayload), v)
}
@ariesmcrae
ariesmcrae / unzip.sh
Created December 8, 2018 03:48
Bash command line unzip (extract) all zip files into folder (directory) where folder name is the name of zip file
#!/bin/sh
for zip in *.zip
do
dirname=`echo $zip | sed 's/\.zip$//'`
if mkdir "$dirname"
then
if cd "$dirname"
then
unzip ../"$zip"
cd ..
@ariesmcrae
ariesmcrae / unzip_7z.sh
Created December 8, 2018 03:50
Bash command line unzip (extract using 7z) all zip files into folder (directory) where folder name is the name of zip file
#!/bin/sh
for zip in *.zip
do
dirname=`echo $zip | sed 's/\.zip$//'`
7z x $zip -o./$dirname
done
@ariesmcrae
ariesmcrae / launch.json
Last active August 24, 2019 04:57
Enable vscode debugging of typescript
//For Mocha
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
@ariesmcrae
ariesmcrae / resources.yaml
Last active March 19, 2024 20:01
Cloudformation AWS::Include parser is very strict. Must put quotes everywhere. Otherwise, you'll get "InvalidAttributeValue". Here's a correct example.
S3Bucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName:
Fn::Sub: "${TagProduct}-${TagEnvironment}-${TagEnvironmentNumber}-audit-${AWS::AccountId}-${AWS::Region}"
NotificationConfiguration:
QueueConfigurations:
- Event: "s3:ObjectCreated:*"
Queue:
Fn::GetAtt: [ "ObjectCreatedQueueAudit", "Arn" ]
@ariesmcrae
ariesmcrae / hosts.txt
Created November 6, 2019 22:05
My host files for ad blocking
https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts
https://block.energized.pro/unified/formats/hosts
https://block.energized.pro/extensions/regional/formats/hosts
https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Xiaomi-Extension.txt
# white list
https://github.com/anudeepND/whitelist
@ariesmcrae
ariesmcrae / FindStringInList.java
Last active December 9, 2019 12:00
Java: Find string in List of strings
private static boolean isStringInputInTheList(String input, List<String> list) {
return Optional.ofNullable(list)
.map(Collection::parallelStream)
.orElseGet(Stream::empty)
.anyMatch(x -> StringUtils.isNotBlank(input) && x.equals(input));
}
// where:
// StringUtils is the org.apache.commons.lang3.StringUtils