Skip to content

Instantly share code, notes, and snippets.

View acgrid's full-sized avatar

acgrid

  • Suzhou
View GitHub Profile
@acgrid
acgrid / gist:2062c2495aeb5116aa3d
Created June 20, 2014 08:32
Unsuccessful XHR Library on OGG over HTTP Live Stream
// vim: set et sw=2 ts=2 sts=2 ff=unix fenc=utf8:
// Author: Binux<i@binux.me>
// http://binux.me
// acgrid<acgrid@gmail.com>
// Created on 2013-04-20 20:17:45
define(['underscore', 'utils', 'jquery'], function(__,utils,$) {
return {
choice_piece_size: function() {
@acgrid
acgrid / gist:4b435b736493dc38b51f
Created February 3, 2015 13:57
Pratical Vim 整理

Pratical Vim 整理

本文档内容基于Drew Neil著作Pratical Vim中译本整理。

模式(Mode)

普通模式(Normal mode)

  • 能够前往其他任一Vim模式
  • 字符命令形式:[{count}=1]{operator},对光标下起的count个字符执行操作并后移光标。
  • 动作命令形式:[{count}=1]{operator}{motion},表示执行operator操作,作用于当前光标+motion指定的范围,并执行count次。
  • 行命令形式:对于动作命令,{operator}{operator}表示将该操作作用于当前行;guugUU是作用于当前行的简化版。
  • 操作符和动作命令均可以自定义,也可与已有的操作符和动作命令组合使用。
<!DOCTYPE html>
<html lang="zh-cn" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SHIFTJIS</title></head>
<body>
<p><?php
if(isset($_POST['subject'])){
$s = $_POST['subject'];
if(!empty($s)){
@acgrid
acgrid / Storage.md
Last active March 16, 2018 05:39
Translated guides about docker

卷的建议用法

Docker容器和服务中持久化数据的最佳方案。用例包括:

  • 多个运行中的容器间共享数据。不手动建立时,卷会在首次挂载到容器时创建。卷不因容器停止或移除被删除。多个容器能同时挂载同一个容器,并可设定只读/读写。卷只会被手动明确删除。
  • Docker主机不一定有确定的目录文件结构时,卷有助于将容器运行环境与Docker主机配置解耦。
  • 需要将容器数据储存在远程主机或云服务上,而不仅仅存在本地。
  • 需要在Docker主机间备份、还原、迁移数据的话是更好的选择。可在停止使用该卷的容器后,备份卷所在的目录(例如/var/lib/docker/volumes/<卷名>)

绑定挂载的建议用法

一般来说尽量用卷。绑定挂载适用于下列用例:

  • 容器共享主机的配置文件。Docker默认为容器提供DNS解析就是用挂载主机文件/etc/resolv.conf到各个容器实现的。
@acgrid
acgrid / capture.js
Created May 24, 2018 15:47
Get screenshot for every page generated by pdf2html using phantomjs
"use strict";
var page = require('webpage').create();
var system = require('system');
if (system.args.length !== 2) {
system.stderr.writeLine('Put target URL as argument');
} else {
var url = system.args[1];
}
page.viewportSize = { width: 1080, height: 1920 };
page.open(url, function (status) {
@acgrid
acgrid / Extract pyinstaller.md
Last active May 26, 2018 09:07
Everything about extract pyinstaller-ed exe files

Checkpoints

  • Put pyinstxtractor.py to somewhere included in PATH by cloning python-exe-unpacker or just downloading
  • Clone python-uncompyle6, patch it if on Windows, install
  • Also put pycize.py and depyinstaller.cmd along with pyinstxtractor.py
  • depyinstaller foo.exe and get source
  • If foo is not the real entry name, try to find the real name among the extracted folder, then do the rest

Tools needed

@acgrid
acgrid / migrate-yarn-to-cnpm.js
Created February 13, 2020 12:08
Migrate yarnpkg to npm.taobao.org (seems yarn2 will resolve this problem)
const fs = require('fs')
fs.readFile('yarn.lock', { encoding: 'utf8' }, (err, data) => {
if (err) {
console.error(err)
process.exit(1)
} else {
fs.writeFileSync('yarn.lock', data.replace(/"https:\/\/registry\.yarnpkg\.com\/.+"/g, url => {
url = url.replace('registry.yarnpkg.com', 'registry.npm.taobao.org')
if (url.includes('/-/')) {
const match = url.match(/\/@[^/]+\//)