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:
| (define (take-even lst) | |
| (letrec [(taker (lambda (lst-rem result) | |
| ;(printf "~a ~a" lst-rem result) | |
| (if (< (length lst-rem) 2) | |
| result | |
| (cons (car (cdr lst-rem)) (taker (cdr (cdr lst-rem)) result)))))] | |
| (taker lst '()))) |
| ; ISIN, e.g. US0378331005 | |
| (define Apple-ISIN "US0378331005") | |
| ; ISO6166 International Securities Identification Number (ISIN) | |
| ; ISO3166-2 plus National Securities Identifying Number (NSIN) | |
| (match Apple-ISIN | |
| [(regexp #px"^([A-Z]{2})([0-9]{9})([0-9])$" (list _ country NSIN check)) | |
| (list country NSIN check)]) |
| ;;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 |