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
using MongoDB.Bson; | |
using MongoDB.Bson.Serialization; | |
using MongoDB.Bson.Serialization.Serializers; | |
public class MongoDbConfigurator { | |
static MongoDbConfigurator() { | |
BsonSerializer.RegisterSerializer(typeof(DateTimeOffset), new DateTimeOffsetSerializer(BsonType.String)); | |
} | |
} |
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 DictionaryExtension { | |
public static TOutput GetOrDefault<TOutput, TValue>(this IDictionary<string, TValue> self, string key, TOutput defaultValue) | |
where TOutput : TValue { | |
return self.ContainsKey(key) ? (TOutput)self[key] : defaultValue; | |
} | |
} |
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
SELECT | |
s.Name AS SchemaName, | |
t.NAME AS TableName, | |
p.rows AS RowCounts, | |
SUM(a.total_pages) * 8 AS TotalSpaceKB, | |
SUM(a.used_pages) * 8 AS UsedSpaceKB, | |
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB | |
FROM | |
sys.tables t | |
INNER JOIN |
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
git push --delete origin branch-name | |
# or | |
git push origin :branch-name | |
# When there is a tag with the same name of the branch: | |
git push origin :refs/heads/branch-name |
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 MongoSerializingExtensions { | |
public static BsonDocument RenderToBsonDocument<T>(this FilterDefinition<T> filter) { | |
var serializerRegistry = BsonSerializer.SerializerRegistry; | |
var documentSerializer = serializerRegistry.GetSerializer<T>(); | |
return filter.Render(documentSerializer, serializerRegistry); | |
} | |
public static BsonDocument RenderToBsonDocument<T>(this SortDefinition<T> sort) { | |
var serializerRegistry = BsonSerializer.SerializerRegistry; | |
var documentSerializer = serializerRegistry.GetSerializer<T>(); |
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
using System; | |
using System.Globalization; | |
namespace DateAndTimeMeltingPot { | |
class MainClass { | |
public static void Main(string[] args) { | |
// Getting 'calendar/clock' date adn time | |
DateTime myBirthday = new DateTime(1978, 3, 19, 1, 15, 0, DateTimeKind.Unspecified); | |
Print(myBirthday); |
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
import java.time.Instant; | |
import java.time.LocalDate; | |
import java.time.LocalDateTime; | |
import java.time.LocalTime; | |
import java.time.ZoneId; | |
import java.time.ZonedDateTime; | |
import java.time.format.DateTimeFormatter; | |
public class DateAndTimeMeltingPot { | |
public static void main(String[] args) { |
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 range(first, last) { | |
const length = last - first + 1 | |
return new Array(length).fill(-1, 0, length).map(function(v, i) { return i + first; }) | |
} |
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
# Shows git history in graph fashion, including all branches | |
git log --graph --abbrev --all --oneline --decorate | |
# Sets up global git alias for previous command | |
git config --global alias.graph 'log --graph --all --decorate --oneline' |
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 RandomExtensions { | |
public static Task Delay(this Random random, int min, int max) { | |
return Task.Delay(random.Next(min, max)); | |
} | |
} |