Skip to content

Instantly share code, notes, and snippets.

View dyng's full-sized avatar
🤔
I think

Ye Ding dyng

🤔
I think
  • Shanghai
  • 06:58 (UTC +08:00)
View GitHub Profile
@dyng
dyng / Dockerfile
Created July 20, 2017 09:26
Create an base image for CI building
FROM maven:3.5-jdk-8
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# add settings.xml into project directory
COPY settings.xml "$MAVEN_CONFIG"
ADD . build
RUN cd build && mvn install -DskipTests
@dyng
dyng / loadJsFromUrl.js
Created August 10, 2015 02:36
Load javascirpt from url, note that the 'Content-Type' should be 'application/javascript'.
function loadJsFromUrl(url) {
var ele = document.createElement("script");
ele.setAttribute("src", url);
document.head.appendChild(ele);
}
@dyng
dyng / gist:5a0d4b7184a9fea54587
Created June 22, 2015 12:09
Example of angular's service, factory, provider
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
};
});
//factory style, more involved but more sophisticated
@dyng
dyng / com.user.loginscript.plist
Created December 14, 2014 03:47
A launchd plist for custom shell script
<!-- http://stackoverflow.com/questions/6442364/running-script-upon-login-mac/13372744#13372744 -->
<!-- Place me at ~/Library/LaunchAgents/com.user.loginscript.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.loginscript</string>
<key>Program</key>
<string>/path/to/executable/script.sh</string>
@dyng
dyng / gist:5c195645cce231cc4d80
Last active August 29, 2015 14:07
Compare tree in Rust
fn is_same_tree(p: &Tree<int>, q: &Tree<int>) -> bool {
match (*p, *q) { // error: cannot move out of dereference of `&`-pointer
(None, None) => true,
(Some(ref a), Some(ref b)) => {
if a.val == b.val
&& is_same_tree(&a.left, &b.left)
&& is_same_tree(&a.right, &b.right){
true
} else {
false
@dyng
dyng / gist:1b04ae9a03c9cf761333
Created October 12, 2014 02:19
Find your codes ate by git

现在假设你添加了一个新文件a.txt,内容如下:

An a file

然后git add a.txtgit reset --hard,恢复到初始状态。

这时运行git fsck的结果如下:

@dyng
dyng / gist:8993654
Created February 14, 2014 01:18
测试包含LWP::UserAgent的模块
use Test::More;
use Test::MockModule;
use HTTP::Request;
our $request_count = 0;
my $mock_ua = Test::MockModule->new('LWP::UserAgent');
$mock_ua->mock('request', sub {
$request_count++;
HTTP::Response->new(200);
});
@dyng
dyng / n2N2n
Last active December 21, 2015 04:09
"n" 固定正向搜索,"N" 固定逆向搜索。
noremap <silent><expr>n v:searchforward ? "n" : "N"
noremap <silent><expr>N v:searchforward ? "N" : "n"
@dyng
dyng / gist:5299251
Last active December 15, 2015 17:49
Inner Join 中使用 AS 的例子
SELECT me.id, him.nickname, me.user_id, transaction_id, purchase_at FROM payment AS me INNER JOIN user AS him ON me.user_id = him.id WHERE him.nickname = 'tama';
@dyng
dyng / gist:4593916
Created January 22, 2013 11:21
编写插件时常用的打开窗口的命令
" 保持轮换文件不变,在左上角垂直打开宽度为20的窗口,打开文件__BufName__
silent keepalt topleft vertical 20split __BufName__