View gist:54b4432fffaf0c67b176
<?php
function getTaobaoURLFromShortURL($shortURL)
{
$contents = file_get_contents($shortURL);
$pattern = '/d="J_Url" value=\'(.+)\'>./';
preg_match($pattern, $contents, $matches);
return urldecode($matches[1]);
}
function getItemIdFromURL($itemURL)
View onlineview.sql
SELECT
d.parent_id, views, cdn,
from_unixtime(1405267200 + row_number * 60) as step_time
FROM
(SELECT
apptype_id, game_id, count(view_id) AS views, r.row_number,
sum(bytes_loaded_cdn1 + bytes_loaded_cdn2 + bytes_loaded_cdn3 + bytes_loaded_cdn4) /duration as cdn
FROM
(SELECT
@curRow:=@curRow + 1 AS row_number
View ErrorLogAnalyze.scala
import scala.io._
import java.io._
import java.util.regex._
object ErrorLogAnalyze {
def main(args: Array[String]) = {
val files = if (args.length == 0) new File(".") else new File(args(0))
val lines = getLogs(files.listFiles.filter(_.getName.contains("error")).toList)
val errorAndHeartbeat = lines.partition(line => line.contains("ERROR") && line.contains("HEARTBEAT"))._1
View TrafficGenerator.scala
import scala.collection.mutable.LinkedList
import scala.collection.mutable.ListBuffer
import scala.compat._
import java.io._
import java.net._
import java.util._
import scala.util.Random
import java.nio.charset.Charset
import java.util.concurrent._
import java.util.concurrent.atomic._
View hdparm.sh
[root@localhost ~]# hdparm -Tt /dev/sdb1
/dev/sdb1:
Timing cached reads: 25642 MB in 2.00 seconds = 12842.90 MB/sec
Timing buffered disk reads: 532 MB in 3.01 seconds = 176.98 MB/sec
[root@localhost ~]# mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
View GenericUDAFCdnBytesLoaded.java
package com.jaunty.hive.udf;
import java.util.Map;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer;
View LockWaitTimeout.java
106626 Lock wait timeout exceeded; try restarting transaction
106627 java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
106628 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
106629 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
106630 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
106631 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
106632 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
106633 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
106634 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
106635 at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379)
View hue_install_error.sh
jj@hellojinjie hue-2.5.0 :) $ python2.7 /home/jj/Workspaces/lib/hue-2.5.0/tools/virtual-bootstrap/virtual-bootstrap.py -qq --no-site-packages /home/jj/Workspaces/lib/hue-2.5.0/build/env
Traceback (most recent call last):
File "/home/jj/Workspaces/lib/hue-2.5.0/tools/virtual-bootstrap/virtual-bootstrap.py", line 1504, in <module>
main()
File "/home/jj/Workspaces/lib/hue-2.5.0/tools/virtual-bootstrap/virtual-bootstrap.py", line 547, in main
use_distribute=options.use_distribute)
File "/home/jj/Workspaces/lib/hue-2.5.0/tools/virtual-bootstrap/virtual-bootstrap.py", line 637, in create_environment
install_setuptools(py_executable, unzip=unzip_setuptools)
File "/home/jj/Workspaces/lib/hue-2.5.0/tools/virtual-bootstrap/virtual-bootstrap.py", line 379, in install_setuptools
_install_req(py_executable, unzip)
View sun.net.www.protocol.http.HttpURLConnection.java
final boolean result[] = {false};
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public Object run() {
try {
InetAddress a1 = InetAddress.getByName(h1);
InetAddress a2 = InetAddress.getByName(h2);
result[0] = a1.equals(a2);
} catch (UnknownHostException e) {
} catch (SecurityException e) {
}
View guesspath.sh
this="${BASH_SOURCE-$0}"
dir=$(cd -P -- "$(dirname -- "$this")" && pwd -P)