Skip to content

Instantly share code, notes, and snippets.

View xieyunzi's full-sized avatar
🎛️
Automation

Reiner xieyunzi

🎛️
Automation
View GitHub Profile
@xieyunzi
xieyunzi / list-direct-dependencies-of-a-binary.md
Last active July 10, 2018 04:28
list direct dependencies of a binary
@xieyunzi
xieyunzi / how-goroutines-work.md
Created May 16, 2018 03:31
How goroutines work
const copyToClipboard = str => {
const el = document.createElement('textarea'); // Create a <textarea> element
el.value = str; // Set its value to the string that you want copied
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
el.style.position = 'absolute';
el.style.left = '-9999px'; // Move outside the screen to make it invisible
document.body.appendChild(el); // Append the <textarea> element to the HTML document
const selected =
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
? document.getSelection().getRangeAt(0) // Store selection if found
(defn- invoke-private-method
[obj fn-name-string & args]
(let [m (first (filter (fn [x] (.. x getName (equals fn-name-string)))
(.. obj getClass getDeclaredMethods)))]
(. m (setAccessible true))
(. m (invoke obj (into-array Object args)))))
(defn- invoke-static-method
[klass fn-name-string & args]
(let [m (first (filter (fn [x] (.. x getName (equals fn-name-string)))
@xieyunzi
xieyunzi / gist:169157c3287bb244e34553694940a620
Created November 13, 2017 09:52
bearychat 键盘滚动
var el = document.querySelector("div[class^=viewport-]"); el.scrollTop = (el.scrollTop + el.clientHeight - 40);
@xieyunzi
xieyunzi / macro-parse-args.clj
Last active November 2, 2017 08:30
clojure macro parse args
(defmacro def-test
[name args & body]
`(defn ~name ~args
(let [[params#] ~args
parsed-args# (parse-args params#)
new-param-data# (merge parsed-args# {:uuid "0efecd84-bba0-4a95-a6dd-a3c3f7071057"})
new-params# (merge params# {:as new-param-data#})
]
(str ~name ", " ~args ", parsed: " parsed-args# ", new-args: " new-params#)
)))

Use script /tmp/output to start recording in a new shell, then type your commands and look in the /tmp/output file, e.g. with an editor or cat -vet. Type exit to the shell to exit the recording.

@xieyunzi
xieyunzi / lisp.cpp
Created September 2, 2017 11:52 — forked from ofan/lisp.cpp
Lisp interpreter in 90 lines of C++
Lisp interpreter in 90 lines of C++
I've enjoyed reading Peter Norvig's recent articles on Lisp. He implements a Scheme interpreter in 90 lines of Python in the first, and develops it further in the second.
Just for fun I wondered if I could write one in C++. My goals would be
1. A Lisp interpreter that would complete Peter's Lis.py test cases correctly...
2. ...in no more than 90 lines of C++.
Although I've been thinking about this for a few weeks, as I write this I have not written a line of the code. I'm pretty sure I will achieve 1, and 2 will be... a piece of cake!
#!/usr/bin/env emacs --script
;; https://www.lunaryorn.com/posts/emacs-script-pitfalls
(message "Hello world")
(message "%S" (/ 30 4))
@xieyunzi
xieyunzi / gist:e5284007f3d1c2a0bcb3884bab9d8e63
Last active July 26, 2017 21:15 — forked from Yaffle/gist:2623011
inplace merge sort
// inplace merge sort
// http://thomas.baudel.name/Visualisation/VisuTri/inplacestablesort.html
(function () {
"use strict";
var floor = Math.floor;
function lower(a, from, to, value, compare) {
while (to > from) {
var middle = from + floor((to - from) / 2);