安装PDO_DBLIB时FreeTDS目录报错的解决

Standard

报错:
[root@test PDO_DBLIB-1.0]# ./configure –with-php-config=/usr/bin/php-config –with-pdo_dblib=/usr/local/freetds


configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory

解决:
touch /usr/local/freetds/include/tds.h
touch /usr/local/freetds/lib/libtds.a
再 ./configure –with-php-config=/usr/bin/php-config –with-pdo_dblib=/usr/local/freetds 时就ok了

Facebook的OnlineSchemaChange.php备注

Standard
...
define('OSC_FLAGS_ACCEPT_VERSION',  0x0400); // bypasses version check
...
public function __construct($input_sock = '', $input_user, $input_password,
  $input_dbname, $input_tablename,
  $input_altercmd, $input_outfile_folder = null,
  $input_flags = 0,
  $input_batchsize_load = 500000,
  $input_batchsize_replay = 500,
  $input_long_xact_time = 30,
  $input_logfile_folder = "/var/tmp/") {
  ...
}
 
...
 
  private function validateVersion() {
    ...
    if ((!($this->flags & OSC_FLAGS_ACCEPT_VERSION)) &&
        ($this->version !== "5.0.84") &&
        ($this->version !== "5.1.47")) {
      $error = "OSC has only been tested on versions 5.0.84 and 5.1.47. ".
               "Running on ".$this->version." is not allowed unless ".
               "OSC_FLAGS_ACCEPT_VERSION flag is set.";
      $this->raiseException($error, false);
    }
    return $this->version;
  }
 
...
 
$user='root';
$pwd='';
$db = 'test';
$table = 't1';
$sock = '/var/lib/mysql/mysql.sock';
 
$alter = "ALTER TABLE `t1` ADD INDEX ( `intcol1` )";
 
$osc = new OnlineSchemaChange($sock, $user, $pwd, $db, $table, $alter, NULL, 0x0400);
$osc->execute();

mysql小工具openarkkit

Standard

下载地址 http://code.google.com/p/openarkkit/

oak-apply-ri: apply referential integrity on two columns with parent-child relationship.
oak-block-account: block or release MySQL users accounts, disabling them or enabling them to login.
oak-chunk-update: perform long, non-blocking UPDATE/DELETE operation in auto managed small chunks.
oak-get-slave-lag: print slave replication lag and terminate with respective exit code.
oak-hook-general-log: hook up and filter general log entries based on entry type or execution plan criteria.
oak-kill-slow-queries: terminate long running queries.
oak-modify-charset: change the character set (and collation) of a textual column.
oak-online-alter-table: perform a non-blocking ALTER TABLE operation.
oak-prepare-shutdown: make for a fast and safe MySQL shutdown.
oak-purge-master-logs: purge master logs, depending on the state of replicating slaves.
oak-repeat-query: repeat query execution until some condition holds.
oak-security-audit: audit accounts, passwords, privileges and other security settings.
oak-show-limits: show AUTO_INCREMENT “free space”.
oak-show-replication-status: show how far behind are replicating slaves on a given master.

记下备用.

phpsysinfo on my vps

Standard


在本站当前所在VPS下装了个用PHP做的用于查看系统信息的小工具.
今后要是需要用PHP做一些系统管理后台时可以参考.

官方链接: http://sourceforge.net/projects/phpsysinfo/

Happy Birthday to me

Standard


一早打开邮箱就收到公司的邮件贺卡,提醒自己时间真是越过越快.
一晃就虚岁30喽~
想想之前上学时的那些个小目标基本也算是达成了.
等再那么十年一晃的时候~
我想~ 全家庭和睦身体健康~ 收入翻N番~ 换更大的house~ 等等好多好贪的目标,哈~

CentOS下Tomcat7+Solr3的安装配置

Standard

下载

wget http://mirror.bjtu.edu.cn/apache/lucene/solr/3.1.0/apache-solr-3.1.0.tgz
wget http://labs.renren.com/apache-mirror/tomcat/tomcat-7/v7.0.12/bin/apache-tomcat-7.0.12.tar.gz
tar zxvf apache-solr-3.1.0.tgz
tar zxvf apache-tomcat-7.0.12.tar.gz
mv apache-solr-3.1.0 /usr/local/solr
mv apache-tomcat-7.0.12 /usr/local/tomcat

配置

vi /etc/profile
#加在最底下
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk
export CLASSPATH=.:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export TOMCAT_HOME=/usr/local/tomcat
export JAVA_OPT="$JAVA_OPTS -Dsolr.solr.home=/usr/local/solr/example/solr"
cp /usr/local/solr/dist/apache-solr-3.1.0.war /usr/local/tomcat/webapps/solr.war
 
vi /usr/local/tomcat/conf/Catalina/localhost/solr.xml
<Context docBase="/usr/local/tomcat/webapps/solr.war" debug="0" crossContext="true">
    <Environment name="solr/home" type="java.lang.String" value="/usr/local/solr/example/solr" override="true" />
</Context>
vi /usr/local/solr/example/solr/conf/solrconfig.xml
#初始
<dataDir>${solr.data.dir:}</dataDir>
#修改为
<dataDir>${solr.data.dir:/usr/local/solr/example/solr/data}</dataDir>
vi /usr/local/tomcat/conf/tomcat-users.xml
#去掉注释块,加入以下内容
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <user username="tomcat" password="s3cret" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>

启动
/usr/local/tomcat/bin/startup.sh

浏览
http://localhost:8080/manager/status

http://localhost:8080/solr/

转载请注明出处:http://yemaosheng.com

Confessions of your worst WTF moment 摘录

Standard

原贴链接: http://stackoverflow.com/questions/63668/confessions-of-your-worst-wtf-moment

