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
#include<limits.h> | |
#include<stdlib.h> | |
#include<stdio.h> | |
int f1(int num) | |
{ | |
const int result = abs(num) - num; | |
return result; | |
} |
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
// Steven Toub wrote this in https://github.com/dotnet/corefx/issues/1793#issuecomment-151584410 | |
// I have made only minor changes. | |
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Net; | |
using System.Net.Sockets; | |
using System.Threading.Tasks; |
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
var a = BitConverter.Int64BitsToDouble(BitConverter.ToInt64(BitConverter.GetBytes(0xFFF8000000000000), 0)); | |
var b = BitConverter.Int64BitsToDouble(BitConverter.ToInt64(BitConverter.GetBytes(0xFFF8000000000001), 0)); | |
Console.WriteLine(a == b); | |
Console.WriteLine(a.Equals(b)); | |
Console.WriteLine(a.Equals((object)b)); |
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
#define WIN32_LEAN_AND_MEAN | |
#define NOGDICAPMASKS | |
#define NOVIRTUALKEYCODES | |
#define NOWINMESSAGES | |
#define NOWINSTYLES | |
#define NOSYSMETRICS | |
#define NOMENUS | |
#define NOICONS | |
#define NOKEYSTATES | |
#define NOSYSCOMMANDS |
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
#include "vec.h" | |
int main(void) { | |
Vec* vec = vec_new(); | |
//vec is a pointer to a struct of an unknown type | |
//so the compiler will not allow bugs 6 and 7 to occur. | |
vec_push(vec, 107); | |
vec_push(vec, 110); | |
vec_free(vec); | |
} |
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
iolanthe:smhasher dbremner$ cd build | |
iolanthe:build dbremner$ ./SMHasher pearson_hash | |
------------------------------------------------------------------------------- | |
--- Testing pearson_hash "http://calypsosfarewell.blogspot.com/2018/01/toy-code-hand-crafting-good-hash.html" | |
[[[ Sanity Tests ]]] | |
Verification value 0x5AA86F6C : PASS | |
Running sanity check 1 ..........PASS | |
Running AppendedZeroesTest..........PASS |
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
#pragma once | |
template<class T, T InvalidValue = nullptr> | |
struct HandleTraitsBase | |
{ | |
using Type = T; | |
inline static Type GetInvalidValue() noexcept | |
{ | |
return InvalidValue; | |
} |
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
template<class T, T invalid_value=nullptr> | |
struct handle_traits_base | |
{ | |
using pointer = T; | |
inline static pointer invalid() throw() | |
{ | |
return invalid_value; | |
} | |
}; |
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
//taken from https://resharper-support.jetbrains.com/hc/en-us/community/posts/206650785-Can-I-handle-not-initialized-warnings-with-Jetbrains-Annotations- | |
[ContractAnnotation("=> false, target:null; => true, target:notnull")] | |
private bool TryFindWorkbook([NotNull] Excel.Workbooks workbooks, [CanBeNull] out Excel.Workbook target) | |
{ | |
Requires.NotNull(workbooks, nameof(workbooks)); | |
foreach (Excel.Workbook workbook in workbooks) | |
{ | |
if (workbook.Name == cellLocation.WorkBookName) | |
{ |
NewerOlder