Skip to content

Instantly share code, notes, and snippets.

View mytharcher's full-sized avatar
🏠
Working from home

Junyi mytharcher

🏠
Working from home
View GitHub Profile
@mytharcher
mytharcher / README.md
Last active April 26, 2024 08:04
Grammar Descriptions in PEG.js

Elimination of left recursion

C -> D o D
D -> C
D -> t

D -> D o D
D -> t
@mytharcher
mytharcher / main.js
Last active December 21, 2023 12:57
Download pasted images for md from Github
const fs = require('node:fs');
const fsPromise = require('node:fs/promises');
const { https } = require('follow-redirects');
const { glob } = require('glob');
async function download(url, toFile) {
const file = fs.createWriteStream(toFile);
await new Promise((resovle, reject) => {
console.log('downloading file:', url);
@mytharcher
mytharcher / compressor.rb
Last active May 10, 2022 01:56
A jekyll plugin for compressing HTML, JavaScript files when rendering.
#
# File compressor plugin for jekyll
# =================================
#
# By [mytharcher](https://github.com/mytharcher)
# 2012-05-20
#
# Updated by [nicoespeon](https://github.com/nicoespeon)
# 2013-04-12
#
@mytharcher
mytharcher / authorization.js
Created November 7, 2012 15:16
A demo testing HTTP 401 authorization on node.js
var approot = process.env.PWD;
var db = require(approot + '/lib/db');
var encrypt = require(approot + '/lib/encrypt');
exports = module.exports = function (req, res, next) {
console.log('processing authorization...');
var session = req.session;
@mytharcher
mytharcher / .htaccess
Last active March 3, 2021 00:30
Used for automated deploy web site code from Bitbucket to Dreamhost test site via git POST hook.
# This config is used for Dreamhost which HTTP basic authoriztion is forbidden.
# The PHP Server variable 'PHP_AUTH_USER' & 'PHP_AUTH_PW' could be implement by
# this config via a CGI environment variable.
# From [HTTP Authentication on PHP as CGI (like Dreamhost)](http://planetozh.com/blog/2009/04/http-authentication-on-php-as-cgi-like-dreamhost/)
RewriteEngine on
RewriteRule ^git-hook.*\.php - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
@mytharcher
mytharcher / generateCombinationsFromLists.js
Created September 17, 2019 07:40
计算任意多个维度有限元素生成的所有向量组合
const lists = [
[1, 2],
[3, 4],
[5],
[7]
];
const combinations = lists
.reduce((all, current) => current
.map(item => all.map(g => g.concat([item])))
@mytharcher
mytharcher / .env
Last active July 9, 2018 13:28
Royal Mail API test
ROYAL_MAIL_API_CLIENT_ID=
ROYAL_MAIL_API_CLIENT_SECRET=
ROYAL_MAIL_API_APP_ID=
ROYAL_MAIL_API_USER_ID=
ROYAL_MAIL_API_PASSWORD=
@mytharcher
mytharcher / package.json
Last active December 4, 2017 09:32
Really simple and useful practice for React project
{
"scripts": {
"dev": "webpack-dev-server --port 3000 --hot --inline --history-api-fallback --colors --progress",
"build": "NODE_ENV=production webpack -p --optimize-occurence-order --optimize-dedupe --output-public-path 'http://cdn.domain.com/assets/[hash]/'",
"release": "npm run build && bin/deploy"
},
"dependencies": {
"axios": "0.12.0",
"classnames": "2.2.5",
"qrcode.react": "0.6.1",
@mytharcher
mytharcher / index.html
Created August 10, 2016 13:18
overwatch loading by css3 BY CCG
<div class="loader">
<ul class="hexagon-container">
<li class="hexagon hex_1"></li>
<li class="hexagon hex_2"></li>
<li class="hexagon hex_3"></li>
<li class="hexagon hex_4"></li>
<li class="hexagon hex_5"></li>
<li class="hexagon hex_6"></li>
<li class="hexagon hex_7"></li>
</ul>
{
"en_US": {"dir": "ltr", "name": "English"},
"de": {"dir": "ltr", "name": "Deutsch"},
"fr_FR": {"dir": "ltr", "name": "français (France)"},
"fr_CA": {"dir": "ltr", "name": "français (Canada)"},
"ca": {"dir": "ltr", "name": "català"},
"pt_BR": {"dir": "ltr", "name": "português"},
"fa_IR": {"dir": "rtl", "name": "پارسی"},
"zh_CN": {"dir": "ltr", "name": "中文"},
"nl": {"dir": "ltr", "name": "Nederlands"},