VBA自定义函数:求非零平均值

Dec 17, 2013 08:59:14 PM

 

Public Function aveifnot0(ParamArray canshu() As Variant) As Double
'本函数为求非零平均数,参数为零散的单元格,而非单元格区域。求连续的单元格区域的非零平均值可以使用
'Excel内置函数AVERAGEIF
'定义函数,数组参数需要用关键字ParamArray定义,类型也必须为Variant
    Dim sum As Double     '声明sum为double型数据类型,sum是要计算非零数的累计和
    Dim i, k As Integer   '声明i,k为单整形
    sum = 0               '给sum初始化为零
    k = 0                 '给k初始化为零,k是计算非零数的个数
    For i = LBound(canshu) To UBound(canshu)   '开始循环,LBound取数组的第一位,UBound取数组的最后一位
    If canshu(i).Value > 0 Then                '判断数组里某一个数的值是否大于零
        sum = sum + canshu(i).Value            '如果大于零,将其值累加
        k = k + 1                              '如果大于零,计数
    Else                                       '否则不执行任何事情
    End If                                     '结束条件判断
    Next i                                     '循环
    aveifnot0 = sum / k                        '循环完毕,返回非零平均值
End Function                                   '自定义函数结束

.bashrc ArchBang

Dec 08, 2012 11:13:51 PM

 

# Add nano as default editor
export EDITOR=nano
VBOX_USB=usbfs

# modified commands
alias diff='colordiff'              # requires colordiff package
alias grep='grep --color=auto'
alias more='less'
alias df='df -h'
alias du='du -c -h'
alias mkdir='mkdir -p -v'
alias nano='nano -w'
alias ping='ping -c 5'
alias ..='cd ..'

# new commands
alias da='date "+%A, %B %d, %Y [%T]"'
alias du1='du --max-depth=1'
alias hist='history | grep'      # requires an argument
alias openports='netstat --all --numeric --programs --inet --inet6'
alias pg='ps -Af | grep $1'         # requires an argument (note: /usr/bin/pg is installed by the util-linux package; maybe a different alias name should be used)

# privileged access
if [ $UID -ne 0 ]; then
    alias sudo='sudo '
    alias scat='sudo cat'
    alias svim='sudo vim'
    alias root='sudo su'
    alias reboot='sudo reboot'
    alias halt='sudo halt'
    alias update='sudo pacman -Su'
    alias netcfg='sudo netcfg2'
fi

# ls
alias ls='ls -hF --color=auto'
alias lr='ls -R'                    # recursive ls
alias ll='ls -l'
alias la='ll -A'
alias lx='ll -BX'                   # sort by extension
alias lz='ll -rS'                   # sort by size
alias lt='ll -rt'                   # sort by date
alias lm='la | more'

# safety features
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -I'                    # 'rm -i' prompts for every file
alias ln='ln -i'
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'

# pacman/yaourt aliases
alias pac="sudo /usr/bin/pacman -S"		# default action	- install one or more packages
alias paca="/usr/bin/yaourt -S"			# default yaourt action	- install one or more packages including AUR
alias pacu="/usr/bin/yaourt -Syua"		# '[u]pdate'		- upgrade all packages to their newest version
alias pacr="sudo /usr/bin/yaourt -Rs"		# '[r]emove'		- uninstall one or more packages
alias pacs="/usr/bin/pacman -Ss"		# '[s]earch'		- search for a package using one or more keywords
alias pacas="/usr/bin/yaourt -Ss"		# '[a]ur [s]earch'	- search for a package or a PKGBUILD using one or more keywords
alias paci="/usr/bin/yaourt -Si"		# '[i]nfo'		- show information about a package
alias paclo="/usr/bin/pacman -Qdt"		# '[l]ist [o]rphans'	- list all packages which are orphaned
alias pacc="sudo /usr/bin/pacman -Scc"		# '[c]lean cache'	- delete all not currently installed package files
alias paclf="/usr/bin/pacman -Ql"		# '[l]ist [f]iles'	- list all files installed by a given package
alias pacexpl="/usr/bin/yaourt -D --asexplicit"	# 'mark as [expl]icit'	- mark one or more packages as explicitly installed 
alias pacimpl="/usr/bin/yaourt -D --asdeps"	# 'mark as [impl]icit'	- mark one or more packages as non explicitly installed

