This is a demo gist to test my gist viewer. The Javascript may not be written by me :D
This is a test for update.
# input: | |
# 1 1 | |
# 2 2 | |
# 3 3 | |
# 4 4 | |
# 5 5 | |
# 6 6 | |
# 7 7 | |
# output: | |
# 1 |
(defface collapsed-face '((t (:background "#e0cf9f" :foreground "#5f5f5f"))) "Collapsed Overlay") | |
(defvar collapsed-face 'collapsed-face) | |
(define-fringe-bitmap 'hs-marker [0 24 24 126 126 24 24 0]) | |
(defun display-code-line-counts (ov) | |
(when (eq 'code (overlay-get ov 'hs)) | |
(let* ((marker-string "*fringe-dummy*") | |
(marker-length (length marker-string)) | |
(display-string | |
(format " (%d)... " |
This is a demo gist to test my gist viewer. The Javascript may not be written by me :D
This is a test for update.
var svg = document.querySelector( "svg" ); | |
var svgData = new XMLSerializer().serializeToString( svg ); | |
var canvas = document.createElement( "canvas" ); | |
var ctx = canvas.getContext( "2d" ); | |
var img = document.createElement( "img" ); | |
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) ); | |
img.onload = function() { |
Simple analog clock.
WRAPPED implementation of Game of life. The project could be found in lifejs. The above pattern is known as Spaceship-Weekender.
A maze pattern is generated by Depth-First Search (DFS) algorithm. To create more interesting/skewed maze, the probability to search for each direction, i.e. top, right, down and left is randomized. As a result sometimes it's more likely to go upward, if available, than right. This generator could be found in mazejs.
CXX=g++ | |
EXE=main | |
FLG=-std=c++11 -O2 -Wall | |
all : $(EXE) | |
$(EXE) : main.cpp | |
$(CXX) $(FLG) -o $@ $< | |
clean : |
#include <algorithm> | |
#include <cstdio> | |
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
#include <map> | |
#include <queue> | |
#include <vector> | |
#include <utility> |
int kmp(const string &T, const string &P) { | |
if (P.empty()) return 0; | |
vector<int> pi(P.size(), 0); | |
for (int i = 1, k = 0; i < P.size(); ++i) { | |
while (k && P[k] != P[i]) k = pi[k - 1]; | |
if (P[k] == P[i]) ++k; | |
pi[i] = k; | |
} |