Remove /eg (#1180)

This code is untested and largely hasn't been updated for changes to Hy.

Partly addresses #1162.
This commit is contained in:
Kodi Arfer 2016-12-20 00:13:04 -08:00 committed by Tuukka Turto
parent 944d61eaf3
commit 21f9589291
22 changed files with 0 additions and 295 deletions

View File

@ -1 +0,0 @@
env

View File

@ -1,23 +0,0 @@
App Engine skeleton for hylang
==============================
# Demo
[proppy-hy.appspot.com](https://proppy-hy.appspot.com)
[proppy-hy.appspot.com/paultag](https://proppy-hy.appspot.com/paultag)
# Setup
```
pip install -r requirements.txt -t env
```
# Run locally
```
dev_appserver.py .
```
# Deploy
```
appcfg.py -a ${APPID} --oauth2 update .
```

View File

@ -1,13 +0,0 @@
application: hy-sample
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.__hymain__.app

View File

@ -1,3 +0,0 @@
import os.path
import sys
sys.path.insert(0, os.path.abspath('env'))

View File

@ -1,7 +0,0 @@
(require hy.contrib.meth)
(import [flask [Flask redirect]])
(def app (Flask __name__))
(route hello "/<name>" [name] (.format "(hello \"{0}!\")" name))
(route root "/" [] (redirect "/hyne"))

View File

@ -1,2 +0,0 @@
from hy.importer import import_file_to_module
__hymain__ = import_file_to_module('__hymain__', 'main.hy')

View File

@ -1,2 +0,0 @@
Flask
hy==0.9.10 # master is broken because of rply

View File

@ -1,6 +0,0 @@
(import [clint.textui [progress]]
[time [sleep]]
[random [random]])
(for [x (.bar progress (range 100))]
(sleep (* (random) 0.1)))

View File

@ -1,12 +0,0 @@
(require hy.contrib.curry)
(defnc s [x y z] ((x z) (y z))) ; λxyz.xz(yz)
(defnc k [x] (fn [y] x)) ; λx.λy.x
(defnc i [x] x) ;; λx.x
(defnc succ [n] (+ n 1))
(print (((((s ((((k s) k) i) i)) (i i)) ((i (i i))
((((k s) i) ((s (k s)) k)) i))) succ) 0))

View File

@ -1,40 +0,0 @@
#!/usr/bin/env hy
;; Copyright (c) Paul R. Tagliamonte <paultag@debian.org>, 2013 under the terms
;; of the Expat license, a copy of which you have should have received with
;; the source.
(import sys)
(defn parse-rfc822-file [path]
"Parse an RFC822 file"
(with-as (open path "r") fd
(parse-rfc822-stream fd)))
(defn parse-rfc822-stream [fd]
"Parse an RFC822 stream"
(setv bits {})
(setv key None)
(for [line fd]
(if (in ":" line)
(do (setv line (.split line ":" 1))
(setv key (.strip (get line 0)))
(setv val (.strip (get line 1)))
(assoc bits key val))
(do
(if (= (.strip line) ".")
(assoc bits key (+ (get bits key) "\n"))
(assoc bits key (+ (get bits key) "\n" (.strip line)))))))
bits)
(setv block (parse-rfc822-file (get sys.argv 1)))
(setv source (get block "Source"))
(print source "is a(n)" (get block "Description"))
(import [sh [apt-cache]])
(setv archive-block (parse-rfc822-stream (.show apt-cache source)))
(print "The archive has version" (get archive-block "Version") "of" source)

View File

@ -1,27 +0,0 @@
;;; Simple Flask application
;;;
;;; Requires to have Flask installed
;;;
;;; You can test it via:
;;;
;;; $ curl 127.0.0.1:5151
;;; $ curl -X POST 127.0.0.1:5151/post
;;; $ curl -X POST 127.0.0.1:5151/both
;;; $ curl 127.0.0.1:5151/both
(import [flask [Flask]])
(require hy.contrib.meth)
(setv app (Flask "__main__"))
(route get-index "/" []
(str "Hy world!"))
(post-route post-index "/post" []
(str "Hy post world!"))
(route-with-methods both-index "/both" ["GET" "POST"] []
(str "Hy to both worlds!"))
(apply app.run [] {"port" 5151})

View File

@ -1,11 +0,0 @@
(import [gevent.server [StreamServer]])
(defn handle [socket address]
(.send socket "Hello from Lisp!\n")
(for [x (range 5)] (.send socket (+ (str x) "\n")))
(.close socket))
(setv server (StreamServer (, "127.0.0.1" 5000) handle))
(.serve-forever server)

View File

@ -1,25 +0,0 @@
;;; Hy tumblr printer.
;;; Copyright (c) Paul R. Tagliamonte, 2013, MIT/Expat license.
(import [lxml [etree]]
[sys [argv]])
(try
(import [urllib.request [urlopen]])
(except [ImportError]
(import [urllib2 [urlopen]])))
(defn get-rss-feed-name [tumblr]
(.format "http://{0}.tumblr.com/rss" tumblr))
(defn get-rss-feed [tumblr]
(.parse etree (urlopen (get-rss-feed-name tumblr))))
(defn print-posts [tumblr]
(for [post (.xpath (get-rss-feed tumblr) "//item/title")]
(print post.text)))
(if (cut argv 2)
(print-posts (get argv 2))
(print-posts "this-plt-life"))

View File

@ -1,11 +0,0 @@
(import [concurrent.futures [ThreadPoolExecutor as-completed]]
[random [randint]]
[sh [sleep]])
(defn task-to-do [] (sleep (randint 1 5)))
(with-as (ThreadPoolExecutor 10) executor
(setv jobs (list-comp (.submit executor task-to-do) (x (range 0 10))))
(for [future (as-completed jobs)]
(.result future)))

View File

@ -1 +0,0 @@
target-c

View File

@ -1,14 +0,0 @@
RPY_WRAP = python -m hy
RPY_FLAGS = -O2
RPY = ~/pypy/rpython/bin/rpython
all: clean build
clear:
@clear
clean:
rm -f target-c
build:
$(RPY_WRAP) $(RPY) $(RPY_FLAGS) target.py

View File

@ -1,2 +0,0 @@
Thanks so much for Romain Guillebert for sitting down and hacking
this out with me. A true hacker in every sense of the word. Thank you!

View File

@ -1,15 +0,0 @@
import hy
import sys
import test
def entry_point(argv):
return test.main(argv)
def target(driver, args):
return entry_point, None
if __name__ == "__main__":
entry_point(sys.argv)

View File

@ -1,12 +0,0 @@
;; hello, rHy!
(defn fib [n]
(if (<= n 2) n
(+ (fib (- n 1)) (fib (- n 2)))))
(defn main [argv]
(for [x [1 2 3 4 5 6 7 8]]
(print (fib x)))
0)

View File

@ -1,5 +0,0 @@
;; python-sh from hy
(import [sh [cat grep]])
(print "Words that end with `tag`:")
(print (-> (cat "/usr/share/dict/words") (grep "-E" "tag$")))

View File

@ -1,24 +0,0 @@
#!/usr/bin/env hy
;; Copyright (c) Paul R. Tagliamonte <paultag@debian.org>, 2013 under the terms
;; of the Expat license, a copy of which you should have received with
;; the source.
(import sys)
(import [sunlight [openstates]]
[collections [Counter]])
(def *state* (get sys.argv 1))
(defn get-legislators [state]
(apply openstates.legislators [] {"state" state}))
(defn get-party-breakdown [state]
(Counter (map
(lambda [x] (get x "party"))
(get-legislators state))))
(print *state* "-" (get-party-breakdown *state*))

View File

@ -1,39 +0,0 @@
;; To run this example, do the following:
;; $ hy get-page.hy http://docs.hylang.org/en/latest/
;;
;; At which point, you should see output like this:
;; 2013-06-24 23:03:57-0700 [-] Log opened.
;; 2013-06-24 23:03:57-0700 [-] Starting factory <HTTPClientFactory: http://docs.hylang.org/en/latest/>
;; 2013-06-24 23:03:57-0700 [HTTPPageGetter,client] Byte count for the content of the HTTP page passed: 11835
;; 2013-06-24 23:03:57-0700 [HTTPPageGetter,client] Preparing to stop reactor ...
;; 2013-06-24 23:03:57-0700 [HTTPPageGetter,client] Stopping factory <HTTPClientFactory: http://docs.hylang.org/en/latest/>
;; 2013-06-24 23:03:57-0700 [-] Main loop terminated.
(import sys)
(import [twisted.web.client [getPage]]
[twisted.internet [reactor]]
[twisted.python [log]])
(defn get-page-size [result]
(print
(+ "Byte count for the content of the HTTP page passed: "
(str (len result)))))
(defn log-error [err]
(log.msg err))
(defn finish [ignore]
(log.msg "Preparing to stop reactor ...")
(reactor.stop))
(defn get-page [url]
(let [d (getPage url)]
(d.addCallback get-page-size)
(d.addErrback log-error)
(d.addCallback finish)))
(if (= __name__ "__main__")
(do
(log.startLogging sys.stdout)
(get-page (second sys.argv))
(reactor.run)))