Skip to content

Instantly share code, notes, and snippets.

@tinybitsofcode
tinybitsofcode / volumetric-clouds.glsl
Created October 13, 2024 21:34 — forked from dolanor/volumetric-clouds.glsl
Volumetric clouds GLSL webGL
// Created by inigo quilez - iq/2013
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// Volumetric clouds. It performs level of detail (LOD) for faster rendering
float noise( in vec3 x )
{
vec3 p = floor(x);
vec3 f = fract(x);
f = f*f*(3.0-2.0*f);
@tinybitsofcode
tinybitsofcode / sp-w-cert-azps-1-0.ps1
Created April 10, 2017 17:57 — forked from devigned/sp-w-cert-azps-1-0.ps1
Create a service principal to auth with a certificate in Azure PowerShell 1.0
# Login to Azure PowerShell
Login-AzureRmAccount
# Create the self signed cert
$currentDate = Get-Date
$endDate = $currentDate.AddYears(1)
$notAfter = $endDate.AddYears(1)
$pwd = "P@ssW0rd1"
$thumb = (New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName com.foo.bar -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $notAfter).Thumbprint
$pwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
@tinybitsofcode
tinybitsofcode / DbEntityExceptionProvider.cs
Last active January 11, 2017 14:37
Extract all EntityFramework validation exceptions (usually entity validation errors specified on EF models - e.g. max-length, required)
public class DbEntityExceptionProvider<TEntity> where TEntity: class, IBaseTableEntity
{
public IEnumerable<DbEntityValidationMessage> TryToUnpackDatabaseException(Exception ex)
{
var response = new List<DbEntityValidationMessage>();
var dbException = ex as DbEntityValidationException;
if (dbException != null)
{
@tinybitsofcode
tinybitsofcode / TypeChangesEnumerator.cs
Created January 11, 2017 14:27
For 2 different instances of a Type, get all of the properties that have different values
public class TypeChangesEnumerator<TEntity>
{
public IEnumerable<ObjectPropertyChange> EnumeratePropertyDifferences(TEntity oldObject, TEntity newObject)
{
var properties = typeof(TEntity).GetProperties();
var changes = new List<ObjectPropertyChange>();
foreach (PropertyInfo pi in properties)
{
var value1 = typeof(TEntity).GetProperty(pi.Name).GetValue(oldObject, null);
@tinybitsofcode
tinybitsofcode / GetEnumValuesWithAttribute.cs
Created January 11, 2017 14:23
For a specified Enum type, get the values that have a certain attribute on them
public static IEnumerable<int> GetEnumValuesWithAttribute<T>(Type enumType) where T : Attribute
{
var valuesWithAttribute = new List<int>();
var typeOfAttribute = typeof(T);
foreach (var value in Enum.GetValues(enumType))
{
var fieldInfo = enumType.GetField(value.ToString());
if (fieldInfo.CustomAttributes.Any(a => a.AttributeType == typeOfAttribute))
{
@tinybitsofcode
tinybitsofcode / GetTypesWithAttribute.cs
Created January 11, 2017 14:21
C# code that returns all the types in an Assembly that have a certain attribute attached to them
public static class AssemblyHelpers
{
public static IEnumerable<Type> GetTypesWithAttribute<TAttr>(Assembly assembly) where TAttr : Attribute
{
foreach (Type type in assembly.GetTypes())
{
if (type.GetCustomAttributes(typeof(TAttr), true).Length > 0)
{
yield return type;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Semantic</title>
<link href="lib/semantic.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script src="lib/semantic.js" type="text/javascript"></script>
</head>