Skip to content

Instantly share code, notes, and snippets.

View gist:3272f9faf8af8a2bb6a9199f37635482
let example = new Promise(
function(resolve, reject){
let success = do some async task;
kevinhooke / gist:07e5a900252fb8dc6ff3c98df60e0b54
Created Jul 2, 2021
Serverless framework Java Lambda - invoke local logger error
View gist:07e5a900252fb8dc6ff3c98df60e0b54
sls invoke local --function functionname
NoSuchMethodError: 'void ...
change aws-lambda-java-log4j2 verion in pom.xml to 1.0.0
kevinhooke / gist:895723ca2991f837785c503916e064f4
Created Jun 10, 2021
JavaScript imports and exports: default and named
View gist:895723ca2991f837785c503916e064f4
- a module can only have one default export:
export default A = //something
... and can be imported with any name:
import A from './A.js';
import B from './A.js';
import someothername from './A.js'
- named exports are imported by their exact name only, a module can have zero, one or more named exports
kevinhooke / gist:389b4e69d3f2ea7c95dc248e8cdd91f3
Created May 13, 2021
git list files on a commit and delete files and all history
View gist:389b4e69d3f2ea7c95dc248e8cdd91f3
# diff changed files against previous commit - this doesn't show anything for a first commit
git diff-tree --no-commit-id --name-only -r commithash
# list all files on a commit
git ls-tree --name-only -r commithash
# delete a file from all commit history
git filter-branch --tree-filter "rm -f filename" HEAD
View gist:05aa2a492973415833123ca7708088fc
Fast Forward
- when no other changes made to master between the last change and the change you are about to merge on your branch,
master is 'fast forwarded' to point to your last commit that you are merging into master (no other changes to merge)
Merging a branch
- checkout target branch: git checkout targetname
- merge source into the target: git merge sourcename
kevinhooke / gist:61eeb5ed3162fa77c7286682d1bb0170
Created Apr 3, 2021
JAX-RS Jersey vs Spring RestController annotations
View gist:61eeb5ed3162fa77c7286682d1bb0170
JAX-RS Jersey Spring RestController
------------- ---------------------
@Path("/examplepath") @RestController
@GET("/item") @GetMapping("/item")
@QueryParam("id") @RequestParam("id") // e.g. /example?id=123
@PathParam("id") @PathVariable("id") //e.g. /example/{id}/detail
kevinhooke / gist:a30de2d5ea9d9986cdf306775063323e
Created Mar 26, 2021
Configuring ~/.ssh/config file for accessing multiple git repos with different keys
View gist:a30de2d5ea9d9986cdf306775063323e
Edit ~/.ssh/config and for each repo add the following block:
host hostname-of-repo
user your-id-for-this-repo
identityfile ~/.ssh/filename-of-key
kevinhooke / gist:7c865d6f5c7e70b4f07af3948ae441ef
Created Mar 9, 2021
stdin, stdout, stderr and redirection
View gist:7c865d6f5c7e70b4f07af3948ae441ef
0 = stdin
1 = stdout
2 = stderr
#redirects stdout from command to file
command > file
#equivalent to
command 1> file
kevinhooke / gist:6020900758fa1a6b85e750846652f527
Created Mar 9, 2021
AWS Cloudformation example for DynamoDB table
View gist:6020900758fa1a6b85e750846652f527
"Resources" : {
"example-table" : {
"Type" : "AWS::DynamoDB::Table",
"Properties" : {
"TableName" : "example-table",
"AttributeDefinitions" : [
"AttributeName" : "LastName",
"AttributeType" : "S"
kevinhooke / gist:b3ef76e5f4a921bf98670d8991cd28b3
Last active Mar 10, 2021
aws cli dynamodb put-item and get item
View gist:b3ef76e5f4a921bf98670d8991cd28b3
aws --endpoint-url=http://localhost:4566 dynamodb put-item --table-name exampletable --item '{
"LastName" : { "S" : "test1" }
}' \
--return-consumed-capacity TOTAL
#query table with only a hash key
aws --endpoint-url=http://localhost:4566 dynamodb query --table-name exampletable \
--key-condition-expression "LastName = :v1" \
--expression-attribute-values '{
":v1" : {"S": "test1"}