Skip to content

Instantly share code, notes, and snippets.

View t1anchen's full-sized avatar

tianchen t1anchen

View GitHub Profile
@t1anchen
t1anchen / init-cc.el
Created January 17, 2024 17:22
add your own include path to clangd in a dynamic way
;; when clangd is launched, add ./include to CPATH for include path
;; search so that eglot can do completion and definition navigation
;;
;; See https://clang.llvm.org/docs/CommandGuide/clang.html#envvar-CPATH
;; for details
(let
((current-proj-incl (file-name-concat (projectile-project-root ".") "include")))
(utils:env-append "CPATH" current-proj-incl))
@t1anchen
t1anchen / init.el
Created January 17, 2024 17:07
Mitigation to Paredit minor mode overrides RET behaviour in geiser major mode
(add-hook
'geiser-repl-mode-hook
#'(lambda ()
(paredit-mode 1)
;; RET is bound to geiser-repl-maybe-send in geiser mode
(define-key paredit-mode-map (kbd "RET") nil))

Keybase proof

I hereby claim:

  • I am t1anchen on github.
  • I am tianchen (https://keybase.io/tianchen) on keybase.
  • I have a public key ASCK4l9DOItIvwAUnsQgSrGuOeGvR-F4qgMFSn6r2rSNOwo

To claim this, I am signing this object:

@t1anchen
t1anchen / yml_format.py
Created May 30, 2014 13:06
check manual yaml file and re-format it to formulized one
#!/usr/bin/python
import sys
import yaml
def main():
"""check.py: a simple tool to check yaml format
Usage: check.py <yaml_filename>
"""
mode = 'piped'
@t1anchen
t1anchen / build.scala
Last active August 29, 2015 14:00
ant task for validating and packaging videos with proper-size data block
val fs = (new java.io.File(".")).listFiles.filter(x => x.getName.contains("asc"))
val ctx = fs.map(x => (x.getName.replace(".asc",""),scala.io.Source.fromFile(x).getLines.next))
ctx.map(i => {
val x = i._1
val y = i._2
val orig = new java.io.File(x)
val suffix = orig.getName.split('.').last
val newf = new java.io.File(y+"."+suffix)
orig.renameTo(newf)
@t1anchen
t1anchen / timer.sh
Last active August 29, 2015 13:56
Timer
#!/bin/sh
read -p "Play? " op
while [ "$op" != "n" ]
do
touch timerflag1
echo "Started ..."
@t1anchen
t1anchen / DummyInterview001.java
Created January 1, 2014 07:44
Dummy Interview Problems
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
/**
* Dummy Interview 1: Sorting
* --------------------------
@t1anchen
t1anchen / douban.math.js
Created December 29, 2013 11:52
Display Mathjax expression (including LaTeX and MathML) in the trivial web page
// ==UserScript==
// @name mathjax for douban
// @namespace jiangzuoyan@gmail.com
// @author Changsheng Jiang<jiangzuoyan@gmail.com> // 感谢原作者,并且我把math_jax_src改回原来的mathjax.org了
// @include http://*.douban.com/*
// @description texify formula using mathjax
// @date 2011-07-12
// @version 20110712
// ==/UserScript==
@t1anchen
t1anchen / GetLines.scala
Created November 21, 2013 16:29
jar package manually
import scala.collection.mutable.BitSet
import scala.collection.mutable.Map
// Don't learn this code!
// Ugly implementation!
object GetLines {
def main(args: Array[String]) {
if (args.length < 1) {
println("Please specify the file to count")
return
@t1anchen
t1anchen / gist:7305345
Created November 4, 2013 16:37
factorial
;; Take k-th product while n!(n-1)!...(n-k+1)!...2!1!
;;
(map (fn [x] (reduce * x)) (take 10 (iterate rest (range 10 0 -1))))
;; (3628800 362880 40320 5040 720 120 24 6 2 1)
(reduce *' (map (fn [x] (reduce *' x)) (take 10 (iterate rest (range 10 0 -1)))))
;; 6658606584104736522240000000N