# '[r]emove [o]rphans' - recursively remove ALL orphaned packages
alias pacro="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rs \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;$!ba;s/\n/ /g')"

[ ! "$UID" = "0" ] && archbey -c white
[  "$UID" = "0" ] && archbey -c green
#PS1="\[\e[01;31m\]┌─[\[\e[01;35m\u\e[01;31m\]]──[\[\e[00;37m\]${HOSTNAME%%.*}\[\e[01;32m\]]:\w$\[\e[01;31m\]\n\[\e[01;31m\]└──\[\e[01;36m\]>>\[\e[0m\]"

virtualbox

Dec 08, 2012 10:35:46 PM

安装virtualbox虚拟机软件及附加组件

yaourt -S virtualbox virtualbox-guest-iso

将当前的用户添加到 vboxusers 用户组中:

sudo gpasswd -a sandy vboxusers

添加usb访问权限

在~/.bashrc 里添加如下语句

VBOX_USB=usbfs

USB2.0需要 Oracle_VM_VirtualBox_Extension_Pack ,下载和virtualbox对应的版本

比如我的virtualbox版本是4.2.4,那就访问 http://download.virtualbox.org/virtualbox/4.2.4/ 下载  Oracle_VM_VirtualBox_Extension_Pack-4.2.4-81684.vbox-extpack

下载完后,打开virtualbox,选择 管理--全局设定--扩展,添加下载的   Oracle_VM_VirtualBox_Extension_Pack-4.2.4-81684.vbox-extpack ,按照提示输入密码安装即可。

重启电脑后使用virtualbox。

 

foobar2000 feq均衡器配置文件

Dec 08, 2012 02:30:06 AM

linux下的音乐播放器deadbeef可以使用foobar2000的feq均衡器配置文件

共享一下http://pan.baidu.com/share/link?shareid=156887&uk=302374367

迅雷离线助手+YAAW For Chrome+Aria2

Dec 08, 2012 01:08:31 AM

linux下下载资源解决方案终于找到了,需要是迅雷会员才可以使用离线下载功能。

安装 aria2和chrome or chromium

打开chrome or chromium,到商店安装 迅雷离线助手 https://chrome.google.com/webstore/detail/eehlmkfpnagoieibahhcghphdbjcdmen

进入迅雷离线界面,点设置,弹出对话框,在下面修改Aria2 JSON-RPC Path

http://127.0.0.1:6800/jsonrpc

YAAW For Chrome 

https://chrome.google.com/webstore/detail/hbjpfaalboebibgfmedmjijhbjapcnki

打开YAAW,点设置,修改Aria2 JSON-RPC Path  

http://127.0.0.1:6800/jsonrpc

手动下载ThunderLixianExporter脚本:    https://github.com/binux/ThunderLixianExporter

然后手动进浏览器扩展,拖动安装即可。

进入需要保存下载文件的目录,在此处打开终端,运行aria2c如下:

 

aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all --file-allocation=none --max-connection-per-server=3 --max-concurrent-downloads=3 --continue

 

启动Aria2后,直接在迅雷离线的『取回本地』的下拉菜单中找到『YAAW』,点击后,Aria2就开始下载资源了。
之后你就可以使用YAAW For Chrome监控下载进度咯。
记住,迅雷离线助手和YAAW For Chrome都是通JSON-RPC和Aria2通信的。
 

ubuntu 的.bashrc

Dec 07, 2012 01:12:21 PM

 

if [ -f /etc/bash_completion ]; then
   . /etc/bash_completion
fi

PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]"

