Skip to content

Instantly share code, notes, and snippets.

@peterwang
peterwang / weitz.de.macros.lisp
Created November 10, 2021 04:29
THE POWER OF LISP MACROS
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10; Encoding: latin-1; -*-
;;; $Header: /usr/local/cvsrep/weitz.de/macros.lisp,v 1.18 2008/05/06 21:28:26 edi Exp $
(in-package :cl-user)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; THE POWER OF LISP MACROS ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@peterwang
peterwang / my-macros.clj
Last active November 11, 2021 09:48
Clojure Macro-writing Macros step by step.
;;; Clojure Macro-writing Macros step by step.
(ns my.macros)
;; => nil
;;;;;;;; ns and vars
*ns*
;; => #namespace[my.macros]
(def x 3)
;; => #'my.macros/x
@peterwang
peterwang / emacs-list-all-fonts.el
Created November 8, 2021 03:10
Emacs list all available fonts.
(dolist (font (font-family-list)) (insert (format ";; \"%s\"\n" font)))
;; "Source Han Mono EL"
;; "Source Han Mono K EL"
;; "Source Han Mono SC EL"
;; "Source Han Mono TC EL"
;; "Source Han Mono HC EL"
;; "Source Han Mono L"
;; "Source Han Mono K L"
;; "Source Han Mono SC L"
;; "Source Han Mono TC L"
;; This buffer is for Clojure experiments and evaluation.
;; Press C-j to evaluate the last expression.
(defn super-classes
[class]
(loop [ret {} cs (set (map #(conj [class] %) (bases class)))]
(if (seq cs)
(let [c (first cs)
bs (map #(conj c %) (bases (last c)))]
(recur (assoc-in ret c {}) (into (disj cs c) bs)))
;;; get pid of JVM
(->> (java.lang.management.ManagementFactory/getRuntimeMXBean)
(.getName)
(re-find #"\d+")
(read-string))
;; => 53590
;; 😀 https://codepoints.net/U+1f600
;; 😊 https://codepoints.net/U+1F60A
;; 𪚥 https://codepoints.net/U+2A6A5
(defn codepoint-seq [s]
(loop [i 0 e (.length s) acc []]
(if (>= i e)
acc
(let [cp (.codePointAt s i)
cc (Character/charCount cp)]
;;; print all threads
(->> (Thread/getAllStackTraces)
keys
(map (juxt (memfn getId)
(memfn getName)))
(sort-by first)
pprint)

Keybase proof

I hereby claim:

  • I am peterwang on github.
  • I am peterwang (https://keybase.io/peterwang) on keybase.
  • I have a public key whose fingerprint is CF77 DB56 4076 B137 2037 3B76 8A85 A07F 0781 46AF

To claim this, I am signing this object:

cd com.supercell.hayday_1.23.250/assets/data;
for f in *.csv ; do (dd if=$f bs=1 count=9 2>/dev/null; echo -ne "\x00\x00\x00\x00"; dd if=$f skip=9 bs=1 2>/dev/null;) | lzcat > $f.new.csv; done
Description:
php5-fpm process coredump-ed when apcu_clear_cache() and opcache_reset() was called
OS:
Linux www 3.2.0-54-virtual #82-Ubuntu SMP Tue Sep 10 20:31:18 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Packages:
ii php-apc 4.0.2-2+debphp.org~precise+1 APC User Cache for PHP 5 (transitional package)
ii php-pear 5.5.8+dfsg-3+sury.org~precise+2 PEAR - PHP Extension and Application Repository
ii php5 5.5.8+dfsg-3+sury.org~precise+2 server-side, HTML-embedded scripting language (metapackage)