Skip to content

Instantly share code, notes, and snippets.

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

Z. Jiang Zenuncl

🏠
Working from home
View GitHub Profile
@Zenuncl
Zenuncl / firewall.sh
Created December 10, 2013 23:00 — forked from x1a0/firewall.sh
#! /bin/bash
# Set the default policies to allow everything while we set up new rules.
# Prevents cutting yourself off when running from remote SSH.
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# Flush any existing rules, leaving just the defaults
iptables -F
<?php
if (isset($_GET['url'])) {
$url = rawurldecode(trim($_GET['url']));
if (empty($url))
return;
if (substr($url, 0, 4) != 'http')
$url = "http://{$url}";
require_once 'PHPWebDriver/__init__.php';
# 1. Make sure you have nginx sub module compiled in
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module'
# 2. add two directives below at HTTP level
# nginx.conf
http {
# ......
sub_filter '</head>' '<style type="text/css">html{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
# -*- coding: utf-8 -*
#########################################################################
#假设类似CTRL + A这样的组合按键算一次
#实现思路:
#首先开始直接输出A的个数必须为3,4,5中的一个,因为1和2对其做复制得不偿失,而6的时候已经相当于3个A作一次复制
#(在测试时发现使M最大的情况中直接输出5个A的情况没有出现过,但是没有找到什么理由不去考虑5个A,也许N足够大会用到5?)
#其次,输出A后需要紧接着作一次“全选复制粘贴”
#第三,再往后需要“全选复制粘贴”和单独“粘贴”做任意顺序组合,找出实现最大化的情况
#ps:这个程序在跑到N = 38的时候我的笔记本就很吃力了,所以只测试了38以下
#ps:发现规律:按键基本形式为4A(or 3A) 3 2 3 2 3 2 。。。(4A代表直接输出4个A,3代表全选复制粘贴,2代表单独两次粘贴)
git_inspect_branch() {
git branch 2> /dev/null | grep ^* | sed 's/^\* \(.*\)$/:\1/g'
}
git_inspect_added() {
[[ $(git status 2> /dev/null | grep 'Untracked files:') != '' ]] && echo '+'
}
git_inspect_modified() {
[[ $(git status 2> /dev/null | grep 'modified:') != '' ]] && echo '*'