TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Babashka Clojure nREPL as a system interface

115 点作者 Borkdude超过 2 年前

3 条评论

sph超过 2 年前
Babashka looks great (and perhaps the one thing that will make me try Clojure. I am allergic to the JVM), and I didn&#x27;t know of osquery.<p>But am I blind, or is there no documentation of what osquery modules&#x2F;tables are available?<p><a href="https:&#x2F;&#x2F;osquery.readthedocs.io&#x2F;en&#x2F;stable&#x2F;" rel="nofollow">https:&#x2F;&#x2F;osquery.readthedocs.io&#x2F;en&#x2F;stable&#x2F;</a><p>EDIT: rewritten the comment so it&#x27;s less of a rant
评论 #33764318 未加载
评论 #33763017 未加载
user3939382超过 2 年前
I hear near universal praise for repl development but in my very limited experience with it, found it nearly impossible. Maybe someone can clarify?<p>What I saw was that the repl leads to a runtime state that is invisible and therefore hard to predict. For example, you define a function in the repl, or assign a value to a variable. You’re just supposed to keep the existence of those declarations in your head? I must be missing something.
评论 #33766093 未加载
评论 #33766176 未加载
评论 #33766457 未加载
评论 #33767056 未加载
gemstones超过 2 年前
One nice thing about this setup is that it&#x27;s not specific to Clojure&#x2F;Lisp; any scripting language with a REPL will do this well:<p><i>Python:</i><p><pre><code> import subprocess import json def osquery(query): return json.loads(subprocess.check_output([&quot;osqueryi&quot;, &quot;--json&quot;, query])) #&gt;&gt;&gt; osquery(&quot;select * from routes where destination = &#x27;::1&#x27;&quot;) #&gt;&gt;&gt; [{&#x27;destination&#x27;: &#x27;::1&#x27;, &#x27;flags&#x27;: &#x27;2098181&#x27;, &#x27;gateway&#x27;: &#x27;::1&#x27;, &#x27;hopcount&#x27;: &#x27;0&#x27;, &#x27;interface&#x27;: &#x27;lo0&#x27;, &#x27;metric&#x27;: &#x27;0&#x27;, &#x27;mtu&#x27;: &#x27;16384&#x27;, &#x27;netmask&#x27;: &#x27;128&#x27;, &#x27;source&#x27;: &#x27;&#x27;, &#x27;type&#x27;: &#x27;local&#x27;}] </code></pre> <i>Node:</i><p><pre><code> const { execFile } = require(&quot;child_process&quot;); async function osquery(query) { return new Promise((resolve, reject) =&gt; { execFile(&quot;osqueryi&quot;, [&quot;--json&quot;, query], (error, out, _err) =&gt; { if (error) { reject(error); return; } resolve(JSON.parse(out)); }); }); } &#x2F;&#x2F;&gt; await osquery(&quot;select * from routes where destination = &#x27;::1&#x27;&quot;); &#x2F;&#x2F;&gt; [ &#x2F;&#x2F;&gt; { &#x2F;&#x2F;&gt; destination: &#x27;::1&#x27;, &#x2F;&#x2F;&gt; flags: &#x27;2098181&#x27;, &#x2F;&#x2F;&gt; gateway: &#x27;::1&#x27;, &#x2F;&#x2F;&gt; hopcount: &#x27;0&#x27;, &#x2F;&#x2F;&gt; interface: &#x27;lo0&#x27;, &#x2F;&#x2F;&gt; metric: &#x27;0&#x27;, &#x2F;&#x2F;&gt; mtu: &#x27;16384&#x27;, &#x2F;&#x2F;&gt; netmask: &#x27;128&#x27;, &#x2F;&#x2F;&gt; source: &#x27;&#x27;, &#x2F;&#x2F;&gt; type: &#x27;local&#x27; &#x2F;&#x2F;&gt; } &#x2F;&#x2F;&gt; ] </code></pre> <i>Ruby:</i><p><pre><code> require &quot;open3&quot; require &quot;json&quot; def osquery(query) out, err, exit_status = Open3.capture3(&quot;osqueryi&quot;, &quot;--json&quot;, query) if exit_status != 0 raise err end return JSON.parse(out, symbolize_names: true) end #irb(main):1:0&gt; osquery(&quot;select * from routes where destination = &#x27;::1&#x27;&quot;) #=&gt; #[{:destination=&gt;&quot;::1&quot;, # :flags=&gt;&quot;2098181&quot;, # :gateway=&gt;&quot;::1&quot;, # :hopcount=&gt;&quot;0&quot;, # :interface=&gt;&quot;lo0&quot;, # :metric=&gt;&quot;0&quot;, # :mtu=&gt;&quot;16384&quot;, # :netmask=&gt;&quot;128&quot;, # :source=&gt;&quot;&quot;, # :type=&gt;&quot;local&quot;}]</code></pre>
评论 #33768436 未加载