This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ObjectHelper { | |
public static T? Min<T>(T? x, T? y) where T : struct, IComparable { | |
if (x.HasValue && y.HasValue) { | |
return x.Value.CompareTo(y.Value) <= 0 ? x : y; | |
} else if (x.HasValue) { | |
return x; | |
} else { | |
return y; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomInt(from, to) { | |
var interval = to - from + 1; | |
return function() { | |
return Math.floor(Math.random() * interval) + from; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function every(times, callback) { | |
var count = times; | |
return function() { | |
count--; | |
if(count === 0) { | |
count = times; | |
callback(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function after(times, callback) { | |
return function() { | |
times--; | |
if(times === 0) { | |
callback(); | |
} | |
} | |
} | |
function asyncmap(list, op, cb) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function after(times, callback) { | |
return function() { | |
times--; | |
if(times === 0) { | |
callback(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DateTimeExtension { | |
public static Int64 Epoch(this DateTime date) | |
{ | |
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); | |
return Convert.ToInt64((date - epoch).TotalMilliseconds) ; | |
} | |
public static DateTime ToDateTime(this long unixTime) | |
{ | |
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.messages.aggregate([ | |
{ $unwind: '$headers.To' }, | |
{ $group: { _id: { id: '$_id', from: '$headers.From'}, to: { $addToSet: '$headers.To' }}}, | |
{ $unwind: '$to' }, | |
{ $group: { _id: { from: '$_id.from', to: '$to'}, hits: {$sum: 1}}}, | |
{ $match: { hits: {$gt: 1} } }, | |
{ $sort: { hits: -1 }} | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Starts ssh-agent | |
eval $(ssh-agent) | |
# Adds private key to ssh-agent | |
ssh-add /path/to/private/key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId></groupId> | |
<artifactId></artifactId> | |
<version></version> | |
<name></name> | |
<packaging></packaging> | |
<dependencyManagement> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> | |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<title></title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="description" content="" /> | |
<meta name="keywords" content="" /> | |
</head> | |
<body> |