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
import java.util.Random; | |
class r { | |
public static void main(String[] args) { | |
Random x = new Random (); | |
for(int i=0; i<1000; i++) System.out.println(x.nextInt(2)); | |
} | |
} |
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
$ cat ofs.cs | |
using System; | |
using System.Runtime.InteropServices; | |
[StructLayout (LayoutKind.Explicit)] | |
struct Embedded { | |
[FieldOffset (0)] IntPtr b; | |
[FieldOffset (0)] int 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
diff --git a/mono/io-layer/locking.c b/mono/io-layer/locking.c | |
index 57b18ca..eec2549 100644 | |
--- a/mono/io-layer/locking.c | |
+++ b/mono/io-layer/locking.c | |
@@ -34,6 +34,11 @@ _wapi_lock_file_region (int fd, off_t offset, off_t length) | |
struct flock lock_data; | |
int ret; | |
+ if (offset < 0 || length < 0) { | |
+ SetLastError (ERROR_INVALID_PARAMETER); |
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
// "Port"/rewrite of: http://blog.neteril.org/blog/2012/12/17/memory-efficient-bitmap-caching-with-mono-for-android/ | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace Cadenza.IO |
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; | |
class Test { | |
public static void Main () | |
{ | |
var v = Environment.OSVersion; | |
Console.WriteLine (" Platform: {0}", v.Platform); | |
Console.WriteLine (" Service Pack: {0}", v.ServicePack); | |
Console.WriteLine (" Version: {0}", v.Version); | |
Console.WriteLine ("Version String: {0}", v.VersionString); |
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
<?xml version="1.0" encoding="utf-8"?> | |
<ArrayOfItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | |
<Item Completed="true"> | |
<DoItem>fds</DoItem> | |
</Item> | |
<Item Completed="false"> | |
<DoItem>Find</DoItem> | |
</Item> | |
</ArrayOfItem> |
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; | |
namespace Total | |
{ | |
class Total | |
{ | |
static void Main() | |
{ | |
int Total = 0; | |
for (int counter = 0; counter < 10; ++counter) { |
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
$ csharp | |
Mono C# Shell, type "help;" for help | |
Enter statements below. | |
csharp> class X { public int Foo {get;set;} } | |
csharp> var x = typeof(X); | |
csharp> x.GetProperty("Foo").GetGetMethod().IsVirtual; | |
false |
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
// from: http://pastebin.com/Hg8vkNAu | |
// | |
// Suggested improvement: | |
static readonly Dictionary<Type, Func<byte[], object>> Decoders = new Dictionary<Type, Func<byte[], object>>() { | |
{ typeof (string), x => Encoding.UTF8.GetString(x) }, | |
{ typeof (byte[]), x => x }, | |
}; | |
public void Add<T>(string cmd, MessageReceiver<T> receiver) | |
{ |
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
class Memoization<T, TResult> { | |
internal Memoization (Func<T, TResult> f, IDictionary<T, TResult> d) | |
{ | |
Invoke = f; | |
Values = d; | |
} | |
public Func<TResult> Invoke {get; private set;} | |
public IDictionary<T, TResult> Values {get; private set;} |