Skip to content

Instantly share code, notes, and snippets.

@darylteo
darylteo / ArrayOrObject.java
Last active November 8, 2022 10:48
Jackson Deserializer based on several StackOverflow posts.
import java.util.List;
@Data
public class ArrayOrObject<T> {
private List<T> data;
private Boolean isObject;
}
@darylteo
darylteo / component.js
Last active October 10, 2016 20:36
Dynamic Component for Ractive with Data propagation on the same level as data source
/*
Extension of the code found at the following SO post
http://stackoverflow.com/questions/31075341/how-to-create-ractives-subcomponents-dynamically-and-change-them-programmatical
*/
let Ractive = require("Ractive");
Ractive.components.dynamic = Ractive.extend({
template: "{{>impl}}",
components: { // you can set whatever components you need, or just use the global ones via Ractive.components },
partials: {
@darylteo
darylteo / spark.js
Created May 24, 2015 07:32
Custom build of Spark IO - accepts http urls for local cloud connections (some errors were annoying and removed for simplicity)
var es6 = require("es6-shim");
var net = require("net");
var Emitter = require("events").EventEmitter;
var https = require("https");
var http = require("http");
var priv = new Map();
var errors = {
cloud: "Unable to connect to spark cloud.",
@darylteo
darylteo / SetParentContentType.sql
Created April 16, 2015 03:39
Stored Procedure T-SQL - Move Document Types in Umbraco 6.2.5
CREATE PROCEDURE SetParentContentType
@childAlias as varchar(MAX),
@parentAlias as varchar(MAX)
AS
BEGIN TRANSACTION;
declare @childId as int;
declare @parentId as int;
SET @childId = (SELECT nodeId FROM cmsContentType WHERE alias = @childAlias);
@darylteo
darylteo / upgrade.ps1
Last active August 29, 2015 14:14
Crazy? Lets write a powerscript to upgrade umbraco for us. (WIP duh, but I ain't creating a whole repo for this)
param(
[string]$version,
[string]$target = ".",
[string]$config,
[string]$sitehost,
[string]$dbhost,
[string]$dbname,
[string]$dbuser,
[string]$dbpass,
@darylteo
darylteo / JarExec.java
Last active August 29, 2015 14:10
JarExec task - supporting execution of Jars (i.e. java -jar). Place in buildSrc/src/main/java/org/gradle/api/tasks/JarExec
/*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
configurations {
jarsIWant
}
dependencies {
jarsIWant ...
}
task copyJarsToWEBINF(type: Sync) {
from configurations.jarsIWant
@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
@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 / 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;