Imagine you have the following tree structure:
.
├── cmd
│ └── fastly
├── fastly
You want to avoid commiting the fastly
file in the root, but you're OK with cmd/fastly
being committed.
Imagine you have the following tree structure:
.
├── cmd
│ └── fastly
├── fastly
You want to avoid commiting the fastly
file in the root, but you're OK with cmd/fastly
being committed.
package main | |
import ( | |
"context" | |
"fmt" | |
"os" | |
"time" | |
"github.com/gofrs/flock" | |
) |
package main | |
import ( | |
"context" | |
"fmt" | |
"time" | |
"github.com/sethvargo/go-retry" | |
) |
export const partial = (fn, arg) => { | |
return (...rest) => { | |
return fn(arg, ...rest) | |
} | |
} |
// For proxy situations where you want to strip a cookie from the incoming request at the proxy layer, before proxying it onto the actual backend. | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func main() { |
# Ensure all code blocks without a language get 'plain' appended.
# NOTE: constraint is that there needs to be an empty line preceding the code block.
cat file.mdx | perl -pe 'BEGIN { undef $/ }; s/(?<=^\n)(```)(\n.+?```)/\1plain\2/s'
NOTE: The Perl variable
$/
stores the line ending, used for processing files line-by-line. By callingundef
on it, we cause Perl to slurp the entire file all in one string at once for us to process.
> WARNING: If the code block has a non-empty preceding line, and the contents of the code block has an empty line before the closing code fence, then the current pattern will accidentally match. So if that's the case, we need to ensure all code blocks don't have an unnecessary empty line at the bottom of them.
use std::result::Result::{Ok, Err}; | |
fn main() { | |
let v = vec![Ok("foo"), Ok("bar"), Err("whoops"), Ok("baz")]; // Err should be skipped | |
for r in v.into_iter().flatten() { | |
println!("{:#?}", r); | |
} | |
} | |
/* |
Box<T>
: A pointer type for heap allocation.Rc<T>
: A read-only, single-threaded reference-counting (i.e. multiple owners) pointer Ω.Arc<T>
: A read-only, thread-safe (i.e. extra performance overhead) reference-counting (i.e. multiple owners) pointer †.Cell<T>
: A single-threaded mutable memory location (where values are moved in and out of the cell).RefCell<T>
: A single-threaded mutable memory location with dynamically checked (i.e. at runtime) borrow rules.Ω Wrap the value inside the
Rc
with eitherCell<T>
orRefCell<T>
for mutability.
> † Wrap the value inside theArc
with eitherMutex
,RwLock
or one of theAtomic*
types for mutability.
use std::any::type_name; | |
use tokio_retry::strategy::{jitter, FixedInterval}; | |
use tokio_retry::Retry; | |
#[derive(Debug)] | |
struct ImageId { | |
id: Option<String>, | |
} | |
async fn action() -> Result<ImageId, ()> { |
https://www.terraform.io/internals/debugging
TF_LOG
: TRACE
, DEBUG
, INFO
, WARN
or ERROR
(or JSON
which is JSON formatted TRACE
logs).TF_LOG_CORE
: only terraform logs.TF_LOG_PROVIDER
: only provider logs.TF_LOG_PATH
: set along with one of the above to ensure logs are sent to a file.