Skip to content

Instantly share code, notes, and snippets.

View jonpryor's full-sized avatar

Jonathan Pryor jonpryor

View GitHub Profile
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);
$ 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
/*
## 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
+ 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];

How would I do the equivalent of 'in_dir=s' => \@in_dirs from Perl's Getopt::Long, i.e., a case where --in_dir was used multiple times.

Manually, by capturing values in an intermediate list:

var dirs    = new List<string> ();
var options = new OptionSet {
    { "in_dir=", v => dirs.Add (v) },
};
var unmatched = options.Parse(new[]{

"--in_dir", "A",

diff --git a/Makefile b/Makefile
index b127bed..e5b75ae 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,6 @@ TARGET = bin/hello
# C library
CC = cc
-AR = ar cqs
-CLIB = bin/libhello.a
// Quick-and-dirty (and untested!) port of https://gist.github.com/3169945 to C#
Bitmap DecodeFile (string path)
{
var opts = new BitmapFactory.Options () {
InJustDecodeBounds = true,
};
using (var b = BitmapFactory.DecodeFile (path, opts)) {
// Ignore; we're filling `opts`
}
const int RequiredSize = 70;
void scrim_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
XElement xmlScrim = XElement.Parse(e.Result, LoadOptions.None);
RunOnUiThread(() => {
var scrimresult = FindViewById<EditText>(Resource.Id.result);
scrimresult.Text = xmlScrim.Element("url").Value;
});
}
// nested enum type
using System;
class Test {
public enum Foo {
A
}
static void Main ()
{
using System;
using System.Reflection;
[assembly: AssemblyVersion("2.2.*")]
class Test {
static void Main ()
{
Console.WriteLine ("Version: {0}",
Assembly.GetExecutingAssembly ().GetName ().Version);