Skip to content

Instantly share code, notes, and snippets.

@massenz
massenz / ErrorStateMachine.json
Last active April 5, 2023 19:47
Demonstrates how to generate different types of errors for AWS Lambda Step Functions, so that Retry/Catch can distinguish between different kinds of errors.
{
"Comment": "A state machine to experiment with errors",
"StartAt": "Error Handler",
"States": {
"Error Handler": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
@yakuter
yakuter / cancel-io-copy.go
Created April 25, 2021 19:25
IO Copy cancellation
// Source: https://ixday.github.io/post/golang-cancel-copy/
import (
"io"
"context"
)
// here is some syntaxic sugar inspired by the Tomas Senart's video,
// it allows me to inline the Reader interface
type readerFunc func(p []byte) (n int, err error)
@mattiasghodsian
mattiasghodsian / readme.md
Last active July 22, 2024 18:17
How to create a Windows application Installer with NSIS

Nullsoft Scriptable Install System is also known as NSIS open-source system to create Windows application installers. NSIS is a script-based system allowing you to create the logic behind your installer/setup file in a complex way to install tasks. NSIS offers plug-ins and other scripts, for example, to download/install 3rd-party files or communicate with Windows.

The tutorial application

This tutorial will guide you through installing and creating your first Windows installer with Nullsoft Scriptable Install System and how to compile your project. Captura Portable will be used as "our application" for the sake of this tutorial.

Installation

Head to NSIS official site and download the latest release and install it. Run NSIS and you will be welcomed with a menu like below, It's always a good practice to read the Documentation before jumping in t

@littlelailo
littlelailo / apollo.txt
Created September 27, 2019 12:04
Apple Bootrom Bug
This bug was also called moonshine in the beginning
Basically the following bug is present in all bootroms I have looked at:
1. When usb is started to get an image over dfu, dfu registers an interface to handle all the commands and allocates a buffer for input and output
2. if you send data to dfu the setup packet is handled by the main code which then calls out to the interface code
3. the interface code verifies that wLength is shorter than the input output buffer length and if that's the case it updates a pointer passed as an argument with a pointer to the input output buffer
4. it then returns wLength which is the length it wants to recieve into the buffer
5. the usb main code then updates a global var with the length and gets ready to recieve the data packages
6. if a data package is recieved it gets written to the input output buffer via the pointer which was passed as an argument and another global variable is used to keep track of how many bytes were recieved already
7. if all the data was recieved th
@fed-franz
fed-franz / bitcoin-cli --help
Last active October 5, 2020 11:01
Bitcoin Core Help (v0.20.0)
Usage: bitcoin-cli [options] <command> [params] Send command to Bitcoin Core
or: bitcoin-cli [options] -named <command> [name=value]... Send command to Bitcoin Core (with named arguments)
or: bitcoin-cli [options] help List commands
or: bitcoin-cli [options] help <command> Get help for a command
Options:
-?
Print this help message and exit
@bserdar
bserdar / gocontracts.md
Last active November 22, 2018 04:12
Types are contracts

v2:

This started as a thought experiment after I read the Go generics and contracts proposal. The original proposal is powerful enough to specify precise type properties from the point of the generic implementor, however constraints such as "type T must support operator <" is over-specific in a language where < cannot be redefined. Such a constraints means "T must be numeric or string". So this exercise is an extension of the idea that contracts should be specified in terms of existing types, not in terms of type capabilities.

@asukakenji
asukakenji / 0-go-os-arch.md
Last active July 18, 2024 06:42
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@subfuzion
subfuzion / dep.md
Last active June 14, 2023 15:46
Concise guide to golang/dep

Overview

This gist is based on the information available at golang/dep, only slightly more terse and annotated with a few notes and links primarily for my own personal benefit. It's public in case this information is helpful to anyone else as well.

I initially advocated Glide for my team and then, more recently, vndr. I've also taken the approach of exerting direct control over what goes into vendor/ in my Dockerfiles, and also work from isolated GOPATH environments on my system per project to ensure that dependencies are explicitly found under vendor/.

At the end of the day, vendoring (and committing vendor/) is about being in control of your dependencies and being able to achieve reproducible builds. While you can achieve this manually, things that are nice to have in a vendoring tool include:

@the8472
the8472 / dht.log
Last active July 4, 2017 17:59
get_peers verbose log
[2017-07-04T16:10:18.324077Z][Verbose] PeerLookupTask 108661049 target:028EA9E1 BA7E9A88 E3955FC8 ABF406A8 60605BCA todo:55 SENT:25 RECEIVED:10 STALLED:0 FAILED:15 SENT_SINCE_RECEIVE:6 activeOnly:0 unanswered:0 srv: D58EDB92 CED1221D 7BEABA36 4BA42651 0E0FEBB3 FINISHED time to finish:PT12.466S name:null
Task 108661049 done SENT:25 RECEIVED:10 STALLED:0 FAILED:15 SENT_SINCE_RECEIVE:6 activeOnly:0 unanswered:0 closestset: 8 tailMod:0 headMod:7 head:22 tail:19
028EA9E1 BA7E9A88 E3955FC8 ABF406A8 60605BCA
028EAB74 919F450D BB0A0A1D 80101CA1 7720F738 00000295 2BE1DF85 589F55D5 2BE41A09 1740ACF2 src:7
028EAC09 ACCFEEEC 12B34420 1122EF79 3F2F4737 000005E8 16B17464 F1261BE8 BAD6E9D1 5F4F1CFD src:6
028EAFF1 F1BBE9EB B3A6DB3C 870C3E99 245E0D90 00000610 4BC57363 503384F4 2CF83831 443E565A src:5
028EAF9C 0F4B7764 3151CE90 0F8EEE4B 70FFC490 0000067D B535EDEC D2C49158 A47AE8E3 109F9F5A src:4
028EA249 F1F1BBE9 EBB3A6DB 3C870C3E 99245E52 00000BA8 4B8F2161 0826F913 97730A96 F9440598 src:4
028EA529 EEAD36A5 41583A3A 3500
@mh-cbon
mh-cbon / main.go
Last active June 7, 2017 07:47
golang, simple stream
package main
import (
"errors"
"fmt"
"io"
"strings"
"sync"
"time"
)