Add car cgi
This commit is contained in:
parent
88c1d0d626
commit
27adf8569d
|
@ -0,0 +1,66 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"net/http/cgi"
|
||||||
|
"os"
|
||||||
|
"github.com/jsgoecke/tesla"
|
||||||
|
"github.com/coduno/netrc"
|
||||||
|
)
|
||||||
|
|
||||||
|
const authtok = "~!Jf5!uYFxhK"
|
||||||
|
const clientId = "81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384"
|
||||||
|
const clientSec = "c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3"
|
||||||
|
|
||||||
|
type Handler struct {
|
||||||
|
cgi.Handler
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.FormValue("auth") != authtok {
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
fmt.Fprintln(w, "NO: Invalid authtok")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Setenv("HOME", "/home/neale")
|
||||||
|
n, _ := netrc.Parse()
|
||||||
|
secrets := n["gitlab.com"] // Requiring a password is such bullshit.
|
||||||
|
|
||||||
|
auth := tesla.Auth{
|
||||||
|
ClientID: clientId,
|
||||||
|
ClientSecret: clientSec,
|
||||||
|
Email: secrets.Login,
|
||||||
|
Password: secrets.Password,
|
||||||
|
}
|
||||||
|
cli, err := tesla.NewClient(&auth)
|
||||||
|
if err != nil {
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
fmt.Fprintln(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
vehicles, err := cli.Vehicles()
|
||||||
|
if err != nil {
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
fmt.Fprintln(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
vehicle := vehicles[0]
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
fmt.Fprintln(w, "OK")
|
||||||
|
fmt.Fprintln(w, vehicle.StartAirConditioning())
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.SetOutput(os.Stdout)
|
||||||
|
log.SetFlags(0)
|
||||||
|
log.SetPrefix("Status: 500 CGI Go Boom\nContent-type: text/plain\n\nERROR: ")
|
||||||
|
h := Handler{}
|
||||||
|
if err := cgi.Serve(h); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
87
install
87
install
|
@ -17,64 +17,75 @@ older () {
|
||||||
|
|
||||||
|
|
||||||
html () {
|
html () {
|
||||||
target=$DESTDIR/${1%mdwn}html
|
target=$DESTDIR/${1%mdwn}html
|
||||||
if older $target $1 tmpl/*; then
|
if older $target $1 tmpl/*; then
|
||||||
echo "HTML $1"
|
echo "HTML $1"
|
||||||
mkdir -p $(dirname $target)
|
mkdir -p $(dirname $target)
|
||||||
./tmpl/mdwntohtml < $1 > $target
|
./tmpl/mdwntohtml < $1 > $target
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
copy () {
|
copy () {
|
||||||
target=$DESTDIR/$1
|
target=$DESTDIR/$1
|
||||||
if older $target $1; then
|
if older $target $1; then
|
||||||
echo "COPY $1"
|
echo "COPY $1"
|
||||||
mkdir -p $(dirname $target)
|
mkdir -p $(dirname $target)
|
||||||
cp $1 $target
|
cp $1 $target
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cc () {
|
cc () {
|
||||||
target=$DESTDIR/${1%.c}
|
target=$DESTDIR/${1%.c}
|
||||||
if older $target $1; then
|
if older $target $1; then
|
||||||
echo "CC $1"
|
echo "CC $1"
|
||||||
gcc -o $target $1
|
gcc -o $target $1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
gc () {
|
gc () {
|
||||||
target=$DESTDIR/${1%.go}
|
target=$DESTDIR/${1%.go}
|
||||||
if older $target $1; then
|
if older $target $1; then
|
||||||
echo "GO $1"
|
echo "GO $1"
|
||||||
go build -o $target $1
|
go build -o $target $1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setuid () {
|
||||||
|
target=$DESTDIR/${1%.*}
|
||||||
|
echo "SETUID $target"
|
||||||
|
chmod u+s $target
|
||||||
}
|
}
|
||||||
|
|
||||||
install () {
|
install () {
|
||||||
fd=$(dirname $fn)
|
fd=$(dirname $fn)
|
||||||
echo "SUBINSTALL $fd"
|
echo "SUBINSTALL $fd"
|
||||||
(cd $fd && ./install $DESTDIR/$fd)
|
(cd $fd && ./install $DESTDIR/$fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
git ls-files | while read fn; do
|
git ls-files | while read fn; do
|
||||||
case "$fn" in
|
case "$fn" in
|
||||||
.*|*/.*|*~|install)
|
.*|*/.*|*~|install)
|
||||||
;;
|
true # Skip
|
||||||
|
;;
|
||||||
*/install)
|
*/install)
|
||||||
install $fn
|
install $fn
|
||||||
;;
|
;;
|
||||||
|
car.cgi.go)
|
||||||
|
gc $fn
|
||||||
|
setuid $fn
|
||||||
|
;;
|
||||||
*.mdwn)
|
*.mdwn)
|
||||||
html $fn
|
html $fn
|
||||||
;;
|
;;
|
||||||
*.cgi.c)
|
*.cgi.c)
|
||||||
cc $fn
|
cc $fn
|
||||||
;;
|
;;
|
||||||
*.cgi.go)
|
*.cgi.go)
|
||||||
gc $fn
|
gc $fn
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
copy $fn
|
copy $fn
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
Title: I Also Enjoy Wearing Kilts
|
||||||
|
|
||||||
|
*This was published as a [letter to the Editor of the Daily Post](http://www.ladailypost.com/content/letter-editor-i-also-enjoy-wearing-kilts)*
|
||||||
|
|
||||||
|
September 28, 2016
|
||||||
|
|
||||||
|
I enjoyed seeing the article "Los Alamos County Council Candidate Models Kilts" - click [here](http://www.ladailypost.com/content/los-alamos-county-council-candidate-models-kilts).
|
||||||
|
|
||||||
|
I've been wearing kilts to work several days a week since August, and find them practical and comfortable. I get positive comments every time I wear one!
|
||||||
|
|
||||||
|
Congratulations to Jaret McDonald on getting the modeling gig!
|
|
@ -20,8 +20,9 @@
|
||||||
<option class="item-select-option" value="000000,ffffff,ffffff">Dark</option>
|
<option class="item-select-option" value="000000,ffffff,ffffff">Dark</option>
|
||||||
<option class="item-select-option" value="ffffff,000000,000000">Light</option>
|
<option class="item-select-option" value="ffffff,000000,000000">Light</option>
|
||||||
<option class="item-select-option" value="000000,ffffff,aaaaaa">Gray</option>
|
<option class="item-select-option" value="000000,ffffff,aaaaaa">Gray</option>
|
||||||
<option class="item-select-option" value="000000,ffffff,aa55ff">Dusk</option>
|
<option class="item-select-option" value="000000,ff55ff,ffffff">Dusk</option>
|
||||||
<option class="item-select-option" value="000000,ffffff,ffff55">Spring</option>
|
<option class="item-select-option" value="000000,ffff55,ffffff">Spring</option>
|
||||||
|
<option class="item-select-option" value="000000,ffaa55,ffffff">Fall</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ function submit() {
|
||||||
} else if (t == "text") {
|
} else if (t == "text") {
|
||||||
v = Number(input.value);
|
v = Number(input.value);
|
||||||
} else if (t == "select-one") {
|
} else if (t == "select-one") {
|
||||||
v = Number(input.value);
|
v = input.value;
|
||||||
} else {
|
} else {
|
||||||
console.log("Unknown type: " + t);
|
console.log("Unknown type: " + t);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -94,7 +94,7 @@ action send to the list and the list only, and provides a "reply to
|
||||||
author" action that will always send to the message's author whether
|
author" action that will always send to the message's author whether
|
||||||
it's a list or not. "Reply to author" honors the `Reply-To` field.
|
it's a list or not. "Reply to author" honors the `Reply-To` field.
|
||||||
This is exactly the convenient behavior Simon claims to want in his
|
This is exactly the convenient behavior Simon claims to want in his
|
||||||
essay, and it can all be done using standard behavior.
|
"considered useful" essay, and it can all be done using standard behavior.
|
||||||
|
|
||||||
|
|
||||||
Getting two copies of the same email
|
Getting two copies of the same email
|
||||||
|
|
|
@ -91,7 +91,7 @@ download a [tarball of the latest
|
||||||
commit](http://woozle.org/neale/g.cgi/x11/xss/snapshot/xss-master.tar.gz), or clone the
|
commit](http://woozle.org/neale/g.cgi/x11/xss/snapshot/xss-master.tar.gz), or clone the
|
||||||
git repository:
|
git repository:
|
||||||
|
|
||||||
git clone http://woozle.org/~neale/projects/xss
|
git clone http://woozle.org/~neale/projects/x11/xss
|
||||||
|
|
||||||
|
|
||||||
History
|
History
|
||||||
|
|
Loading…
Reference in New Issue