Run a ssh tunnel to a database via jump / bastion host
ssh -v -L 9999:[database host]:5432 jumphost
psql -h localhost -p 9999 -U [user] --password -d [database]
If you get:
;;By Jhen Kung, [email protected] | |
;;app.rkt | |
#lang racket(require web-server/servlet | |
web-server/servlet-env | |
"router.rkt") | |
(serve/servlet mordor | |
#:port 8080 | |
#:servlet-path "/" |
BEGIN { | |
int visited[node_t]; | |
int visit(node_t n, edge_t e) { | |
if (visited[n] == 0) { | |
visited[n] = 1; | |
for (e = fstin(n); e; e = nxtin(e)) { | |
visit(e.tail, NULL); | |
} |
/* LISP as a register machine. Any obj not in a reg or on the stack may be | |
* collected at the end of eval (). */ | |
#include <ctype.h> | |
#include <iso646.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
typedef enum { no } truth; | |
enum type { nil_type, int_type, sym_type, cons_type, str_type }; | |
typedef struct obj { |
#include<stdio.h> | |
int lookahead = -1; | |
void getchar_skipwhitespace() { while( (lookahead = getchar()) == ' ') ; } | |
int success() { getchar_skipwhitespace(); return 1; } | |
int failure() { return 0; } | |
int lparen() { return lookahead == '(' ? success() : failure(); } | |
int rparen() { return lookahead == ')' ? success() : failure(); } | |
int sym() { return lookahead >= 'a' && lookahead <= 'z' ? success() : failure(); } | |
int star( int (*a) (void) ) { return a() ? star(a) : 1; } | |
int main(int argc, char *argv[]) { |
run Proc.new { |env| | |
['200', {'Content-Type' => 'text/html'}, [env.to_s]] | |
} |
require 'rack' | |
app = Proc.new do |env| | |
['200', {'Content-Type' => 'text/html'}, [env.to_s]] | |
end | |
Rack::Handler::WEBrick.run app |
Run a ssh tunnel to a database via jump / bastion host
ssh -v -L 9999:[database host]:5432 jumphost
psql -h localhost -p 9999 -U [user] --password -d [database]
If you get:
run = ->(a,v) { a.reduce(v){|x,y| break unless y.call(v); x } } | |
run.call [ | |
->(v) { puts "Hello"; true }, | |
->(v) { puts "World"; false }, | |
->(v) { puts "!"; true } | |
], 1 |
run = ->(p) do | |
f, *r = p | |
f.call(->() { run.call(r) } , ->() { false }) if f | |
end | |
run.call [ ->(s,e){puts "Hello"; s.call} , | |
->(s,e){puts "World";s.call} ] |
#lang racket | |
; | |
; A self-evaluating Lisp interpreter implemented without define, letrec, let | |
; | |
; Copyright (C) 2017 A. Carl Douglas | |
; | |
; without current-namespace, this racket error occurred: | |
; ?: function application is not allowed; | |
; no #%app syntax transformer is bound in: |