Skip to content

Instantly share code, notes, and snippets.

private enum StudentToId implements Function<Student, Integer> {
INSTANCE;
@Override
public Integer apply(Student input) {
return input.getId();
}
}
@xilin
xilin / master.vim
Created February 26, 2014 08:53 — forked from gmccreight/master.vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
angular.module("myApp",[])
.directive("myDirective", function () {
return {
restrict: "A",
scope: {
text: "@myText",
twoWayBind: "=myTwoWayBind",
oneWayBind: "&myOneWayBind"
}
};
git rebase --onto <new base-commit> <current base-commit>
@xilin
xilin / analyse_watchers.js
Last active August 29, 2015 14:08 — forked from DTFagus/analyse_watchers.js
Analysis Angular Watcher
javascript: (function() {
var root = $(document.getElementsByTagName('html'));
var watchers = [];
var attributes = [];
var attributes_with_values = [];
var elements = [];
var elements_per_attr = [];
var scopes = [];
@xilin
xilin / hibernate_update.java
Created March 18, 2015 03:50
Hibernate Update
StringBuffer sql = new StringBuffer();
sql.append("UPDATE TABLE_NAME ");
sql.append("SET FIELD_NAME = FIELD_VALUE ");
sql.append("WHERE COND_FIELD =:param ");
SQLQuery query = this.getSession().createSQLQuery(sql.toString());
query.setParameter("param", paramValue);
query.executeUpdate();
import static java.lang.System.out;
import static java.util.Arrays.asList;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
public class ListTests {
public static void main( String[] args ) {
List<String> names = asList( "Ted", "Fred", "Jed", "Ned" );
@xilin
xilin / UIScrollView_did_end.m
Created September 12, 2015 13:26
how to check when UIScrollView end scroll
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
//[super scrollViewWillBeginDragging:scrollView]; // pull to refresh
self.isScrolling = YES;
NSLog(@"+scrollViewWillBeginDragging");
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
@xilin
xilin / linkmap.js
Created December 7, 2015 03:09 — forked from bang590/linkmap.js
XCode Linkmap Parser
var readline = require('readline'),
fs = require('fs');
var LinkMap = function(filePath) {
this.files = []
this.filePath = filePath
}
LinkMap.prototype = {
start: function(cb) {