易栈网-膘叔

浏览模式: 标准 | 列表 | 图文
转:Vagrant下共享目录静态文件(js/jpg/png等)“缓存”问题

转:Vagrant下共享目录静态文件(js/jpg/png等)“缓存”问题

转一篇Vargrant的相关文章【Vagrant下共享目录静态文件(js/jpg/png等)“缓存”问题】,原文来自:http://blog.smdcn.net/article/1325.html,主要是问题在于使用了sendfile可能会导致部会内容不会刷新。

原文如下:

之前提到说通过Vagrant部署开发环境,使用目录共享模式,在本地磁盘进行开发,而通过虚拟机环境运行开发的页面。

是的,一切看起来都是那么的顺利,首先基于VirtualBox安装了Vagrant,接下来,按照以往部署环境的习惯,在VM中安装了nginx作为开发运行环境,并且将本地的共享目录作为nginx的web目录,然后打开页面,看上去似乎都很正常,但接下来,你发现了一个神奇的事情,你修改替换了一个css,一张图片,然后刷新浏览器,发现什么都没有变,然后你有非常猛烈、使劲的F5,依旧还是没有改变,是的,你看看编辑器,似乎替换是正常的,在看看VM上的文件,也都是对的,是的,尝试重启nginx,依旧没有任何变化,你开始怀疑php5-fpm甚至于毫不相干的memcached和mysql,但都无济于事。也不知道是什么让这些文件被“缓存”了呢。

当你尝试修改一个js,并且用同样的方法更新之后,会遇到类似的问题,是的,就算重启VM上任何服务,甚至重启VM,依旧没有用,当然,比起其他资源文件,浏览器的反应会强烈一些,因为浏览器会提示未知错误,而你通过浏览器查看你修改的JS文件,会看到文件尾巴有下面奇怪的随机字符:

�����������������

这到底是什么东西呢?编码错误?缓存异常?又或是其他什么?

是的,你尝试花费很多时间,试验各种各样的方法去解决这个问题,其实对于nginx来说,你只需要修改配置文件(nginx.conf)中的一行重启就能简单的解决这个问题:

sendfile off;
找到 nginx.conf ,把里面的 “sendfile on” 修改为 “sendfile off”。

当然,如果你使用Apache也可能遇到类似的问题,那么同样也有类似的配置需要修改:

EnableSendfile off
关于这个问题的参照:
https://github.com/mitchellh/vagrant/issues/351#issuecomment-1339640

http://stackoverflow.com/questions/9479117/vagrant-virtualbox-apache2-strange-cache-behaviour

----转载完毕---

关于这个sendfile,还有人做了个测试:记vagrant nginx sendfile问题,然后居然没有人评论。。。

从今年开始,一直在vagrant虚拟机上做开发

因前段时间一个项目需要调试静态文件,出现静态文件修改后,浏览器刷新不生效。

最后追踪到是nginx开启了sendfile这一项。。

具体sendfile原理可以查下,,网上写的都很详细,这里就不复述了。

一开始一直认为是nginx某个地方配置有问题。。但后来干脆自己写下,做下测试

具体代码如下(tcp那几步连接这里就不写了。网上很多):


/**
* @connect tcp 连接句柄
*/
int sendClient(int connect)
{
int fd;
struct stat fileStat;
off_t offset = 0;
fd = open("/data/web/test.com/index.html", O_RDONLY|O_NONBLOCK);
if (fd < 0) {
perror("open file.");
return 0;
}
//获取文件信息
fstat(fd, &fileStat);
char buffer[fileStat.st_size];
// read(fd, buffer, fileStat.st_size);
//write(connect, buffer, fileStat.st_size);
sendfile(connect, fd, &offset, fileStat.st_size);
close(fd);
return 1;
}

至些我测了下,得到的还是不生效,由此可以断定,与nginx无关,与系统调度有关

至于问题,我现在的回答只能是vagrant的一个坑,具体是什么,我也无从得知,

