Skip to content

Instantly share code, notes, and snippets.

View ngn999's full-sized avatar
💭
I may be slow to respond.

ngn999 ngn999

💭
I may be slow to respond.
View GitHub Profile
@ngn999
ngn999 / test.markdown
Created December 12, 2012 14:20
test syntax hight
(mapcar* (lambda (x) (* x x)) '( 1 2 3 4))
[1,2,3,4,5].colllect {|x| x*x}

def double (x)
  x * 2
end
@ngn999
ngn999 / gist:4490333
Last active December 10, 2015 20:48
mptut exercise 11

贴到这里看效果

pair m,end;
m = 1/2[(dir 145)*2cm, (0,0)];
end = (dir 105)*0.85cm + m;
draw (dir 145)*2cm -- (0,0);
draw m -- end;
draw m withpen pencircle scaled 2;

paste this code to here

u = 1cm;
pair a,b,o,c,d;

a := (0,2)*u;
b := (0,1)*u;
o := (0,0)*u;
c := (0,-1)*u;

numeric u; % 声明和定义不能同时

u := 2cm;
pair o,a,b;

o := (0,0)*u;
a := (1,0)*u;

draw o -- (1,0)*u;
pair a,b,c;
numeric u;
u:=2cm;
a:=(0,0)*u;
b:=(1,0)*u;
c:=(0.5,0.8)*u;

draw a{up} .. c;
draw a{right} .. c;
numeric xmax,ymax,xmin,ymin;
xmax := 4;
ymax := 2;
xmin := 0;
ymin := 0;

numeric ux,uy;
ux := 1cm;
uy := 1cm;

在两pair的中点,画一个红色的叉

u:=1cm;
pair a,b;
a := (3,4)*u;
b := (0.5,0)*u;

draw a--b;
@ngn999
ngn999 / boxjoin.md
Created January 13, 2013 17:27
boxjoin 的用法
beginfig(250)
  boxjoin(a.se = b.sw; a.ne = b.nw);
  boxit.a1(btex a etex);
  boxit.a2(btex b etex);
  boxit.a3(btex c etex);
  boxit.a4(btex d etex);
  drawboxed(a1,a2,a3,a4);
endfig;
(defun add-py-header ()
"check and add # -*- coding: utf-8 -*-"
(interactive)
(let ((pyheader "# -*- coding: utf-8 -*-"))
(if (not (equal pyheader (buffer-substring-no-properties 1 (1+ (length pyheader)))))
(progn (goto-char 1)
(insert (concat pyheader "\n\n"))))))
@ngn999
ngn999 / zhoubao.md
Last active December 15, 2015 07:19
周报模板
定义一个 markdown-mode下的 snippet
<pre>
# -*- mode: snippet -*-
# name: zhoubao
# key: zhoubao
# binding: C-c C-n
# --
## ${1:#你的名字#}周报
`(concat "__" (yesterday-is 1) " ~ " (tommorow-is 5) "__")`