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
#include <iostream> | |
template <int n> struct Fib | |
{ | |
enum { val = Fib<n - 1>::val + Fib<n - 2>::val }; | |
}; | |
template<> struct Fib<0> { enum { val = 0 }; }; | |
template<> struct Fib<1> { enum { val = 1 }; }; |
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
std::string text = ""; | |
std::string line; | |
while (std::getline(std::cin, line)) | |
{ | |
text = text + line + "\r\n"; | |
} |
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
/* | |
Code convention summary: | |
- don't use underscores '_' (except in constants) | |
- lines should not be longer than 100 symbols | |
- indent using EITHER ALWAYS 4 spaces OR ALWAYS Tabs. Don't mix tabs and spaces. | |
*/ | |
#include <string> | |
// Declaration and implementation should be split into "CompanyWorkers.h" and "CompanyWorkers.cpp" files. |
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; | |
// Example from acticle by Eric Lippert http://blogs.msdn.com/b/ericlippert/archive/2011/03/17/implementing-the-virtual-method-pattern-in-c-part-one.aspx | |
namespace VirtualMethodsImplementation | |
{ | |
internal sealed class VTable | |
{ | |
public readonly Func<Animal, string> Complain; | |
public readonly Func<Animal, string> MakeNoise; |
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
let stringPermutations (s : string) = | |
let rec permute result rest = | |
match rest with | |
| "" -> [result] | |
| _ -> | |
rest | |
|> Seq.mapi (fun i -> fun c -> | |
permute (result + c.ToString()) (rest.Remove(i, 1))) | |
|> Seq.concat | |
|> Seq.toList |
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
$f = New-Object System.IO.FileStream d:\temp\50MB-file.dat, Create, ReadWrite | |
$f.SetLength(50MB) | |
$f.Close() |
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.Runtime.InteropServices; | |
namespace Application | |
{ | |
public class ConsoleUtils | |
{ | |
[DllImport("kernel32.dll", EntryPoint = "AllocConsole", CharSet = CharSet.Unicode)] | |
public static extern bool AllocConsole(); | |
} | |
} |