当然, 这个我也是从表象猜测, 如果有人知道真正的原因, 还请不吝留言指教
升到osx EI后,brew不能使用的解决方法

升到osx EI后,brew不能使用的解决方法

升级osx 10.11后(即osx EI),brew在使用的时候就会直接报错了。因为从10.11开始,对几个重要目录的权限苹果有了新的限制,特别是/usr目录,所以官方有一个解决方法:https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md

内容很长,如果你是第一次使用brew 就看上面的内容吧,如果你已经使用过了brew(即是从旧机器 升级上来的),你可以来一句简单的办法:

sudo chown -R $(whoami):admin /usr/local

当然执行完后,你最好还是先用brew doctor检测一下,按照上面的提示一点点的操作,嗯,有些内容你就忽略吧,比如:

Warning: You are using OS X 10.11.
We do not provide support for this pre-release version.
You may encounter build failures or other breakage.

如果你有自己曾经创建的链接扔在/usr/local下面,你就不用理会这一句:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
make

最后还有一个重要的,如果你用的是brew 安装的PHP,你可能还要加上这么一句:

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile

因为brew 将PHP的fpm 软链接到了/usr/local/sbin目录下。所以需要将它加到$PATH里面,加完后运行一下source ~/.bash_profile即可

当然,如果这也不行那也不行,别忘了运行一下:xcode-select --install。

Over

哎呀,新版apple的授权,我该不该升级?

哎呀,新版apple的授权,我该不该升级?

看了一下苹果10.11系统的SLA(software license agreements),感觉心惊胆跳的,装了10.11,是不是意味着我以前的购买的软件都不能用了?还是说新版的操作系统,下载的软件我可以用于商业用途?

看这里:http://images.apple.com/legal/sla/docs/OSX1011.pdf

(文字不能COPY,好纠结)

好紧张,我该怎么办?

Linux Network Statistics Tools / Commands

Linux Network Statistics Tools / Commands

不想多说啥,直接上原文地址:http://www.cyberciti.biz/faq/network-statistics-tools-rhel-centos-debian-linux/

以下内容有部分经过我的重新排版,但由于fck编辑器中有些内容会自动被code处理,所以,如果太乱,我也不想改了
1.
Type the following command:
# nstat

Sample outputs:

#kernel
IpInReceives 133243 0.0
IpInDelivers 133243 0.0
IpOutRequests 92904 0.0
IcmpOutErrors 97 0.0
IcmpOutTimeExcds 97 0.0
IcmpMsgOutType3 97 0.0
TcpActiveOpens 538 0.0
TcpEstabResets 56 0.0
TcpInSegs 129837 0.0
TcpOutSegs 89720 0.0
TcpRetransSegs 42 0.0
TcpOutRsts 704 0.0
UdpInDatagrams 3255 0.0
UdpNoPorts 97 0.0
UdpOutDatagrams 3270 0.0
Ip6OutNoRoutes 206 0.0
TcpExtTW 141 0.0
TcpExtDelayedACKs 508 0.0
TcpExtDelayedACKLocked 1 0.0
TcpExtDelayedACKLost 42 0.0
TcpExtTCPHPHits 117659 0.0
TcpExtTCPPureAcks 2158 0.0
TcpExtTCPHPAcks 605 0.0
TcpExtTCPSackRecovery 1 0.0
TcpExtTCPLossUndo 16 0.0
TcpExtTCPSackFailures 4 0.0
TcpExtTCPFastRetrans 1 0.0
TcpExtTCPSlowStartRetrans 3 0.0
TcpExtTCPTimeouts 33 0.0
TcpExtTCPDSACKOldSent 40 0.0
TcpExtTCPDSACKRecv 5 0.0
TcpExtTCPAbortOnData 120 0.0
TcpExtTCPAbortOnClose 55 0.0
TcpExtTCPSackShiftFallback 9 0.0
IpExtInOctets 180131682 0.0
IpExtOutOctets 7289106 0.0
2.
To see summary of stats, enter:
# ss -s

