This file contains hidden or 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
| ;; to save an object into a json file | |
| (with-temp-buffer | |
| (json-insert '(:foo "bar")) | |
| (write-file "~/tmp/my.json")) | |
| ;; load a json file as hash table | |
| (with-temp-buffer | |
| (insert-file-contents "~/tmp/my.json") | |
| (json-parse-buffer)) |
This file contains hidden or 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
| let group_by (f : 'a -> 'b) (ll : 'a list) : ('b, 'a list) Hashtbl.t = | |
| List.fold_left | |
| (fun acc e -> | |
| let grp = f e in | |
| let grp_mems = try Hashtbl.find acc grp with Not_found -> [] in | |
| Hashtbl.replace acc grp (e :: grp_mems); | |
| acc) | |
| (Hashtbl.create 100) | |
| ll;; |
This file contains hidden or 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
| /** | |
| * @author Bahman Movaqar <Bahman AT BahmanM.com> | |
| */ | |
| @Grab('org.jsoup:jsoup:1.8.2') | |
| import static org.jsoup.Jsoup.parse | |
| def cookieManager = new CookieManager(null, CookiePolicy.ACCEPT_ALL) | |
| CookieHandler.setDefault(cookieManager) | |
| def doc = parse( | |
| new URL('https://www.packtpub.com/packt/offers/free-learning').text |
This file contains hidden or 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
| #lang racket | |
| ;;; | |
| ;;; Author: Bahman Movaqar <Bahman AT BahmanM.com> | |
| ;;; | |
| (require net/url) | |
| (require sxml) | |
| (require net/uri-codec) | |
| (require net/http-client) | |
| (require (planet neil/html-parsing)) | |
| (require net/cookies) |