Skip to content

Instantly share code, notes, and snippets.

View jonpryor's full-sized avatar

Jonathan Pryor jonpryor

View GitHub Profile
+ public static Group [] getgrouplist (string username)
+ {
+ // Syscall to getpwnam to retrieve user uid
+ Passwd pw = Syscall.getpwnam (username);
+ if (pw == null)
+ return new Group [0];
+ // initialising the lngroups by 1 to get the group count
+ int ngroups = 1;
+ // allocating buffer to store group uid's
+ uint [] groups = new uint [ngroups];
/*
## Mono JIT compiler version 2.10.9 (tarball Mon May 7 20:25:51 EDT 2012)
DynamicMethod creation: 0.0453009000ms
LINQ expressions creation: 0.0971724000ms
Delegate creation: 0.0044351000ms
DynamicMethod invocation: 0.0000612000ms
Expression invocation: 0.0000609000ms
MethodInfo invocation: 0.0007135000ms
Delegate invocation: 0.0000619000ms
$ adb shell pm list packages Scratch. | cut -c 9-
Scratch.AlertDialog
Scratch.AndroidSpecificLocale
Scratch.Deadlock
Scratch.DefaultTemplate
Scratch.ExceptionPropogation
Scratch.ExpandableListActivity
Scratch.FieldSetLrefOverflow
Scratch.Hello
Scratch.HttpsDownload
int
Mono_Posix_Syscall_syslog (int priority, const char* message)
{
#ifdef __GCC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Werror=format-security"
#endif
syslog (priority, message);
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;}
// 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)
{
$ 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
using System;
namespace Total
{
class Total
{
static void Main()
{
int Total = 0;
for (int counter = 0; counter < 10; ++counter) {
<?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;
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);