Sample outputs:

Total: 786 (kernel 804)
TCP: 65 (estab 40, closed 7, orphaned 0, synrecv 0, timewait 6/0), ports 56
Transport Total IP IPv6
* 804 - -
RAW 1 1 0
UDP 12 9 3
TCP 58 52 6
INET 71 62 9
FRAG 0 0 0
See ss command tutorial for more information.
3.
To see a table of all network interfaces and its summary, enter:
# netstat -i

Sample outputs:

Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 941022 0 0 0 688165 0 0 0 BMRU
lo 16436 0 9304 0 0 0 9304 0 0 0 LRU
ppp0 1496 0 3784 0 0 0 4177 0 0 0 MOPRU
more...
To see summary statistics for each protocol, enter:
# netstat -s

Sample outputs:

Ip:
1092065 total packets received
0 forwarded
0 incoming packets discarded
1091681 incoming packets delivered
798913 requests sent out
895 dropped because of missing route
759 reassemblies required
375 packets reassembled ok
Icmp:
17 ICMP messages received
0 input ICMP message failed.
ICMP input histogram:
timeout in transit: 8
echo replies: 9
1747 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 1730
echo request: 17
IcmpMsg:
InType0: 9
InType11: 8
OutType3: 1730
OutType8: 17
Tcp:
4822 active connections openings
1129 passive connection openings
457 failed connection attempts
165 connection resets received
7 connections established
1062519 segments received
771394 segments send out
7158 segments retransmited
6 bad segments received.
2578 resets sent
Udp:
20846 packets received
1730 packets to unknown port received.
0 packet receive errors
19242 packets sent
UdpLite:
TcpExt:
71 invalid SYN cookies received
8 resets received for embryonic SYN_RECV sockets
142 packets pruned from receive queue because of socket buffer overrun
2109 TCP sockets finished time wait in fast timer
84 packets rejects in established connections because of timestamp
19454 delayed acks sent
6 delayed acks further delayed because of locked socket
Quick ack mode was activated 7306 times
1 packets directly queued to recvmsg prequeue.
1 bytes directly received in process context from prequeue
823921 packet headers predicted
24412 acknowledgments not containing data payload received
10150 predicted acknowledgments
242 times recovered from packet loss by selective acknowledgements
33 congestion windows recovered without slow start by DSACK
335 congestion windows recovered without slow start after partial ack
336 TCP data loss events
TCPLostRetransmit: 35
1 timeouts after reno fast retransmit
156 timeouts after SACK recovery
116 timeouts in loss state
461 fast retransmits
5 forward retransmits
608 retransmits in slow start
2073 other TCP timeouts
62 SACK retransmits failed
43074 packets collapsed in receive queue due to low socket buffer
8499 DSACKs sent for old packets
101 DSACKs sent for out of order packets
308 DSACKs received
9 DSACKs for out of order packets received
427 connections reset due to unexpected data
122 connections reset due to early user close
28 connections aborted due to timeout
TCPDSACKIgnoredOld: 3
TCPDSACKIgnoredNoUndo: 60
TCPSpuriousRTOs: 4
TCPSackShifted: 282
TCPSackMerged: 740
TCPSackShiftFallback: 1017
IpExt:
InMcastPkts: 47
OutMcastPkts: 51
InBcastPkts: 1
InOctets: 1341508973
OutOctets: 72525352
InMcastOctets: 8649
OutMcastOctets: 7519
InBcastOctets: 328
See netstat command tutorial for more information.
4.
Type the following command:
# ifconfig

OR
# /sbin/ifconfig

OR
# ifconfig eth0

