Skip to content

Instantly share code, notes, and snippets.

View tajpure's full-sized avatar
🎯
Focusing

Jiaxuan Tao tajpure

🎯
Focusing
View GitHub Profile
// 你的主题名
.dark {
background-color: #212121; // 背景颜色
color: white; // 字体颜色
}
@tajpure
tajpure / marked-katex.js
Created August 14, 2016 10:44
Support katex for marked.
const renderer = new marked.Renderer()
let originParagraph = renderer.paragraph.bind(renderer)
renderer.paragraph = (text) => {
const blockRegex = /\$\$[^\$]*\$\$/g
const inlineRegex = /\$[^\$]*\$/g
let blockExprArray = text.match(blockRegex)
let inlineExprArray = text.match(inlineRegex)
for (let i in blockExprArray) {
const expr = blockExprArray[i]
const result = renderMathsExpression(expr)
#! /bin/python
import os, math
import Image
import ImageDraw
def cut_circle(source, target):
image = Image.open(source).convert("RGBA")
size = image.size
r2 = min(size[0], size[1])
if size[0] != size[1]:
@tajpure
tajpure / rolling_checksum.js
Last active March 11, 2016 04:35
Rolling checksum
/*
* Rolling Checksum from
* http://www.cs.cmu.edu/~15-749/READINGS/required/cas/tridgell96.pdf
*
*/
'use strict';
module.exports = {
last: null,
checksum: function (data, isNotRolling) {
@tajpure
tajpure / Memoizer
Last active August 29, 2015 14:23
Memoizer
// The demo comes from <<JavaScript:The Good Parts>>.
var memoizer = function (memo, formula) {
var recur = function (n) {
var result = memo[n];
if (typeof result !== 'number') {
result = formula(recur, n);
memo[n] = result;
}
return result;
};
@tajpure
tajpure / index.rkt
Last active December 28, 2016 04:05
A Racket Blog
#lang web-server/insta
; A blog is a (listof post)
; and a post is a (post title body)
(struct post (title body))
; BLOG: blog
; The static blog.
(define BLOG
(list (post "Second Post" "This is anther post")