summary refs log tree commit diff stats
path: root/posts
diff options
context:
space:
mode:
Diffstat (limited to 'posts')
-rw-r--r--posts/2021-2-24+9front+UNIX+workflow28
1 files changed, 0 insertions, 28 deletions
diff --git a/posts/2021-2-24+9front+UNIX+workflow b/posts/2021-2-24+9front+UNIX+workflow
deleted file mode 100644
index 197c1df..0000000
--- a/posts/2021-2-24+9front+UNIX+workflow
+++ /dev/null
@@ -1,28 +0,0 @@
-# 9front + UNIX
-The best of both worlds
-
-Like many people I use UNIX (Linux) for "real" work, but, unlike most, I use 9front all day everyday. This is thanks to the wonderful work by the 9front people's ssh system. Here are the tools I use:
-
-sshfs(1)
-vt(1)
-ssh(1)
-
-These tools give me full access to my UNIX system from my preffered os. Here's how it works:
-
-First I connect to my UNIX machine via sshfs:
-
-	sshfs fulton@tux
-
-This exposes all the files in my UNIX system's home dir under /n/ssh in my current namespace. Then I'll open my favorite editor acme with:
-
-	acme -l lib/work.dump
-
-This opens the editor with my saved work preset. Of course, I'll need to build things, so I use a vt(1) - A virtual UNIX terminal and ssh(1) to get a shell.
-
-	vt ssh fulton@tux
-
-This gives me a great lag free editing experience (the only time acme read or write from the server is saving files) in my favorite os, along with the build tools I need.
-
-To be honest, this is much better than what I had before no more juggling git commits to be able to move from desktop to laptop and no more laggy ssh vim instances.
-
-- Fulton
/* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
package background

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

// Download takes path and url as input and downloads the data to a
// file, returning an error if there is one.
func Download(file string, url string) error {
	o, err := os.Create(file)
	if err != nil {
		err = fmt.Errorf("%s%s\n%s",
			"download.go: failed to create file: ", file,
			err.Error())
		return err
	}
	defer o.Close()

	res, err := http.Get(url)
	if err != nil {
		err = fmt.Errorf("%s%s\n%s",
			"download.go: failed to get response from ", url,
			err.Error())
		return err
	}
	defer res.Body.Close()

	// Return an error on unexpected response code.
	if res.StatusCode != http.StatusOK {
		err = fmt.Errorf("Unexpected Response: %s",
			res.Status)
		return err
	}

	// This will not copy everything to memory but will save to
	// disk as it progresses, ideal for big files or low memory
	// environments.
	_, err = io.Copy(o, res.Body)
	if err != nil {
		err = fmt.Errorf("%s\n%s",
			"download.go: failed to copy body to file",
			err.Error())
	}
	return err
}
>