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
/// <summary> | |
/// Reshapes the drawing are to maintain aspect ratio when the window is resized, | |
/// using a target pixel ratio to maintain, and applying "pillars" or "letterbox" | |
/// effect as needed, allowing the drawing context to shrink/grow uniformly. | |
/// </summary> | |
/// <param name="width">The new width of the window/drawing area to fit to.</param> | |
/// <param name="height">The new height of the window/drawing area to fit to.</param> | |
public void WindowReshape(int width, int height) | |
{ | |
// Make the projection matrix active |
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
#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 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 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 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
module Kernel | |
def suppress_warning | |
return unless block_given? | |
verbosity = $VERBOSE | |
$VERBOSE = nil | |
yield | |
$VERBOSE = verbosity | |
end | |
end |
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
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 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
/* | |
* 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 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
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 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
/* | |
* 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 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.IO; | |
using System.IO.Compression; | |
using System.Text; | |
namespace TarExample | |
{ | |
public class Tar | |
{ |
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 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); | |
} |
OlderNewer