No.1
Our product was used by police forces to input data about people that are arrested and what they are charged with. It would also store digital mugshots and fingerprints, and electronically submit the fingerprints to the FBI. While testing, we would routinely use our own fingerprints for fake bookings that got inserted into the test database. Except for the time that I “temporarily” switched the test machines over to the production database and forgot to switch them back…

Cleaning up our production database was easy, but it took a court order signed by the superintendent of the Boston Police Department to remove my colleague’s fingerprints from the FBI database — she had booked herself under the name “Elroy Jetson”.

No.2
I was given a GPS system that was used on ships and given the task of getting a program to interface with it and collect co-ordinates. We didn’t have a manual for the device, but once I got it powered on, I found a big help button. I thought that might at least get us started with how to use it.
After pressing the button, it beeped a couple of times, and then the screen started flashing: Sending S.O.S. signal
Gosh damn – I unplugged the power cable, hoping the thing would turn off, but it must have had an emergency battery inside, because it carried on going, and there was no stopping it.
I waited, very anxiously, expecting a Sea King helicopter to appear outside the office at any moment, wondering how I was going to explain what had happened.
Fortunately – either because I was indoors and the signal didn’t get through or because the receiver of the signal realized an S.O.S. originating 100 miles inland probably wasn’t a real shipping incident – no sea king turned up. Phew.

No.3
I had just imported a bunch of old data into a new system, had taken about 5 hours and was due to go live two hours later, this was around 4 in the morning.
For some reason I tried to delete something:
DELETE from important_table; where id=4
Yeah, I didn’t notice the semicolon either. And no, there was no safety net.

No.4
I shipped my administrator password for an FTP site inside an open source project I was working on.

No.5
I worked for a large bank and added an error message to a piece of code that the application should never have been able to reach (theoretically)…
One Monday morning the unthinkable happened. The error message was proudly displayed on over 10,000 monitors across 1800 branches, and would return when you dismiss the message.
The message read: “If you can see this message the system is all F**KED UP and we might as well go home. Have a nice day.”
Thank goodness this happened before source control systems were implemented at the bank.

No.6
I was logged into my new dedicated server box and configuring some firewall rules over ssh. The first thing I did was set it to not accept any connections from anyone. Then I saved it to test that before going through and adding the various ports I wanted to allow.
Needless to say, the first rule worked…

No.7
When I set up a new VMware instance at the evening and went home keeping it running. What I didn’t noticed was that I used the IP of the Nameserver as IP of the VMware instance. Suddenly all hosts in our building tried to connect to the VMware for DNS lookups.
Our whole network was practically down.
Since this was a VMware our Admins were not able to track down the MAC address. So they had to plug off every single computer in our office (~500) until the problem was gone.
At the next day I found a letter on my desk: “Who dares to switch this computer on will die”.

No.8
Near the end of the dot com bubble, my company was doing research on a sector of the market. We had been given a database with company names in that sector, and we weren’t sure if many of them were still viable companies. I wrote a quick and dirty app which looped through the database and tried the URLs to see if it got a valid response… the assumption being that a 404 would be a failed company. The app used the IE browser COM component and actually displayed the pages while it processed. I split the database into three sections and set it to run on three machines beginning at the close of business and running overnight. My cube was extremely proximate to the CEO and CFO.
Upon arrival the next day, I discovered that the database was not at all accurate. Apparently it was open to the public for update, and numerous spammers and porn companies had inserted records and URLs of their own. This, in itself, was not terrible. What was terrible is that many of the pages when loaded, spawned pop-up windows of extremely explicit details and while the program moved on to the next page, the pop-up windows were orphaned and visible for all to see.
I had some ‘splaining to do.

No.9
I rewrote a whole module that was working perfectly but that looked “messy” to me. I had managed to convince my boss that it was the Right Thing To Do, and the rewrite took me 3 weeks.
I still remember the pearls of sweat running from my armpits as my boss, looking over my shoulder, was commenting on bug after bug in my new shiny super-clean module…
I’m no longer “rewriting from scratch” without a really good reason.

No.10
Ooh! Embarrassing confessional time. The first one that comes to mind was shortly after I switched to OS X from years on Windows and had basically forgotten anything I knew about unix.
I was working on a personal project and decided I was at a point where I should backup my stuff. So I opened up the command line:
gzip *.py
Oh man! It zipped every file individually! Right, I have to tar them first. Okay
rm *.gz
Wait! Why is my directory empty?! Oh no….
Yeah, I also forgot that gz doesn’t copy and zip, it zips in-place.
I got lucky, though, and still had most of the files open in my editor.
This was what convinced me to finally install a version control system on my home machine and use it for my own stuff.

No.x…

Gtk+ HTML backend update

Standard

转贴,原文链接:http://blogs.gnome.org/alexl/2011/03/15/gtk-html-backend-update/

The last few days I spent fixing up some more details in the new HTML5 gdk backend. Not everything is supported yet (keyboard input in particular is very weak), but much more things work now. Even thought the backend is not of production quality it is now good enough that I think its interesting for a larger audience to play around with. So, today I merged the branch into the Gtk+ master branch (i.e. what will be Gtk+ 3.2).

The new multi-backends setup in Gtk+ 3.0 makes this much easier to test. All you have to do is build Gtk+ with –enable-x11-backend –enable-broadway-backend.This will give you a normal X11-based Gtk+ where you can enable the broadway backend at runtime by setting the GDK_BACKEND enviroment variable.

The backend only supports firefox 4 atm, and Mozilla disabled websockets by default, so you have to enable enable websockets for any input to work. However when this is done you can test any app by running:

GDK_BACKEND=broadway your-application&
firefox http://127.0.0.1:8080/
I recorded a small screencast to show this stuff:

Note that the recording is using a local connection, it will be slower over the network depending on the network bandwidth.