写了个LeetCode客户端,人在家中坐,offer天上来

这样就可以用Emacs刷LeetCode啦!

祝找工作的同学都能找到好工作!

31 个赞

Great 最近刚好在leetcode刷题 :smile:

好东西,方便了

标题不错,要是能躺着收 offer 就更好了 :sunglasses:

第一题的c++解法 有小于 5ms 的吗?

第一次了解leetcode, 感谢

为了学习rust去刷leetcode,结果代码没写多少,大部分时间在跟编译器战斗 :rofl:

2 个赞

看到vscode有,想搞个emacs的,无奈自己写不出来,现在有了:+1:

我也写了一个emacs leetcode 插件,借助 leetcode-cli,没有楼主那么好看。但我自己用得还挺顺手,借楼宣传一波。https://github.com/ginqi7/leetcode-emacs

1 个赞

url.el 如何发送 Content-Type: multipart/form-data 请求

比如这样一个 HTML Form:

<form enctype="multipart/form-data" method="post">
  <input type="file" name="myFile">
</form>

用户提交这个表单后,浏览器大概会发送这样一个请求:

POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=c4882e0b35fe052121ae5a562e6b8256

--c4882e0b35fe052121ae5a562e6b8256
Content-Disposition: form-data; name="myFile"; filename="foo.txt"
Content-Type: text/plain

The contents of foo.txt.

--c4882e0b35fe052121ae5a562e6b8256-

curl 发送这个请求:

curl -F [email protected] url

url.el 发送这个请求:

(let* ((boundary (mml-compute-boundary '()))
       (url-request-method "POST")
       (url-request-extra-headers
        `(("Content-Type" . ,(concat "multipart/form-data; boundary=" boundary))))
       (url-request-data
        (mm-url-encode-multipart-form-data
         '(("file"
            ("name" . "myFile")
            ("filename" . "foo.txt")
            ("filedata" . "This is the contents of foo.txt.")))
         boundary)))
  (display-buffer
   (url-retrieve-synchronously "http://localhost:8080/test/")))

必不可少的是 filedata,它表示数据。

1 个赞

很不错!辛苦了,最近正准备研究leetcode client

感谢指点!现在已经换用request.el了,网络请求全部用cURL

主要就是用浏览器查看LeetCode网站的请求,然后用Emacs解析请求结果。

LeetCode的题目是直接返回的html,直接用Emacs的shr.el渲染就可以了。现在只实现了提交代码的功能。

昨天把url.el换成了request.el,底层用cURL。而且也尽可能的使用异步任务,减少Emacs的卡顿。

2 个赞

REQUEST [error] Error (error) while connecting to https://leetcode.com/accounts/login

我把request-message-levelrequest-log-level设成debug后显示了这些东西

REQUEST [debug] Run: curl --silent --include --location --compressed --cookie d:/Development/.emacs.d/request/curl-cookie-jar --cookie-jar d:/Development/.emacs.d/request/curl-cookie-jar --write-out \n(:num-redirects %{num_redirects} :url-effective %{url_effective}) https://leetcode.com/accounts/login
REQUEST [debug] REQUEST--CURL-CALLBACK event = exited abnormally with code 2

REQUEST [debug] REQUEST--CURL-CALLBACK proc = #<process request curl>
REQUEST [debug] REQUEST--CURL-CALLBACK buffer = #<buffer  *request curl*>
REQUEST [debug] REQUEST--CURL-CALLBACK symbol-status = nil
REQUEST [debug] REQUEST--CALLBACK
REQUEST [debug] (buffer-string) =
curl: option --compressed: the installed libcurl version doesn't support this

curl: try 'curl --help' for more information


REQUEST [debug] REQUEST-RESPONSE--CANCEL-TIMER
REQUEST [debug] -CLEAN-HEADER
REQUEST [debug] -CUT-HEADER
REQUEST [debug] error-thrown = (error . "exited abnormally with code 2
")
REQUEST [debug] -PARSE-DATA
REQUEST [debug] parser = nil
REQUEST [debug] data = nil
REQUEST [debug] symbol-status = error
REQUEST [debug] Executing error callback.
REQUEST [error] Error (error) while connecting to https://leetcode.com/accounts/login.

win10系统,any ideas?

试试看能不能解决这个?

我明白了,辣鸡widows/system32自带的curl……problem solved

在Spacemacs中尝试使用这个包,但是 M-x leetcode 显示 Cannot open load file: No such file or directory, request-deferred 。 看了一下 load-path ,发现有leetcode的路径,同时该路径下也确实有相关文件。 由于是刚接触Emacs不久,不知道是哪出了问题,所以想问一下大家,这个问题的应该怎么解决。

应该需要安装一个包 request-deferred

原来这是一个包 :see_no_evil: ,我一直以为是Emacs延迟加载的术语,谢谢

最近添加了提交测试用例的功能,并且增强了异步支持,提交代码不会阻塞Emacs了,欧耶!接下来打算把它加到 Melpa 里,手动安装Emacs的依赖比较麻烦。