Skip to content

Instantly share code, notes, and snippets.

@aranm
aranm / gist:1406610
Created November 29, 2011 21:34
iOS AudioSession Getting all USB Audio Ouputs
/* print a CFNumber */
void printCfNumber(CFNumberRef cfNum) {
SInt32 s;
if(!CFNumberGetValue(cfNum, kCFNumberSInt32Type, &s)) {
printf("***CFNumber overflow***");
return;
}
printf("%d", (int)s);
}
@aranm
aranm / gist:3916122
Created October 19, 2012 03:48
Require Config with jQuery
require.config({
paths: {
//3rd Party libraries
'knockout': 'knockout-2.2.0.debug',
'jquery': 'jquery-1.7.1',
'doubletap': 'jquery.doubletap',
'address': 'jquery.address-1.4.min',
'bootstrap': 'bootstrap-2.0.1',
'amplify': 'amplify',
'JQueryDictionary": "Utilities/JQueryDictionary',
@aranm
aranm / gist:5410239
Created April 18, 2013 04:57
Render a partial razor view to a string. Can't remember where this code came from originally (it isn't mine)
private static string RenderPartialViewToString(Controller controller, string pathToView, object viewModel,
ViewDataDictionary viewData = null) {
String result;
var viewEngine = ViewEngines.Engines.FindPartialView(controller.ControllerContext, pathToView);
using (var writer = new StringWriter()) {
var vd = viewData == null ? new ViewDataDictionary(viewModel)
: new ViewDataDictionary(viewData) { Model = viewModel };
var viewContext = new ViewContext(controller.ControllerContext,
viewEngine.View,
@aranm
aranm / gist:5428332
Created April 21, 2013 03:20
Make sure that you respond to notifications on the main thread
- (void)respondToNotification:(NSNotification *)notification {
if (![NSThread isMainThread]) {
[self performSelectorOnMainThread:@selector(respondToNotification:) withObject:notification waitUntilDone:YES];
return;
}
//Code here
}
@aranm
aranm / Gradient-Bubbles-on-Canvas.markdown
Created September 27, 2013 05:38
A Pen by Aran Mulholland.
var events = require('events');
function callSomething(){
var eventEmitter = new events.EventEmitter();
console.log("Method called");
eventEmitter.emit("data", "Hello immediately (you will never see this message)");

How to create a GraphGist

You create a GraphGist by creating a GitHub Gist in AsciiDoc and enter the URL to it in the form on this page. Alternatively, you can put an AsciiDoc document in Dropbox and enter the public URL in the form.

This GraphGist shows the basics of using AsciiDoc syntax and a few additions for GraphGists. The additions are entered as comments on their own line. They are: //console for a query console; //hide, //setup and //output to configure a query; //graph and //table to visualize queries and show a result table.

Click on the Page Source button in the menu to see the source for this GraphGist.

= The Feed is King (or Queen)
When creating a social network type application the feed is king, the most common query that will be run against your service will be a request to get the feed. There are of course many ways to model the feed and a couple of components that are required.
To do a very simple feed one might structure the data as follows:
Users follow other users
[cypher]
----
@aranm
aranm / Install PHP 5.3 on Ubuntu 14.04(trusty)
Created January 10, 2019 08:00 — forked from arbabnazar/Install PHP 5.3 on Ubuntu 14.04(trusty)
How to install PHP 5.3 on Ubuntu 14.04
#Add the Ubuntu 12.04(precise) repositories
cat <<EOF >> /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu precise main restricted universe
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
EOF
# Update the repos
apt-get update
@aranm
aranm / functions.cs
Last active August 6, 2019 06:27
Azure Functions with DI'd Application Settings
public class MyFunctions
{
private readonly IOptions<ApplicationSettings> _applicationSettingsOptions;
private readonly IOptions<ConnectionStrings> _connectionStringsOptions;
public MyFunctions(IOptions<ApplicationSettings> applicationSettingsOptions, IOptions<ConnectionStrings> connectionStringsOptions)
{
// the "Values" section of the configuration file
_applicationSettingsOptions = applicationSettingsOptions;