Skip to content

Instantly share code, notes, and snippets.

import clojure.lang.Compiler;
import clojure.lang.RT;
import clojure.lang.Symbol;
import clojure.lang.Var;
public class ClojureUtil {
public static void main() {
Var call = RT.var("clojure.main", "main");
call.invoke();
(defun me-insert-delete-char-at-beginning (begin-pos end-pos c)
"insert or delete c at beginning of every line"
(save-excursion
(goto-char begin-pos)
(move-beginning-of-line nil)
(let ((line-num-begin (line-number-at-pos begin-pos))
(line-num-end (line-number-at-pos end-pos))
(delete (eq c (char-after (point)))))
(while (<= line-num-begin line-num-end)
;; set delete for insert flag base on first line
@zhuzhonghua
zhuzhonghua / init_make.py
Created June 3, 2019 02:32
用于生成makefile的python文件
#python3
import sys
import os
import re
#all src dirs
dirs = [".", "base", "render"]
temp_dir = "temp"
@zhuzhonghua
zhuzhonghua / py
Created May 31, 2019 08:28
moviepy 调整速度
sub_clip = clip.subclip(t[0], t[1])
sub_clip = sub_clip.speedx(factor=2)
@zhuzhonghua
zhuzhonghua / generate.py
Last active May 24, 2019 08:22
automate generate video
import os
import random
from moviepy.editor import VideoFileClip, concatenate_videoclips
i_files = [("GH010024.MP4", (39, 41), ("00:17:15","00:17:17")),
("GH020024.MP4", ("00:00:29","00:00:32"),("00:05:21","00:05:23")),
("GH030024.MP4", ("00:07:02","00:07:05"))]
o_file = "final.mp4"
解决 emacs 选中不高亮的问题
原来需要使用transient-mark-mode
使用的主题solarize把transient-mark-mode禁用了
需要手动打开一下
所以使用了一个hook, transient-mark-mode-off-hook,发现关了就手动打开
@zhuzhonghua
zhuzhonghua / testclient.clj
Created January 25, 2019 02:47
clojure socket client send int bytebuffer
(ns ssrvclj.testclient
(:import [java.net Socket]
[java.nio ByteBuffer]))
(def buf (ByteBuffer/allocate 4));
(.putInt buf 100)
(def byte-buf (.array buf))
(def sock (Socket. "127.0.0.1" 8888))
@zhuzhonghua
zhuzhonghua / srvclj.clj
Created January 25, 2019 02:43
clojure server using java nio
(ns srvclj.core
(:import [java.nio.channels ServerSocketChannel Selector SelectionKey]
[java.nio ByteBuffer]
[java.net InetSocketAddress])
(:gen-class))
(def buf (ByteBuffer/allocate 1024));
(def selector (Selector/open))
(def serverChannel (ServerSocketChannel/open))
@zhuzhonghua
zhuzhonghua / CMakeLists.txt
Created January 21, 2019 13:44
cmake file sample
cmake_minimum_required (VERSION 3.5)
project(dummyplayer)
aux_source_directory(swf DIR_SWF)
aux_source_directory(base DIR_BASE)
aux_source_directory(render DIR_RENDER)
set(DUMMYSRC src/main.cpp ${DIR_SWF} ${DIR_BASE} ${DIR_RENDER})
SET(TOP ${PROJECT_SOURCE_DIR})
@zhuzhonghua
zhuzhonghua / gist:cdeac8e1fa9c3e72b82e86a0522063bd
Created January 21, 2019 03:01
解决cpp中public/private/protected等的缩进问题
头文件进入c++-mode
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
access-label的缩进设置成--
((access-label . --))
C-x C-o 查看设置某行对应label的缩进值
C-x C-s 查看整体缩进值