Skip to content

Instantly share code, notes, and snippets.

View ecnelises's full-sized avatar

Qiu Chaofan ecnelises

View GitHub Profile
@ecnelises
ecnelises / mastodon_job
Last active April 24, 2022 15:06
FreeBSD rc scripts for typical mastodon instances
#!/bin/sh
# PROVIDE: mastodon_job
# REQUIRE: postgresql networking
. /etc/rc.subr
name="mastodon_job"
rcvar="mastodon_job_enable"
mastodon_job_user="mastodon" # Your user to run the instance
@ecnelises
ecnelises / v2ex-darkify.css
Created April 13, 2022 11:21
Make your V2EX support system light/dark mode automatically
.item_hot_topic_title {
text-shadow: none;
}
@media (prefers-color-scheme: light) {
#Wrapper {
background-color: #e2e2e2;
}
@ecnelises
ecnelises / test_snan_rint.cc
Created February 13, 2020 09:27
Test rint impact for sNaN and qNaNs
#include <cstdio>
#include <cmath>
#include <limits>
#include <ctime>
#define __STDC_WANT_IEC_60559_BFP_EXT__
using namespace std;
double qnan, snan, result;
@ecnelises
ecnelises / subscriptions.opml
Last active November 9, 2021 02:06
My subscriptions of RSS
<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
<head>
<title>My Subscriptions</title>
</head>
<body>
<outline title="Normal" text="Normal">
<outline htmlUrl="https://www.schneier.com/blog/" text="Schneier on Security" title="Schneier on Security" type="rss" xmlUrl="https://www.schneier.com/blog/atom.xml" />
<outline text="MacRumors: Mac News and Rumors - All Stories" type="rss" htmlUrl="https://www.macrumors.com" xmlUrl="http://feeds.macrumors.com/MacRumors-All" title="MacRumors: Mac News and Rumors - All Stories" />
<outline htmlUrl="http://www.zenlife.tk" title="Arthur的博客" text="Arthur的博客" xmlUrl="http://www.zenlife.tk/feed.atom" type="rss" />
@ecnelises
ecnelises / StrangeLinkedListForInt.cc
Created October 10, 2018 05:25
一个可以用磁盘序列化的静态链表类
#include <iostream>
#include <vector>
#include <tuple>
#include <cstdio>
using namespace std;
// StrangeLinkedListForInt
// 一个可以用磁盘序列化的静态链表类
class StrangeLinkedListForInt {
@ecnelises
ecnelises / GSoC2018.md
Last active June 1, 2022 09:41
Summary of Google Summer of Code 2018, multi-factor authentication of RubyGems

Google Summer of Code 2018 - Adding multi-factor authentication to RubyGems

My project of the Google Summer of Code 2018 is adding multi-factor (or so-called two-factor) authentication to gem, the default shipped package management tool of Ruby, and RubyGems.org, the site hosting gems.

Project description

Item Content
Project Adding multi-factor authentication to RubyGems
Organization Ruby
@ecnelises
ecnelises / select.html
Last active May 29, 2021 15:59
A styled select implementation. See https://var.ecnelises.com/select.html
<!DOCTYPE HTML>
<html>
<head>
<title>Select</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, minimal-ui, initial-scale=1.0" />
<style>
body {
font-family: avenir, "helvetica neue", sans-serif;
@ecnelises
ecnelises / yinyang.rb
Created November 24, 2017 16:43
Ruby 版本的阴阳谜题
# 所谓阴阳谜题,即是写一个递归的程序,无休止地输出 @*@**@***... 这样的字符串
# 当然,这里的要求是不能用到常规的数字加减,而是要通过程序的控制流来反映
# 由于 Scheme 语言中存在 call/cc 这个方法,实现阴阳谜题特别方便
# Ruby 其实也是有 call/cc 的,不过现在属于 deprecated 的状态
# 这里用基本的递归实现
# 由于没有显式的 call/cc,这里得把程序写成 CPS 的形式
callcc_cps = -> (f, cont) {
f.(cont)
}
@ecnelises
ecnelises / combinator_json.rb
Created December 12, 2016 06:44
用Parser Combinator写成的JSON解析器
class Parser
def initialize(&p)
@proc = p
end
def call(str)
@proc.call(str)
end
def | (another)
@ecnelises
ecnelises / Either.hpp
Last active November 23, 2016 17:12
C++ Either类的简易实现
#ifndef EITHER_HPP
#define EITHER_HPP
#include <type_traits>
template<typename T1, typename T2>
struct MaxTypeSizeHelper {
const static auto size = (sizeof(T1) > sizeof(T2)) ? sizeof(T1) : sizeof(T2);
};