Skip to content

Instantly share code, notes, and snippets.

View hellojinjie's full-sized avatar
🏠
Working from home

hellojinjie hellojinjie

🏠
Working from home
View GitHub Profile
@hellojinjie
hellojinjie / onlineview.sql
Created July 21, 2014 07:20
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
@hellojinjie
hellojinjie / .vimrc
Created April 28, 2012 06:07 — forked from htom78/.vimrc
Set up Vim on Mac or Linux. curl https://raw.github.com/gist/532968/vim.sh | sh
" this is the configuration file for linux and mac systems
" symlink this to your home folder as .vimrc
" It loads pathogen and loads all modules from ~/.vim/bundles.
" It then loads ~/.vimrc_main which has the main
" configuration that works across all systems.
call pathogen#runtime_prepend_subdirectories(expand('~/.vim/bundles'))
call pathogen#helptags()
source ~/.vimrc_main
<?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)
@hellojinjie
hellojinjie / XinDianBaoSessionService.java
Created September 2, 2012 08:48
top sync user session serivice
package com.xindianbao.isv;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.ExecutionException;
import com.google.common.cache.CacheBuilder;
package com.xindianbao.isv;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.gearman.Gearman;
import org.gearman.GearmanClient;
import org.gearman.GearmanServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@hellojinjie
hellojinjie / repair-maven-local-repository.sh
Created June 26, 2013 13:11
由于网路的原因,我们在下载 jar 包或者 source 的时候,会中断,导致 maven 认为在 central repository 不存在这个文件。 这时我们可以手动删除不完整的 jar 包。
find . -name "*-lastUpdated" -or -name "*-not-available" -exec rm {} \;
find . -size 0 -exec rm {} \;
@hellojinjie
hellojinjie / PS1.sh
Last active December 19, 2015 00:18
酷酷的 PS1 : )
// 第一个是原文的,但是不对的,下面的第二个是我修改的。
// original from http://jamiedubs.com/ps1-collection-customize-your-bash-prompt
// export PS1="\[\e[01;32m\]\u@\h \[\e[01;34m\]\W \`if [ \$? = 0 ]; then echo -e '\e[01;32m:)'; else echo -e '\e[01;31m:('; fi\` \[\e[01;34m\]$\[\e[00m\] "
export PS1="\[\e[01;32m\]\u@\h \[\e[01;34m\]\W \`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]:)'; else echo -e '\[\e[01;31m\]:('; fi\` \[\e[01;34m\]$\[\e[00m\] "
@hellojinjie
hellojinjie / 行尾结束符.sh
Last active December 19, 2015 13:48
坑爹的行尾结束符。
#!/usr/bin/env bash
java -jar dbmigrate.jar $*
# 在 windows 中编辑的 shell 脚本复制到 linux 运行出现 : No such file or directory 错误
# 你绝对想不到,上面的代码在 shell 看来应该是下面这样的
#!/usr/bin/env bash^M
java -jar dbmigrate.jar $*^M
# 运行 dos2unix ,去掉 \r 即可。
@hellojinjie
hellojinjie / redis-usage.sh
Created July 11, 2013 05:58
请问这是 column store吗?
$ redis-cli incr next.news.id
(integer) 1
$ redis-cli set news:1:title "Redis is simple"
OK
$ redis-cli set news:1:url "http://code.google.com/p/redis"
OK
$ redis-cli lpush submitted.news 1
OK
@hellojinjie
hellojinjie / guesspath.sh
Created September 10, 2013 07:34
神奇的一段 shell 代码用来判断当前脚本所在的位置,从 hadoop 的启动脚本里复制过来的
this="${BASH_SOURCE-$0}"
dir=$(cd -P -- "$(dirname -- "$this")" && pwd -P)