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
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 '*'
# -*- 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代表单独两次粘贴)
# 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 */
<?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';
@Zenuncl
Zenuncl / gist:6590194
Created September 17, 2013 04:53
Error install puppet
Selecting previously unselected package pe-ruby-shadow.
Unpacking pe-ruby-shadow (from .../pe-ruby-shadow_2.2.0-1puppet3_amd64.deb) ...
Selecting previously unselected package pe-puppet.
Unpacking pe-puppet (from .../pe-puppet_3.2.4.pe1-1puppet1_all.deb) ...
Selecting previously unselected package pe-rubygem-guid.
Unpacking pe-rubygem-guid (from .../pe-rubygem-guid_0.1.1-1puppet2_all.deb) ...
Selecting previously unselected package pe-rubygem-builder.
Unpacking pe-rubygem-builder (from .../pe-rubygem-builder_3.0.0-1puppet2_all.deb) ...
Selecting previously unselected package pe-rubygem-excon.
Unpacking pe-rubygem-excon (from .../pe-rubygem-excon_0.14.1-1puppet2_all.deb) ...
@Zenuncl
Zenuncl / Changeling2
Last active December 27, 2015 23:48
changeling
from WordLookup import lookup
# This is a helper function which converts a word string into a list with each letter as an element
def wordToList(word):
i=0
a=[]
while i < len(word):
a.append(word[i])
i+=1
return a
import WordLookup
def changeling(initial,goal,steps):
first=initial
last=goal
### The Word Check Function Part ###
if WordLookup.lookup(initial) == False or WordLookup.lookup(goal) == False:
return "Not in the List"
@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
@Zenuncl
Zenuncl / Logcat
Created March 6, 2014 05:10
Android LogCat
03-06 00:07:53.227: D/dalvikvm(904): GC_FOR_ALLOC freed 230K, 13% free 2748K/3140K, paused 34ms, total 37ms
03-06 00:07:53.227: I/dalvikvm-heap(904): Grow heap (frag case) to 3.445MB for 635812-byte allocation
03-06 00:07:53.347: D/dalvikvm(904): GC_FOR_ALLOC freed 4K, 11% free 3364K/3764K, paused 116ms, total 116ms
03-06 00:07:53.387: D/dalvikvm(904): GC_FOR_ALLOC freed <1K, 11% free 3364K/3764K, paused 32ms, total 33ms
03-06 00:07:53.387: I/dalvikvm-heap(904): Grow heap (frag case) to 3.917MB for 500416-byte allocation
03-06 00:07:53.509: D/dalvikvm(904): GC_FOR_ALLOC freed <1K, 10% free 3852K/4256K, paused 109ms, total 109ms
03-06 00:07:53.606: E/SQLiteLog(904): (1) near "tabletasksdatabase": syntax error
03-06 00:07:53.616: D/AndroidRuntime(904): Shutting down VM
03-06 00:07:53.616: W/dalvikvm(904): threadid=1: thread exiting with uncaught exception (group=0x41465700)
03-06 00:07:53.638: E/AndroidRuntime(904): FATAL EXCEPTION: main