-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripted auto-commit on change (2021-09-07 01:18:18) by gitwatch.sh
- Loading branch information
Showing
53 changed files
with
6,199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
;; Wrapping in an `eval-and-compile` ensures global python packages | ||
;; are available in macros defined in this file as well. | ||
(eval-and-compile | ||
(import sys os) | ||
(sys.path.append "~/<path-to-global-libs>")) | ||
|
||
;; These modules, macros, and methods are now available in any Hy repl | ||
(import | ||
re | ||
json | ||
pathlib [Path] | ||
hyrule [pp pformat]) | ||
|
||
(require | ||
hyrule [%]) | ||
|
||
(setv | ||
;; Spy and output-fn will be set automatically for all hy repls | ||
repl-spy True | ||
repl-output-fn pformat | ||
;; We can even add colors to the promps. This will set `=>` to green and `...` to red. | ||
sys.ps1 "\x01\x1b[0;32m\x02=> \x01\x1b[0m\x02" | ||
sys.ps2 "\x01\x1b[0;31m\x02... \x01\x1b[0m\x02") | ||
|
||
;; Functions and Macros will be available in the repl without qualification | ||
(defn slurp [path] | ||
(setv path (Path path)) | ||
(when (path.exists) | ||
(path.read-text))) | ||
|
||
(defmacro greet [person] | ||
`(print ~person)) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env hy | ||
|
||
;; snippet by HN user volent: | ||
|
||
(import [flask [Flask]]) | ||
(setv app (Flask "Flask test")) | ||
(with-decorator (app.route "/") | ||
(defn index [] | ||
"Hello World !")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(import starlette.responses :as RES) | ||
(import starlette.applications :as SA) | ||
(import starlette.routing :as RO) | ||
|
||
|
||
|
||
(defn/a homepage[req] (RES.JSONResponse | ||
{"hello" "world"})) | ||
|
||
|
||
|
||
|
||
(setv app (SA.Starlette :debug True :routes | ||
[ | ||
(RO.Route "/" homepage)])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import hy | ||
import starlette.responses as Res | ||
import starlette.applications as SA | ||
import starlette.routing as RO | ||
|
||
|
||
async def homepage(req): | ||
return Res.JSONResponse({'hello': 'world'}) | ||
|
||
|
||
app = SA.Starlette(debug=True, routes=[RO.Route('/', homepage)]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from starlette.applications import Starlette | ||
from starlette.responses import JSONResponse | ||
from starlette.routing import Route | ||
|
||
|
||
async def homepage(request): | ||
return JSONResponse({'hello': 'world'}) | ||
|
||
async def hophop(request): | ||
source = request.path_params['source'] | ||
destination = request.path_params['destination'] | ||
return JSONResponse({source: destination}) | ||
|
||
app = Starlette(debug=True, routes=[ | ||
Route('/', homepage), | ||
Route('/{source}/{destination}', hophop) | ||
]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import hy | ||
from blabla import app | ||
|
||
if __name__ == "__main__": | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .repl import embed | ||
|
||
__all__ = ["embed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
Make `python -m ptpython` an alias for running `./ptpython`. | ||
""" | ||
from .entry_points.run_ptpython import run | ||
|
||
run() |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.