alias aptu="sudo apt-fast update"
alias aptua="sudo apt-fast upgrade"
alias apts="sudo  apt-cache search"
alias apti="sudo apt-fast install"
alias aptr="sudo apt-fast remove"
alias aptac="sudo apt-fast autoclean"
alias aptar="sudo apt-fast autoremove"

# modified commands
alias diff='colordiff'              # requires colordiff package
alias grep='grep --color=auto'
alias more='less'
alias df='df -h'
alias du='du -c -h'
alias mkdir='mkdir -p -v'
alias nano='nano -w'
alias ping='ping -c 5'
alias ..='cd ..'

# new commands
alias da='date "+%A, %B %d, %Y [%T]"'
alias du1='du --max-depth=1'
alias hist='history | grep $1'      # requires an argument
alias openports='netstat --all --numeric --programs --inet --inet6'
alias pg='ps -Af | grep $1'         # requires an argument (note: /usr/bin/pg is installed by the util-linux package; maybe a different alias name should be used)

# ls
alias ls='ls -hF --color=auto'
alias lr='ls -R'                    # recursive ls
alias ll='ls -l'
alias la='ll -A'
alias lx='ll -BX'                   # sort by extension
alias lz='ll -rS'                   # sort by size
alias lt='ll -rt'                   # sort by date
alias lm='la | more'

# safety features
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -I'                    # 'rm -i' prompts for every file
alias ln='ln -i'
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'

Archlinux安装pdf虚拟打印机

Dec 04, 2012 02:22:37 AM

 

sudo pacman -S cups-pdf
sudo systemctl enable cups.service
or 
sudo systemctl start cups.service

用浏览器访问
http://localhost:631/

添加发现的pdf虚拟打印机-》打印机类型选Generic, Postscript Printer。依照指示走就ok。提示你输入帐号密码请输入root及root密码。

可以测试一下,和windows下的打印机不同的是它默认会把pdf文件输出到一个目录里。默认是

/var/spool/cups-pdf/$用户名/ ;可以自己修改配置文件/etc/cups/cups-pdf.conf 设置默认目录。
效果不错;

Arch64 Alsa Systemctl

Nov 24, 2012 03:05:18 AM

安装了archlinux64位,使用systemctl enable不了alsa,提示无install选项

手动链接服务

 

sudo ln -s /lib/systemd/system/alsa-store.service /etc/systemd/system/multi-user.target.wants/alsa-store@.service

sudo ln -s /lib/systemd/system/alsa-restore.service /etc/systemd/system/multi-user.target.wants/alsa-restore@.service

修改hosts,加快访问google

Nov 24, 2012 12:36:07 AM

#一般hosts文件在Windows下位于c:\windows\system32\drivers\etc\hosts。Linux下位于/etc/hosts

 

203.208.46.146 www.google.com
203.208.46.147 www.google.com.hk
203.208.46.132 clients1.google.com
203.208.46.149 mail.google.com
203.208.46.161 chatenabled.mail.google.com
203.208.46.161 mail-attachment.googleusercontent.com   
203.208.46.146 id.google.com
203.208.46.146 encrypted.google.com
203.208.46.161 encrypted-tbn0.google.com
203.208.46.162 encrypted-tbn1.google.com
203.208.46.163 encrypted-tbn2.google.com
203.208.46.164 encrypted-tbn3.google.com
203.208.46.132 webcache.googleusercontent.com 
203.208.46.191 ssl.gstatic.com
203.208.46.161 docs.google.com
203.208.46.157 0.docs.google.com
203.208.46.157 1.docs.google.com
74.125.39.99 chrome.google.com
74.125.39.99 clients2.google.com

如何编辑lxde右键菜单

Nov 03, 2012 02:44:24 PM

下了个压缩包,右键设置打开方式,第一次设置错了,但是这个方式却留在里 右键菜单里面;另外,安装里playonlinux,右键里出现了notepad,卸载playonlinux后,notepad菜单还在。请问如何编辑右键菜单呢?

 

找到了 
在 ~/.local/share/applications/文件夹下,删除不用的打开方式即可