Skip to content

Instantly share code, notes, and snippets.

View notcome's full-sized avatar

Minsheng Liu notcome

View GitHub Profile
#C++ 吧的吧友看过来
头疼如何共享代码嘛?来使用 Github 的 Gist 吧……
首先你需要一个 Github 的账号,不知道何为 Github 的现在就去搜索,这太可怕了。嗯嗯!
然后访问 gist dot github dot com,按照指示去做就可以了。方便吧……
最后记着防度娘抽风哦!
@notcome
notcome / ChronoClockToUTC
Created July 8, 2014 07:31
Convert std::chrono::system_clock::time_point to std::tm
#include <iostream>
#include <ratio>
#include <chrono>
#include <string>
template <typename value_type>
struct timed {
std::chrono::time_point<std::chrono::steady_clock> timestamp;
value_type value;
@notcome
notcome / LRU.v1
Last active August 29, 2015 14:04
class LRUElement {
constructor (data, master, index) {
this.data = data;
this.master = master;
this.index = index;
this.lastAccess = new Date();
}
get value () {
return this.data;
@notcome
notcome / kvo.js
Created October 2, 2014 13:10
KVO and Binding for JavaScript
function initWatchProperty (obj, key) {
if (obj['$$watchers$$' + key])
return;
Object.defineProperty(obj, key, {
get: function () {
return this['$$' + key];
},
set: function (val) {
var old = this['$$' + key];
@notcome
notcome / gist:a94e6c0c95cff41c8a10
Created October 21, 2014 00:52
Simplest way to implement parental control in Qujing.
var http = require('http');
var server = http.createServer(onRequest);
function onRequest (req, res) {
res.writeHead(403, 'You are forbidden to visit this page due to Qujing\'s parental control.');
res.write('You are forbidden to visit this page due to Qujing\'s parental control.');
res.end();
}
@notcome
notcome / inline-phrases.html
Created October 30, 2014 13:58
several IOL.cn problem page prototypes
<style>
ul, li { padding: 0; margin: 0; }
ul { width: 400px; }
li {
display: inline;
font-family: "Charis SIL";
font-style: italic;
}
@notcome
notcome / initGuard.js
Created December 9, 2014 04:33
ensure that the function's first invocation will be exclusive
var fs = require('fs');
function guardInit (init) {
var delayedCalls = [];
var status = 'not initialized';
return function () {
if (status == 'initializing')
return delayedCalls.push(arguments);
if (status == 'initialized')
@notcome
notcome / gist:52658490bc4bb2f4ad37
Created February 6, 2015 13:12
Hyphenating English Within Chinese Articles is Possible.
<html lang="cmn-Hans-CN">
<head>
<style type="text/css">
#block {
width: 10em;
margin-left: 5em;
text-align: justify;
-webkit-hyphens: auto;
}
i {
@notcome
notcome / canvas-compress
Created February 11, 2015 20:52
Compress selected images using canvas
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#picture-select {
display: block;
}
#canvas {
@notcome
notcome / WillBeBack
Created February 12, 2015 12:30
I will be back after bbq is done
{-# LANGUAGE DeriveDataTypeable, TemplateHaskell, TypeFamilies, FlexibleInstances, FlexibleContexts, InstanceSigs #-}
module Data.VCodePool where
import Data.Data (Data, Typeable)
import Data.SafeCopy (base, deriveSafeCopy, SafeCopy(..))
import Control.Applicative ((<$>), (<*>))
import Control.Monad.Reader (ask)
import Control.Monad.State (get, put)