Skip to content

Instantly share code, notes, and snippets.

@Pablissimo
Pablissimo / gist:4658214
Created January 28, 2013 19:18
Mucking about with .NET in 10 spare minutes to emulate some of sometimes.rb's functionality in a horribly non-.NET way
using System;
namespace Sometimes
{
class Program
{
static void Main(string[] args)
{
// Farting about with a .NET-esque toy version of sometimes.rb...
5.To(10).Times(() => Console.WriteLine("This'll get annoying"));
@Pablissimo
Pablissimo / gist:5362966
Created April 11, 2013 12:23
Quick and dirty proxying of CloudTable
public class CloudTableProxy
{
CloudTable _table;
public CloudTableProxy(CloudTable table)
{
_table = table;
}
public virtual string Name { get { return _table.Name; } }
@Pablissimo
Pablissimo / DataMemberAwareEnumJsonConverter
Created July 31, 2013 15:51
A JsonConverter (for Newtonsoft's JSON.NET) that respects the Name property of DataMember attributes applied to enumeration members, falling back to the enumeration member name where no DataMember attribute exists (or where a name has not been supplied)
/// <summary>
/// A JsonConverter that respects the Name property of DataMember attributes
/// applied to enumeration members, falling back to the enumeration member
/// name where no DataMember attribute exists (or where a name has not
/// been supplied). Entirely experimental, use at your own risk.
///
/// Paul O'Neill, paul@pablissimo.com, 31/07/13
/// </summary>
public class DataMemberAwareEnumJsonConverter : JsonConverter
{
@Pablissimo
Pablissimo / DataMemberAwareEnumJsonConverter
Created July 31, 2013 15:51
A JsonConverter (for Newtonsoft's JSON.NET) that respects the Name property of DataMember attributes applied to enumeration members, falling back to the enumeration member name where no DataMember attribute exists (or where a name has not been supplied)
/// <summary>
/// A JsonConverter that respects the Name property of DataMember attributes
/// applied to enumeration members, falling back to the enumeration member
/// name where no DataMember attribute exists (or where a name has not
/// been supplied). Entirely experimental, use at your own risk.
///
/// Paul O'Neill, paul@pablissimo.com, 31/07/13
/// </summary>
public class DataMemberAwareEnumJsonConverter : JsonConverter
{
require_once('/var/www/resources/MiiCard/miiCard.Consumers/miiCard.Consumers.php');
if (session_id() == "")
{
session_start();
}
$miiCardObj = new Consumers\MiiCard(MIICARD_CONSUMER_KEY, MIICARD_CONSUMER_SECRET, null, null, null, MIICARD_FORCE_CLAIMS, MIICARD_SIGNUP_MODE);
if ($miiCardObj->isAuthorisationCallback())
{
@Pablissimo
Pablissimo / build.log
Created August 14, 2016 13:54
Chutzpah build failure
psake version 4.2.0
Copyright (c) 2010 James Kovacs
Executing Clean-Solution-NoVS
Microsoft (R) Build Engine version 4.6.1586.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Executing Build-Solution-NoVS
Microsoft (R) Build Engine version 4.6.1586.0
@Pablissimo
Pablissimo / minecraft.cypher
Created July 29, 2019 12:10
Cypher script for creating an initial Neo4j graph database representing the Minecraft crafting and forging recipe book
MERGE (n:Resource{name:"Wooden Plank"});
MERGE (n:Resource{name:"Stick"});
MERGE (n:Resource{name:"Torch"});
MERGE (n:Resource{name:"Crafting Table"});
MERGE (n:Resource{name:"Furnace"});
MERGE (n:Resource{name:"Chest"});
MERGE (n:Resource{name:"Wood Pickaxe"});
MERGE (n:Resource{name:"Stone Pickaxe"});
MERGE (n:Resource{name:"Iron Pickaxe"});
MERGE (n:Resource{name:"Gold Pickaxe"});
MATCH (movie: Movie { title: 'Top Gun' })<-[acted_in: ACTED_IN]-(actor: Person)
WITH collect(distinct actor) + movie as nodes, collect(distinct acted_in) as relationships
CALL apoc.export.csv.data(nodes, [], 'nodes.csv', {}) YIELD file as nodefile
UNWIND relationships as relationship
CALL apoc.create.vRelationship(startNode(relationship), type(relationship), { title: relationship.title }, endNode(relationship)) YIELD rel
WITH collect(rel) as relationshipsAmended, nodefile
CALL apoc.export.csv.data([], relationshipsAmended, 'edges.csv', {}) YIELD file as edgefile
RETURN edgefile, nodefile
@Pablissimo
Pablissimo / out.txt
Created August 8, 2019 11:20
Example output of a cypher-shell call with --format verbose for SO question https://stackoverflow.com/questions/56899593/redirect-neo4j-profiling-output-to-file
+---+
| n |
+---+
+---+
+----------------------------------------------------------------------+| Plan | Statement | Version | Planner | Runtime | Time |+----------------------------------------------------------------------+| "EXPLAIN" | "READ_ONLY" | "CYPHER 3.5" | "COST" | "COMPILED" | 1 |+----------------------------------------------------------------------+
+------------------+----------------+-------------+-------+
| Operator | Estimated Rows | Identifiers | Other |
+------------------+----------------+-------------+-------+
@Pablissimo
Pablissimo / minecraft-with-recipes.cypher
Last active November 13, 2022 06:20
Cypher script for creating an initial Neo4j graph database representing the Minecraft crafting and forging recipe book where Recipes are their own nodes with relevant output quantities
MERGE (n:Resource{name:"Wooden Plank"});
MERGE (n:Resource{name:"Stick"});
MERGE (n:Resource{name:"Torch"});
MERGE (n:Resource{name:"Crafting Table"});
MERGE (n:Resource{name:"Furnace"});
MERGE (n:Resource{name:"Chest"});
MERGE (n:Resource{name:"Wood Pickaxe"});
MERGE (n:Resource{name:"Stone Pickaxe"});
MERGE (n:Resource{name:"Iron Pickaxe"});
MERGE (n:Resource{name:"Gold Pickaxe"});