Skip to content

Instantly share code, notes, and snippets.

View MaskRay's full-sized avatar
🏠
Working from home. Need food

Fangrui Song MaskRay

🏠
Working from home. Need food
View GitHub Profile
@MaskRay
MaskRay / pwner-service
Last active February 8, 2020 02:35
BCTF決賽統計
# pwn成功服務的次數
# cat states| jq -r '.pwns[] | .pwner as $p | .victim | "\($p)%\(.service)"' | sort | uniq -c | sort -n | grep -v NPC
1 我是狗汪汪%catftp
5 无名%catftp
10 Sigma%catftp
13 Pax.Mac Team%catftp
30 DISA%bluemine
50 DISA%catftp
54 Light4Freedom%catftp
@MaskRay
MaskRay / a.coffee
Last active August 29, 2015 14:03
Mark solved problems
###
// ==UserScript==
// @name 166.111.227.253
// @namespace https://github.com/MaskRay
// @version 0.0.1
// @description meow
// @include http://166.111.227.253/*
// ==/UserScript==
###
@MaskRay
MaskRay / a.js
Created July 14, 2014 16:27
LeetCode Downloader (client JavaScript)
// 在 console 裏執行即可
// Generated by LiveScript 1.2.0
(function(){
var down;
down = function(name){
var x$, xhr;
x$ = xhr = new XMLHttpRequest;
x$.responseType = 'document';
x$.onreadystatechange = function(){
var id, cpp, x$, a;
@MaskRay
MaskRay / a.cc
Created July 16, 2014 17:00
Autovivification in C++
#include <functional>
#include <cstdio>
#include <map>
using namespace std;
template<class T>
class A : public map<T, A<T> > {
public:
A() : x(T()) { }
A &operator[](size_t i) {
module type Base = sig
type ('x,'a) m
val unit : 'a -> ('x,'a) m
val bind : ('x,'a) m -> ('a -> ('x,'b) m) -> ('x,'b) m
end
module type BaseT = sig
module W : Base
type ('x,'a) m
val lift : ('x,'a) W.m -> ('x,'a) m
@MaskRay
MaskRay / boleyn-salary.ml
Created October 2, 2014 14:50
Boleyn Salary
let read_int _ = Scanf.bscanf Scanf.Scanning.stdib " %d" (fun x -> x)
let flip f x y = f y x
let euler_tour n es root =
let dfn1 = Array.make n 0
and dfn2 = Array.make n 0 in
let rec dfs i x =
dfn1.(x) <- i;
dfn2.(x) <- List.fold_left dfs (i+1) es.(x);
dfn2.(x)
(*
% WatLog test case: Insertion Sort
[lt-n: a, b].
[lt-n: b, c].
[lt-n: c, d].
[lt-n: d, e].
% transitive closure on lt-n relation
{([lt-n: #x, #y]) => [lt: #x, #y]}.
@MaskRay
MaskRay / a.rb
Last active August 29, 2015 14:07
重要通知、教务通知
#!/usr/bin/ruby
#encoding: utf-8
require 'open-uri'
require 'nokogiri'
require 'rss'
s = open('http://oars.tsinghua.edu.cn/zzh/30630.nsf/infobytime?openview').read
m = Nokogiri.parse(s).xpath('//script/text()')[0].text.match(/(?<= location\.replace\(")[^"]*(?=")/)
s = open("http://oars.tsinghua.edu.cn#{m[0]}").read
s = s.force_encoding('gbk').encode 'utf-8'
@MaskRay
MaskRay / regex-to-string-fp.ml
Created October 18, 2014 16:10
regex-to-string-fp
let is_lower c =
'a' <= c && c <= 'z'
type ast =
| Lit of char
| Star of ast
| Cat of ast*ast
| Or of ast*ast
module Parser = struct
module Str = struct
let implode l =
let s = Bytes.make (List.length l) ' ' in
List.iteri (fun i c -> Bytes.set s i c) l;
s
end
module LazyList = struct
type 'a node = Nil | Cons of 'a * 'a t
and 'a t = 'a node Lazy.t