This file contains 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 bool IsBetween<T>(this T value, T min, T max) where T : struct, IComparable, IComparable<T>, | |
IConvertible, IEquatable<T>, IFormattable | |
{ | |
return value.CompareTo(min) >= 0 && value.CompareTo(max) <= 0; | |
} |
This file contains 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
#region MIT License | |
// Color.cs is distributed under the MIT License (MIT) | |
// | |
// Copyright (c) 2018, Eric Freed | |
// | |
// The MIT License (MIT) | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
This file contains 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
module Kernel | |
def suppress_warning | |
return unless block_given? | |
verbosity = $VERBOSE | |
$VERBOSE = nil | |
yield | |
$VERBOSE = verbosity | |
end | |
end |
This file contains 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
require 'rubygems/package' | |
require 'zlib' | |
TAR_LONGLINK = '././@LongLink' | |
tar_gz_archive = '/path/to/archive.tar.gz' | |
destination = '/where/extract/to' | |
Gem::Package::TarReader.new( Zlib::GzipReader.open tar_gz_archive ) do |tar| | |
dest = nil | |
tar.each do |entry| |
This file contains 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
/* | |
* A simple libpng example program | |
* http://zarb.org/~gc/html/libpng.html | |
* | |
* Modified by Yoshimasa Niwa to make it much simpler | |
* and support all defined color_type. | |
* | |
* To build, use the next instruction on OS X. | |
* $ brew install libpng | |
* $ clang -lz -lpng15 libpng_test.c |
This file contains 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
char* replace_char(char* str, char find, char replace){ | |
char *pos = strchr(str,find); | |
while (pos) | |
{ | |
*pos = replace; | |
pos = strchr(pos,find); | |
} | |
return str; | |
} |
This file contains 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
/* | |
* Windows BMP file functions for OpenGL. | |
* | |
* Written by Michael Sweet. | |
*/ | |
#include "bitmap.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> |
This file contains 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 bool Serialize<T>(T obj, Stream stream) | |
{ | |
try | |
{ | |
var xml = new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 }; | |
var serializer = new DataContractSerializer(typeof(T)); | |
using (var writer = XmlWriter.Create(stream, xml)) | |
{ | |
serializer.WriteObject(writer, obj); | |
} |
This file contains 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.Drawing; | |
namespace MyNamespace | |
{ | |
public static class Extensions | |
{ | |
public static Color ToColor(this ConsoleColor color) | |
{ | |
switch (color) |
This file contains 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.Runtime.InteropServices; | |
namespace MyNamespace | |
{ | |
public static class ConsoleHelper | |
{ | |
private const int SW_SHOW = 5; | |
public static void Show() |
OlderNewer