Skip to content

Instantly share code, notes, and snippets.

View zgramana's full-sized avatar

Zachary Gramana zgramana

View GitHub Profile
@zgramana
zgramana / gist:1323909
Created October 29, 2011 00:25
Code snippet for Spawning Threads Using Selectors With Multiple Parameters
/* Copyright (c) 2011 Zachary J. Gramana
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
@zgramana
zgramana / hashalbum.js
Created January 24, 2012 14:00
hashalbum widget
/*!
* jQuery JavaScript Library v1.4.1
* http://jquery.com/
*
*
* Includes Sizzle.js
* http://sizzlejs.com/
* Copyright 2010, The Dojo Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining
@zgramana
zgramana / ShingleFilter.cs
Created August 10, 2012 19:36 — forked from jenwilson/ShingleFilter.cs
ShingleFilter class in Lucene.Net - This version is not complete.
/**
* ShingleFilter class for Lucene.Net C# ported from Java version 2.9.2 org.apache.lucene.analysis.shingle.ShingleFilter.java
* [Last updated: 07-16-2011]
*
* This version of the file is not complete. It produces System.SystemException: System.NullReferenceException when run.
*
* System.NullReferenceException: Object reference not set to an instance of an object.
* at LuceneIndexer.ShingleFilter.FillShingleBuffer() in C:\Users\..\ShingleFilter.cs:line 381 *
*
*
@zgramana
zgramana / gist:3352238
Created August 14, 2012 19:50
Eager loading Lucene.Net docs
// Only load the fields that the query asks for.
// The Lucene.Net signature for this is wonky, as
// Java Lucene takes a Set<String>. As a result,
// we are obliged to create this hashtable where
// the keys == values.
var loadFields = new Hashtable();
foreach (var fieldName in request.ResultFields)
{
loadFields.Add(fieldName, fieldName);
@zgramana
zgramana / phpunit.bat
Created September 27, 2012 16:50
Temporary workaround for using NetBeans 7.2 with PHPUnit 3.7.1.
@echo off
REM PHPUnit
REM
REM Copyright (c) 2002-2010, Sebastian Bergmann <[email protected]>.
REM All rights reserved.
REM
REM Redistribution and use in source and binary forms, with or without
REM modification, are permitted provided that the following conditions
REM are met:
@zgramana
zgramana / Action.cs
Created May 21, 2013 21:11
Compares the difference between Action<T> and Func<T,bool> where we ignore the return value.
using System;
public static class Program
{
public static void Main(string[] args)
{
var m = new Action<int>(i => Console.WriteLine(i.ToString()));
m(5);
}
}
@zgramana
zgramana / make_copy_ctor.cs
Last active December 18, 2015 03:19
makes copy ctor
// References:
// - MyPreviouslyAdded.dll
// - MyGacced.dll
// Imports:
// - My.Namespace.Bitches
// - My.Other.Namespace
P("public Version(Version item)");
P("{");
var t = typeof(Version);
var props = t.GetProperties();
@zgramana
zgramana / ToNSDictionary.cs
Created October 2, 2013 20:33
Quick n dirty function to convert a System.Json.JsonValue to an NSDictionary.
using System.Json;
...
var response = "{ \"foo\": \"bar\" }";
var jsonValue = JsonValue.Parse (response) as JsonObject;
// Split the lambda declaration and initialization
// so that we can do recursion;
Func<JsonValue, NSDictionary> toNSDictionary;
toNSDictionary = (obj)=> {
If you want to debug your Xamarin app using LLDB to get a backtrace, then do the following:
1) Clone https://github.com/zgramana/ios-deploy (or download https://www.dropbox.com/s/8fl1t1qc5fdg5tn/ios-deploy)
2) Run `make` inside that folder.
3) Run `./ios-deploy -d -b path/to/bin/iPhone/Debug/MyFoo.app`
This will install your app and start it will lldb attached.
From the lldb prompt:
@zgramana
zgramana / gist:8362306
Created January 10, 2014 20:49
Selected MonoDevelope/Xamarin Studio ProjectTypeGuids.
<DotNetProjectSubtype
guid="{e613f3a2-fe9c-494f-b74e-f63bcb86fea6}"
type="MonoDevelop.IPhone.IPhoneProject"
migrationHandler="MonoDevelop.IPhone.IPhoneProjectMigrationHandler" />
<DotNetProjectSubtype
guid="{6bc8ed88-2882-458c-8e55-dfd12b67127b}"
type="MonoDevelop.IPhone.IPhoneProject" />
<DotNetProjectSubtype
guid="{f5b4f3bc-b597-4e2b-b552-ef5d8a32436f}"
type="MonoDevelop.IPhone.IPhoneBindingProject"