eth0 Link encap:Ethernet HWaddr b8:ac:6f:65:31:e5
inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::baac:6fff:fe65:31e5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:966334 errors:0 dropped:0 overruns:0 frame:0
TX packets:703297 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1186255648 (1.1 GiB) TX bytes:73968238 (70.5 MiB)
Interrupt:17
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9666 errors:0 dropped:0 overruns:0 frame:0
TX packets:9666 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1399578 (1.3 MiB) TX bytes:1399578 (1.3 MiB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.1.11.70 P-t-P:10.0.31.18 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1496 Metric:1
RX packets:3784 errors:0 dropped:0 overruns:0 frame:0
TX packets:4177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:2400265 (2.2 MiB) TX bytes:275983 (269.5 KiB)
To display network interface statistics, enter:
# ip -s link

Sample outputs:

1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes packets errors dropped overrun mcast
1444187 9960 0 0 0 0
TX: bytes packets errors dropped carrier collsns
1444187 9960 0 0 0 0
2: eth0: mtu 1500 qdisc mq state UP qlen 1000
link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
1221956483 991501 0 0 0 24
TX: bytes packets errors dropped carrier collsns
75623937 720272 0 0 0 0
3: wlan0: mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 00:21:6a:ca:9b:10 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
4: pan0: mtu 1500 qdisc noop state DOWN
link/ether 4a:c7:5f:0e:8e:d8 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
8: ppp0: mtu 1496 qdisc pfifo_fast state UNKNOWN qlen 3
link/ppp
RX: bytes packets errors dropped overrun mcast
2419881 3848 0 0 0 0
TX: bytes packets errors dropped carrier collsns
284151 4287 0 0 0 0
5.
Type the following command (you need to install and enable sar via sysstat package):
sar -n DEV

Linux 2.6.32-220.2.1.el6.x86_64 (www.cyberciti.biz) Tuesday 13 March 2012 _x86_64_ (2 CPU)
12:00:01 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
12:10:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 CDT eth0 127.13 121.32 95.45 18.34 0.00 0.00 0.00
12:10:01 CDT eth1 98.48 110.62 16.72 96.33 0.00 0.00 0.00
12:20:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:20:01 CDT eth0 139.95 133.41 106.30 19.95 0.00 0.00 0.00
12:20:01 CDT eth1 110.65 121.85 18.14 107.13 0.00 0.00 0.00
12:30:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:30:01 CDT eth0 147.85 132.49 115.78 20.45 0.00 0.00 0.00
12:30:01 CDT eth1 111.88 127.39 18.61 117.65 0.00 0.00 0.00
12:40:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:40:01 CDT eth0 136.75 124.64 105.24 19.48 0.00 0.00 0.00
12:40:01 CDT eth1 101.65 115.32 17.58 104.50 0.00 0.00 0.00
12:50:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:50:01 CDT eth0 131.45 125.69 96.49 19.58 0.00 0.00 0.00
12:50:01 CDT eth1 101.41 111.31 17.54 96.78 0.00 0.00 0.00
01:00:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:00:01 CDT eth0 140.30 133.27 102.17 20.75 0.00 0.00 0.00
01:00:01 CDT eth1 106.90 119.51 18.53 103.09 0.00 0.00 0.00
01:10:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:10:01 CDT eth0 152.03 127.74 125.56 19.85 0.00 0.00 0.00
01:10:01 CDT eth1 115.60 134.57 18.73 126.96 0.00 0.00 0.00
01:20:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:20:01 CDT eth0 138.55 130.55 103.03 20.20 0.00 0.00 0.00
....
..
....
..
.
01:00:01 CDT eth1 156.82 169.48 28.83 138.49 0.00 0.00 0.00
01:10:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:10:01 CDT eth0 215.19 194.82 163.11 30.99 0.00 0.00 0.00
01:10:01 CDT eth1 162.49 183.79 28.36 163.70 0.00 0.00 0.00
01:20:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:20:01 CDT eth0 200.20 192.23 140.64 30.93 0.00 0.00 0.00
01:20:01 CDT eth1 153.60 166.96 27.32 140.26 0.00 0.00 0.00
01:30:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:30:01 CDT eth0 111.98 103.58 79.12 16.52 0.00 0.00 0.48
01:30:01 CDT eth1 87.50 95.58 14.74 79.35 0.00 0.00 0.00
Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
Average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Average: eth0 211.21 196.20 156.18 31.20 0.00 0.00 0.01
Average: eth1 159.10 174.52 28.00 149.95 0.00 0.00 0.00
Or type the following command:
# sar -n DEV 1 3

Sample outputs:

Linux 2.6.32-220.2.1.el6.x86_64 (www.cyberciti.biz) Tuesday 13 March 2012 _x86_64_ (2 CPU)
01:44:03 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
01:44:04 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:44:04 CDT eth0 161.70 154.26 105.20 26.63 0.00 0.00 0.00
01:44:04 CDT eth1 145.74 142.55 25.11 144.94 0.00 0.00 0.00
01:44:04 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
01:44:05 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:44:05 CDT eth0 162.14 156.31 107.46 42.18 0.00 0.00 0.00
01:44:05 CDT eth1 135.92 138.83 39.38 104.92 0.00 0.00 0.00
01:44:05 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
01:44:06 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01:44:06 CDT eth0 303.92 293.14 272.91 37.40 0.00 0.00 0.00
01:44:06 CDT eth1 252.94 290.20 34.87 263.50 0.00 0.00 0.00
Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
Average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Average: eth0 210.37 202.34 163.19 35.66 0.00 0.00 0.00
Average: eth1 178.93 191.64 33.36 171.60 0.00 0.00 0.00
-----
最后再附送两个
1、netstat -s TCP连接失败 相关统计 解释 (http://blog.sina.com.cn/s/blog_781b0c850101pu2q.html)
针对问题:TCP连接失败
分析:netstat -s输出中和连接失败相关的参数
202270382 invalid SYN cookies received --- 三次握手ack包,syncookies校验没通过;
13700572 resets received for embryonic SYN_RECV sockets ---syn_recv状态下,收到非重传的syn包,则返回reset
1123035 passive connections rejected because of time stamp ---开启sysctl_tw_recycle,syn包相应连接的时间戳 小于 路由中保存的时间戳;
14886782 failed connection attempts --- syn_recv状态下,socket被关闭; 或者 收到syn包(非重传)
438798 times the listen queue of a socket overflowed ---收到三次握手ack包,accept队列满
438798 SYNs to LISTEN sockets ignored ---收到三次握手ack包,因各种原因(包括accept队列满) 创建socket失败
2、Linux 2.6 - man page for nstat (linux section 8) (http://www.unix.com/man-page/linux/8/nstat/)
3、老王的监控Netstat数据 (http://huoding.com/2015/04/09/427)
佛教的一些信息

佛教的一些信息

中国佛教出现过许多派别,主要有八宗。

一是三论宗又名法性宗,
二是瑜伽宗又名法相宗,
三是天台宗,
四是贤首宗又名华严宗,
五是禅宗,
六是净土宗,
七是律宗,
八是密宗又名真言宗。
这就是通常所说的性、相、台、贤、禅、净、律、密八大宗派。

寺院等级介绍 :唐以前设上座,寺主,维那三职.

现在寺院设八大职事:都监,监院,维那,副寺,典坐,僧值,知客,书记.一寺之主称方丈或住持.

GM、VP、FVP、CIO都是什么职位

GM、VP、FVP、CIO都是什么职位

听闻新浪的鸟哥(风雪之隅)去离开新浪去链家当VP了。不禁了解了一下各类英文的称呼,之前只对ceo,cto,cfo之类的解释比较熟,果然还是属于低层面的。。。

所以乘这个机会了解一下gm,vp,fvp,cio的含义,也好装装逼,原文来自:http://blog.sina.com.cn/s/blog_6a2c38270100mso5.html
企业各职位英文缩写:
GM(General Manager)总经理
VP(Vice President)副总裁
FVP(First Vice President)第一副总裁
AVP(Assistant Vice President)副总裁助理
CEO(Chief Executive Officer)首席执行官,类似总经理、总裁,是企业的法人代表。
COO(Chief Operations Officer)首席运营官,类似常务总经理
CFO(Chief Financial Officer)首席财务官,类似财务总经理
CIO(Chief Information Officer)首席信息官,主管企业信息的收集和发布
CTO(Chief technology officer)首席技术官 类似总工程师
HRD(Human Resource Director)人力资源总监
OD(Operations Director)运营总监
MD(Marketing Director)市场总监
OM(Operations Manager)运作经理
PM(Production Manager)生产经理
(Product Manager)产品经理


下面的。。。有点怪。。。

CAO: Art 艺术总监
CBO: Business 商务总监
CCO: Content 内容总监
CDO: Development 开发总监
CGO: Gonverment 政府关系
CHO: Human resource 人事总监
CJO: Jet 把营运指标都加一个或多个零使公司市值像火箭般上升的人
CKO: Knowledge 知识总监
CLO: Labour 工会主席
CMO: Marketing 市场总监
CNO: Negotiation 首席谈判代表CPO: Public relation 公关总监
CQO: Quality control 质控总监
CRO: Research 研究总监
CSO: Sales 销售总监
CUO: User 客户总监
CVO: Valuation 评估总监
CWO: Women 妇联主席
CXO: 什么都可以管的不管部部长
CYO: Yes 什么都点头的老好人
CZO: 现在排最后,等待接班的太子
access-control-allow-origin-multiple-origin-domains

access-control-allow-origin-multiple-origin-domains

原文来自:http://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains

主要是因为涉及到CSS和JS文件是挂在别的域,然后又遇到了ajax之类的操作,所以就需要有跨域操作了,本来很方便的,只是在.htaccess文件中加了一句
Header add Access-Control-Allow-Origin "http://xxxxxx.com"
但因为备案原因,所以又添加了一个备用域名,结果,就报错了,报错提示是:
font from origin 'http://xxxxx.com' has been blocked from loading by Cross-Origin Resource Sharing policy: The 'Access-Control-Allow-Origin' header contains multiple values 'http://yyyy.com, http://zzzz.com', but only one is allowed. Origin 'http://xxxxx.com' is therefore not allowed access.
我晶,不支持多域名啊,google了一下,找到了这一篇:http://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains
不多贴,其实挺有意思。。方法也有不少
1、利用apache的环境变量:
SetEnvIf Origin "^(.*\.example\.com)$" ORIGIN_SUB_DOMAIN=$1
<FilesMatch "\.woff$">
Header set Access-Control-Allow-Origin "%{ORIGIN_SUB_DOMAIN}e" env=ORIGIN_SUB_DOMAIN
</FilesMatch>
2、用PHP来判断:
$http_origin = $_SERVER['HTTP_ORIGIN'];

if ($http_origin == "http://www.domain1.com" || $http_origin == "http://www.domain2.com" || $http_origin == "http://www.domain3.info")
{
header("Access-Control-Allow-Origin: $http_origin");
}
3、和1有点类似
SetEnvIf Origin "^http(s)?://(.+\.)?(domain\.org|domain2\.com)$" origin_is=$0
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
4、这是nginx的:
location /fonts {
# this will echo back the origin header
if ($http_origin ~ "example.org$") {
add_header "Access-Control-Allow-Origin" $http_origin;
}
}
更多的,还是去原网页看吧。。
关于CodeAnyWhere

关于CodeAnyWhere

最近收到一封邮件,大意是,phpanywhere已经改名为codeanywhere了,我看了一下邮件中提及的博客日期,发现贴子地址是:http://www.neatstudio.com/show-1305-1.shtml ,已经是N年前的事情了。

邮件中提及:As you may have heard we have changed our name to Codeanywhere a couple of years back and now we have an issue. Namely we lost the domain phpanywhere.net and know all your link lead to nowhere.

为了以防万一,我查了一下百科:

History[edit]
In 2009 PHPanywhere (the predecessor of Codeanywhere) was launched, which was a web-based FTP client and text editor, designed for PHP.[4] That project stayed idle until May 22, 2013 when the founders launched Codeanywhere.

Codeanywhere raised $600,000 from World Wide Web Hosting on July 15, 2013 when Ben Welch-Bolen became a board member.[5] In August of 2014 Codeanywhere was accepted in Techstars’s Fall Boston Class.[6] In 2014, as part of the TechCrunch Disrupt NY Conference, the audience voted Codeanywhere the best company in Startup Alley.[1]

so,phpanywhere确实是codeanywhere的前身。。。于是顺手改掉了那篇博客,顺便说一下,codeanywhere很早就在ipad上面有APP了,而且我还用过,只是居然真的不知道它就是phpanywhere....


最近很多关于墙的新闻和消息

最近很多关于墙的新闻和消息

说实话,最近有很多关于墙的消息,好象要出国已经变得越来越难了,早上@三马 分享了一篇简书文章,介绍墙和翻墙缘由的,结果发了一分钟就被墙了!是啊,现在已经不再提怎么爬梯子了,很多人都认命了。周围有不少技术人员已经开始用百度、bing来搜索了(不得不说,360、soso什么的还是没有深入到技术人员的心里)

我呢,不知道从什么时候起,我习惯了用google(现在都没有在想以前没有google的时候,我是怎么搜索的),当然到现在为止我还是在用google,甚至我也认为,一个没有办法时刻用上google的人应该也不是一个好程序员(当然,我本来就不是)。

最近上海电信在对国外出口做限制,因为不知道是超售还是封锁,我这里就不发表意见,但带来的问题是,原来仅剩的几个还能访问的国外站点,现在也变得越来越慢了。比如github,作为一名PHP程序员,composer这个工具既给我们带来了快乐,也给我们带来了无尽的悲伤,一个composer update,你已经无法想象你要等多久了。

发完牢骚也说说我自己是怎么用的吧,自建VPN是肯定不用说的,那都是备用的,毕竟在手机上用shadowsocks还是不太方便,平时在网页端已经是switchyomega + goagentx + shadowsocks 了。前两天有人推荐了proxychain4,现在在命令行用它来更新composer 感觉也快了很多。

最后补一句,为了能够稳定的打开网页,我已经备了4个shadowsocks的服务器(这是多大代价的投入啊!!!!!)

BTW:updated 2019-11-26,所有的梯子都断了。。。。。哎。

利用pubu.im来做BUG提醒工具

利用pubu.im来做BUG提醒工具

BUG提醒工具其实有很多,比如可以在有BUG的时候发封邮件到你的常用邮箱,这样你的手机上(邮件APP)就会收到一条提醒。或者有短信SP通道的话,你也可以有类似处理。当然还有monolog,支持php-console插件,可以发送到你的chrome上面,我在这里再换个小方式,利用pubu.im这个IM工具(或者说。。。。说不出来)来做提醒

流程很简单

1、去pubu.im测试一个帐户。。这不用我多说吧

2、下载MAC客户端登录,自己添加自己为一个机器人,相当于自己和自己聊天,如果你的消息不算隐私,你可以直接用现成的:小布 这个通道

3、在聊天界面选择插件,点击更多,打开网页,添加“incoming”插件,生成一个URL,选择你刚才聊天组

4、根据提示信息在你的APP里写上一段测试代码,POST方式的,可以用curl/file_get_contents/Requests/guzzle等,工具实在太多,不想多说

5、测试通过后,可以尝试自己用set_error_handle,自己处理出错信息,在出错信息前进行判断:

if(debug_mode){ //send report }

6、你会发现 右上角弹了一个小窗,就是你刚才的测试标题!

----EOF---

就这样,你在工作的时候不需要打开手机,电脑上会直接有提醒哦~~~而且因为是聊天记录,你还可以往前翻,到底是什么BUG,嗯,再也不用客户端开发人员和你说,XXX接口出错了。。。因为他一出错你就收到,然后你就可以在他没有和你提的时候悄悄的改掉,等他提出来有BUG的时候,你说,在哪里?一定是你访问的姿势不对,不信你试试

哈哈