Skip to content

Instantly share code, notes, and snippets.

View jdh8's full-sized avatar
🐱
Kocham cię wyderko

Chen-Pang He jdh8

🐱
Kocham cię wyderko
View GitHub Profile
@jdh8
jdh8 / miller-rabin.c
Created June 29, 2014 06:43
Primality test
/* Primality test.
*
* Copyright (C) 2013 Chen-Pang He <jdh8@ms63.hinet.net>
* Don’t copy-paste the email. It won’t work.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
@jdh8
jdh8 / prime.c
Created June 29, 2014 06:54
Generate the first n prime numbers
/* Generate the first n prime numbers.
*
* Copyright (C) 2013 Chen-Pang He <jdh8@ms63.hinet.net>
* Don’t copy-paste the email. It won’t work.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
@jdh8
jdh8 / analytic.mac
Last active June 8, 2016 18:55
Wave packet generator
load("fft");
g(x):= exp(-x^2 /2) / sqrt(2 * %pi);
plot(n, k):= plot2d(['discrete, realpart(fft(makelist(g(i-k+n) + g(i-k) + g(i-k-n), i, 0, n-1))) * n], ['x, 1, n]);
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2016 Chen-Pang He <chen.pang.he@jdh8.org>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef EIGEN_MATRIX_SIGN_ITERATION
#include <ios>
#include <string>
#include <unistd.h>
template<bool>
class FileDescriptor
{
private:
int _fd;
@jdh8
jdh8 / tchisla.cpp
Last active August 8, 2016 13:00
Solve Tchisla with bottom-up dynamic programming
// This gist is no longer maintained.
// Please move to [jdh8/chic][chic].
//
// [chic]: https://github.com/jdh8/chic
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdint>
@jdh8
jdh8 / Convolution.cpp
Last active August 15, 2016 19:06
Snippet for convolution filter
template<int>
struct image_filter_vector;
template<>
struct image_filter_vector<ColMajor, DirectAccessBit>
{
template<typename Lhs, typename Rhs, typename Destination>
static void run(const Lhs&, const Rhs&, Destination&);
};
@jdh8
jdh8 / Operators.cpp
Created August 31, 2016 08:37
Barton–Nackman trick
template<typename T>
class Comparable
{
friend bool operator!=(const T& x, const T& y) { return !(x == y); }
friend bool operator>(const T& x, const T& y) { return y < x; }
friend bool operator<=(const T& x, const T& y) { return !(y < x); }
friend bool operator>=(const T& x, const T& y) { return !(x < y); }
};
template<typename T>
@jdh8
jdh8 / wbr5.html
Last active December 27, 2016 09:01
<!DOCTYPE html>
<html lang="zh-TW" class="no-js">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<title>我方開叫一線花色</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Merriweather:,i,b,bi%7CMontserrat:,b">
<link rel='stylesheet' href='https://jdh8.org/wp-content/themes/twentysixteen/style.css?ver=4.6.1'>
<link rel="stylesheet" href="https://jdh8.github.io/css/wordpress.css">
@jdh8
jdh8 / default.diff
Created February 26, 2017 17:45
Translate default.liquid from English to Chinese. -- https://github.com/jdh8/sweet-16/blob/master/_layouts/default.liquid
diff --git a/_layouts/default.liquid b/_layouts/default.liquid
index 2aab8d0..998ad36 100644
--- a/_layouts/default.liquid
+++ b/_layouts/default.liquid
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="en">
+<html lang="zh-Hant">
<head>
<meta charset="UTF-8">