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 IdGenerator | |
{ | |
private static readonly ConcurrentDictionary<string, IEnumerator<string>> _generators = new ConcurrentDictionary<string, IEnumerator<string>>(); | |
public static string Next(string prefix) | |
{ | |
var generator = _generators.GetOrAdd(prefix, x => MakeSequence(prefix).GetEnumerator()); | |
generator.MoveNext(); | |
return generator.Current; | |
} |
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 bool CanHandle(MimeMessage message, IEnumerable<(string name, byte[] data)> attachments) | |
{ | |
return true; | |
} | |
// ... |
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
// snip | |
var handlers = new IMailProcessor[] | |
{ | |
new AppleHealthAttachmentMailProcessor(from, settings, customSheets), | |
new AppleHealthGoogleDriveMailProcessor(from, settings, customSheets), | |
new SettingsUpdateMailProcessor(from, settingsStore), | |
new HelpMailProcessor(from), // <-- catch all | |
}; |
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"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.doesnt.matter</groupId> | |
<artifactId>Whatever</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<name>Simple POM to download some dependencies</name> | |
<url>http://jonfuller.co</url> | |
<dependencies> | |
<dependency> |
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
NODE_NAME="name-of-node" | |
ENDPOINT="http://JENKINSURL_GOES_HERE/computer/api/xml?xpath=computerSet/computer\[displayName='$NODE_NAME'\]/offline/text()" | |
ENDPOINT_RESULT=$(curl $ENDPOINT 2> /dev/null) | |
if [ $ENDPOINT_RESULT = "false" ] ; then | |
exit 0 | |
fi | |
exit 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
def using(to_ensure) | |
begin | |
yield if block_given? | |
ensure | |
to_ensure() | |
end | |
obj = SomthingToClose.connect |
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
{ | |
"arguments": { | |
"fields": [ "id", "name", "percentDone", "totalSize", "rateDownload", "rateUpload" ] | |
}, | |
"method": "torrent-get" | |
} |
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
{ | |
"arguments": { | |
"fields": [ "id", "name", "percentDone", "totalSize", "rateDownload", "rateUpload" ] | |
}, | |
"method": "torrent-get" | |
} |
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 class Meh | |
{ | |
public static void Change<TObj, TProp>(this TObj obj, Expression<Func<TObj, TProp>> propertyExpr, TProp newValue, Action operation) | |
{ | |
var name = ((MemberExpression)propertyExpr.Body).Member.Name; | |
var prop = typeof(TObj).GetProperty(name); | |
var oldValue = prop.GetValue(obj, new object[0]); | |
try | |
{ |
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
class LineBuilder | |
{ | |
List<LineItem> _lines; | |
public LineBuilder WithLine(params string[] names) | |
{ | |
_lines.AddRange(names.Select(name => new LineItem(name))); | |
return this; | |
} |
NewerOlder