Skip to content

Instantly share code, notes, and snippets.

View jonpryor's full-sized avatar

Jonathan Pryor jonpryor

View GitHub Profile
@jonpryor
jonpryor / gist:4635021
Last active December 11, 2015 17:29 — forked from anonymous/gist:4635005
static readonly IList<ViewModel> registeredEntities = new List<ViewModel>();
protected static IList<ViewModel> RegisteredViewModels
{
get
{
return registeredEntities;
}
}
diff --git a/PluginExample/Program.cs b/PluginExample/Program.cs
index 7d45ae6..1e320f5 100644
--- a/PluginExample/Program.cs
+++ b/PluginExample/Program.cs
@@ -1,5 +1,6 @@
using System;
using System.Net;
+using System.IO;
using System.Security;
using System.Security.Permissions;
$ csharp
using SyMono C# Shell, type "help;" for help
Enter statements below.
csharp> using System.Text.RegularExpressions;
csharp> var r = new Regex (@"^\s*(?<name>[A-Za-z0-9_]+)\s*=\s*(?<value>[^\s]+)\s*;");
csharp> var m = r.Match ("Foo = Bar;");
csharp> m.Success;
true
csharp> var name = m.Groups ["name"].Value;
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));
}
}
$ cat ofs.cs
using System;
using System.Runtime.InteropServices;
[StructLayout (LayoutKind.Explicit)]
struct Embedded {
[FieldOffset (0)] IntPtr b;
[FieldOffset (0)] int c;
}
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);
@jonpryor
jonpryor / DiskCache.cs
Last active December 10, 2015 08:19
File system abstraction for use in PCL apps. `FileSystemOperations.cs` is usable in a PCL library that targets .NET 4.5 and .NET for Windows Store Apps. (Yes, this is _crazy_, but .NET 4.5 is required to access `System.IO.StreamWriter` (!) and other useful `System.IO` types. (Seriously, we need to target .NET 4.5 to use types present in .NET 1.0…
// "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
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);
<?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>
using System;
namespace Total
{
class Total
{
static void Main()
{
int Total = 0;
for (int counter = 0; counter < 10; ++counter) {