Skip to content

Instantly share code, notes, and snippets.

@SteveHoggNZ
SteveHoggNZ / bash.sh
Created May 4, 2016 07:05
bash - sudo replay last command
sudo !!
@SteveHoggNZ
SteveHoggNZ / bash.sh
Created May 4, 2016 07:07
bash - Get text on the clipboard e.g. echo “Hello World” | pbcopy
echo “Hello World” | pbcopy
@SteveHoggNZ
SteveHoggNZ / bash.sh
Created May 4, 2016 07:07
bash - make a new directory and cd into it
mkdir my-new-dialogue && cd $_
// shorthand for result that is a promise
it(() => {
return expect(result)
.to.eventually.deep.equal({url, options})
})
// ... longhand, which handles multiple promises in a test, and is
// easier to debug (by inserting console.log in then handler)
it(() => {
return Promise.all([
@SteveHoggNZ
SteveHoggNZ / gist:11b5209e2b00e38b54a3c921c2f39b8f
Created May 7, 2016 05:38
bash - filtered output to file and stdout
echo '1
2
3
4
LOG: 5
6
LOG: 7' | tee >(grep LOG | sed 's/LOG: //' > tmp.txt)
@SteveHoggNZ
SteveHoggNZ / Examples.js
Created May 10, 2016 23:26
React Notes
// Don't use fat arrow functions as props in pure components, use a named function instead e.g.
export const ChoiceKey = (props: Props) => {
const keyClickHandler = () => {
props.keyClick(props.id)
}
return <div className={classes.choiceKey}
onClick={keyClickHandler}>Choice Key {props.id}</div>
}
@SteveHoggNZ
SteveHoggNZ / aws-cli-jq.sh
Last active June 24, 2020 21:44
Examples of AWS CLI using JQ
# jq reference: https://stedolan.github.io/jq/manual
# Get a list of each Lambda function that starts with ^test and output that as an array
# i.e. take the contents of the .Functions[] list, select the ones that have a .FunctionName property that
# starts with test, and record the .FunctionName value
aws lambda list-functions | jq '[ .Functions[] | select(.FunctionName | test("^test")) | .FunctionName ]'
# Create an array of new maps for Lambda functions
aws lambda list-functions | jq '[ .Functions[] | select(.FunctionName | test("^test")) | {name: .FunctionName, memory: .MemorySize} ]'
@SteveHoggNZ
SteveHoggNZ / mfa-roles-cli-users-groups-roles.json
Created November 23, 2016 02:42
MFA-Roles-On-CLI: CloudFormation template for users, groups and roles - JSON
{}
@SteveHoggNZ
SteveHoggNZ / aws-cloudformation-snippets.json
Created November 23, 2016 03:21
AWS CloudFormation Snippets
// Get the Arn from a resource
"Principal": {
"AWS": { "Fn::GetAtt": [ "BarbaraBossUser", "Arn" ] }
},
@SteveHoggNZ
SteveHoggNZ / company-shared-storage.json
Created November 24, 2016 23:34
AWS / MFA + CLI / CloudFormation / Example / Company Shared Storage
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"CompanySharedBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName" : "h4-company-bucket"
}
},
},