Skip to content

Instantly share code, notes, and snippets.

View dyng's full-sized avatar
🤔
I think

Ye Ding dyng

🤔
I think
  • Shanghai
  • 12:23 (UTC +08:00)
View GitHub Profile
@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: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 / 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: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 / 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 / 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