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 / Gruntfile.coffee
Created March 1, 2013 16:17
Gruntfile.coffee
module.exports = (grunt) ->
'use strict'
grunt.initConfig
coffee:
debug:
files: [
expand: true
cwd: 'js'
src: ['**/*.coffee', '!**/_*.coffee']
#!/usr/bin/env coffee
fs = require 'fs'
Path = require 'path'
NUM_BACKUPS = 22
SPEED = 1.4
Array::last = -> @[@length-1]
Array::min = -> @reduce (x, y) -> if x < y then x else y
@MaskRay
MaskRay / a.cc
Created March 10, 2013 09:38
Simplifying boolean algebra 數字邏輯電路作業
#include <limits.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
const int N = 10, MAX = 1 << N;
int L[MAX], R[MAX], U[MAX], D[MAX], S[MAX];
int n, cur, opt0, opt1, opt[1 << N], now[1 << N];
string name[MAX];
@MaskRay
MaskRay / a.rb
Last active December 14, 2015 19:09
數據分析
#!/usr/bin/env ruby
#encoding: utf-8
require 'json'
all = []
open('/tmp/o').read.lines.each do |l|
all << JSON.parse(l)
end
@MaskRay
MaskRay / Makefile
Created April 21, 2013 14:52
人工智能大作業Linux開發環境(開箱即用)
.SUFFIXES:
.PHONY: all dist clean release wine
#CXXFLAGS += -Wextra -I. -O2
#CXXFLAGS += -Wextra -I. -g -fno-default-inline
CXXFLAGS += -Wextra -I. -g
MINGW := /opt/mingw/bin/i686-w64-mingw32-g++
DIST_SRC := *.cc *.h *.cpp --exclude Main.cpp
RELEASE_SRC := $(DIST_SRC) win/a.dll
@MaskRay
MaskRay / scoreboard-delta.html
Last active December 20, 2015 14:49
defcon ctf 21 scoreboard (partial)
<p align= center >
<table cellspacing=0 border=1>
<caption align=bottom class=captiondataframe></caption>
<tr><td>
<table border=0 class=dataframe>
<tbody>
<tr class= firstline >
<th>&nbsp; </th>
<th>a[-nrow(a), 1] </th>
@MaskRay
MaskRay / pj.js
Last active December 31, 2015 00:29
評教
cpzb = centerFrame.cpzbframe
function f() {
as = [].slice.apply(centerFrame.xspjcpkd.document.querySelectorAll('a')).filter(function(e){return !(s=e.nextSibling)||!s.textContent.match(/已提交/)})
if (as.length) as[0].click()
}
cpzb.frameElement.onload = function() {
w = this.contentWindow
if (w.document.querySelector('.copyright_zi_yellow'))
@MaskRay
MaskRay / lyndon-word.cc
Created February 4, 2014 13:16
Lyndon word or lexicographically minimal string rotation
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 1213;
char a[N+1];
// n > 0
int lyndon_word(const char *a, int n)
{
@MaskRay
MaskRay / biconnected.cc
Created February 5, 2014 10:21
2-vertex-connected component & 2-edge-connected component
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (decltype(b) i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
const int N = 1213;
int timestamp, dfn[N];
@MaskRay
MaskRay / README.md
Last active August 29, 2015 13:59
ucore-lab填寫已有實驗

7a2c9a代表:

commit 7a2c9aac470b451894de3042d10d45b9202f2749
Author: Junjie Mao <[email protected]>
Date:   Tue Mar 18 08:30:09 2014 +0800

    Replace POSIX incompatible usages of expr with sh-compatible string operators
    
    This should solve the issue reported at
 https://piazza.com/class/hrw6f9rv9q077k?cid=38