Skip to content

Instantly share code, notes, and snippets.

@darylteo
darylteo / build.gradle
Last active August 29, 2015 13:56
Working with a task created by maven-publish pulication.
apply plugin: 'java'
apply plugin: 'maven-publish'
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
task dummy << {
<div class="datagrid_hack"></div>
<script>
(function ($) {
// check so that this code only fires once.
if ($._datagridHack) {
return;
}
$._datagridHack = function () {
var root = $('.datagrid_hack');
@darylteo
darylteo / update.sql
Created March 6, 2014 07:01
Rebuild Umbraco's level/node structure after modifying parentids. Needs a better recursive union. This example only works with content types specifically.
WITH CT AS (
SELECT *
FROM umbracoNode
WHERE (nodeObjectType = 'A2CB7800-F571-4787-9638-BC48539A0EFB')
),
L1 AS (
SELECT *, 1 'NewLevel', CAST(parentID as varchar) + ',' + CAST(id as varchar) 'NewPath'
FROM CT
WHERE parentID = -1
), L2 AS (
@darylteo
darylteo / build.gradle
Created March 30, 2014 09:51
Detecting if a dependency is valid in Gradle
def doesModuleExist(def notation) {
try {
def dep = project.dependencies.create(notation)
def conf = project.configurations.detachedConfiguration(dep)
// force resolution
def files = conf.files
} catch (Exception e) {
e.printStackTrace()
return false
repositories {
mavenCentral()
}
apply plugin:'java'
configurations {
metamodel
validator
processor
2
3
5
7
11
13
17
19
23
29
@darylteo
darylteo / NinjectWebCommon.cs
Created July 5, 2014 08:04
Ninject injection into Signalr Hubs with ninject.mvc5.
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Ascend.Core.Application.App_Start.NinjectWebCommon), "Start")]
[assembly: WebActivatorEx.ApplicationShutdownMethodAttribute(typeof(Ascend.Core.Application.App_Start.NinjectWebCommon), "Stop")]
namespace Ascend.Core.Application.App_Start
{
using System;
using System.Linq;
using System.Web;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
@darylteo
darylteo / SSHPlugin.java
Last active August 29, 2015 14:04
Simple Plugin in Java for Gradle
package org.company.gradle;
import groovy.lang.Closure;
import groovy.lang.MissingMethodException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import java.util.HashMap;
import java.util.Map;
@darylteo
darylteo / anything.groovy
Last active August 29, 2015 14:05
A Map + Expando implementation for Groovy
import groovy.json.*;
class MyBean extends Expando {
def methodMissing(String name, def args) {
if(args.size() == 0) {
super.getProperty(name)
} else if(args.size() == 1) {
def value = args[0];
def result = value;
@darylteo
darylteo / build.gradle
Last active August 29, 2015 14:10
Configuration Extensions
configurations {
war_common
war_secure
mwar
pwar
swar
uwar
mwar.extendsFrom war_common