Skip to content

Instantly share code, notes, and snippets.

View AndyWatt83's full-sized avatar

Andy Watt AndyWatt83

View GitHub Profile
@AndyWatt83
AndyWatt83 / main.rs
Created February 12, 2022 23:43
Testing for a very simple Rust API
#[cfg(test)]
mod tests {
use super::*;
use actix_web::body::to_bytes;
use actix_web::dev::Service;
use actix_web::{http, test, web, App, Error};
#[actix_web::test]
async fn test_say_hello() -> Result<(), Error> {
let app = App::new().route("/", web::get().to(say_hello));
@AndyWatt83
AndyWatt83 / main.rs
Last active February 12, 2022 23:46
Very simple Actix API
use actix_web::{middleware, web, App, HttpRequest, HttpServer};
async fn say_hello(req: HttpRequest) -> &'static str {
println!("REQ: {:?}", req);
"Hello world!"
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "actix_web=info");
@AndyWatt83
AndyWatt83 / BlogPost.cs
Created December 6, 2021 23:24
A very simple entity model example
namespace Blog.Database.Entities;
public class BlogPost
{
public int Id { get; set; }
public string Title { get; set; } = default!;
}
@AndyWatt83
AndyWatt83 / BlogDbContext.cs
Created December 6, 2021 23:22
A data context for a very simple entity framework example
using Blog.Database.Entities;
using Microsoft.EntityFrameworkCore;
namespace Blog.Database;
public class AppDbContext : DbContext
{
public DbSet<BlogPost> Posts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
"name": "C# (.NET)",
"dockerComposeFile": [
"../docker/docker-compose.yaml"
],
"service": "dev-env",
"workspaceFolder": "/workspace",
"settings": {},
"extensions": [
"ms-dotnettools.csharp",
version: '3'
services:
database:
container_name: postgres
image: "postgres"
env_file:
- database/database.env
volumes:
- blog-database-data:/var/lib/postgresql/data/
dev-env:
@AndyWatt83
AndyWatt83 / devcontainer.json
Created May 5, 2021 18:58
Dev Container for Docker
{
"name": "Existing Docker Compose (Extend)",
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
],
"service": "truffle_suite",
"workspaceFolder": "/workspace",
"settings": {
"terminal.integrated.shell.linux": null
@AndyWatt83
AndyWatt83 / truffle-config.js
Created May 5, 2021 18:52
Truffle Config for Docker
module.exports = {
networks: {
development: {
host: "ganache-cli",
port: 8545,
network_id: "57771",
},
}
};
@AndyWatt83
AndyWatt83 / docker-compose.yml
Created May 4, 2021 22:09
Docker compose for Ethereum development
version: "3"
services:
# start the ganache cli container
ganache-cli:
container_name: ganache-cli
build:
context: ./docker/ganache-cli
# note host:container
ports:
- 5545:8545
@AndyWatt83
AndyWatt83 / Dockerfile
Created May 4, 2021 22:07
ganache-cli Dockerfile
FROM trufflesuite/ganache-cli:latest
RUN /bin/sh -c "apk add --no-cache bash"
ENTRYPOINT node /app/ganache-core.docker.cli.js --quiet --networkId 57771 --verbose --host 0.0.0.0