Skip to content

Instantly share code, notes, and snippets.

View orderResource.js
define(['services/module', 'underscore'], function (module, _) {
'use strict';
function OrderResource($http, $q, link) {
// ... other functions removed: viewState, accessState, flattenResource
// viewState is a deeper resource
// accessState looks at the Accept headers
// flattenResource: flattens all of this for the client-side resource (in-memory model bound to view)
@toddb
toddb / markdown.gradle
Created Jun 5, 2012
Markdown script for usage of PegDown - converts md files into html
View markdown.gradle
/*
* Adapted from https://raw.github.com/geb/geb-seconf-2012-slides/master/buildSrc/pegdown/src/main/groovy/org/gradle/plugins/pegdown/PegDown.groovy
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
@toddb
toddb / userDefineLang_Gradle.xml
Created Jun 4, 2012
Gradle language for Notepad++
View userDefineLang_Gradle.xml
<NotepadPlus>
<UserLang name="Gradle" ext="gradle">
<Settings>
<Global caseIgnored="yes" />
<TreatAsSymbol comment="yes" commentLine="yes" />
<Prefix words1="no" words2="no" words3="no" words4="no" />
</Settings>
<KeywordLists>
<Keywords name="Delimiters">&quot;&apos;0&quot;&apos;0</Keywords>
<Keywords name="Folder+"></Keywords>
@toddb
toddb / changelog.gradle
Created Jun 3, 2012
Gradle integration to SVN to generate CHANGELOG from svn log (integration via svnkit)
View changelog.gradle
/*
task changeLog(type: ReleaseNotes){
destFile file("CHANGELOG-DJANGO-SAMPLE")
url "http://django-page-cms.googlecode.com/svn/trunk/"
}
# gradle changeLog
Creates output (first entry only shown):
@toddb
toddb / jasmine_extensions.js
Created Apr 11, 2012 — forked from esbie/jasmine_extensions.js
Jasmine spy syntactic sugar for dealing with success/error callbacks (aka jQuery.ajax)
View jasmine_extensions.js
/**
* An extension that always calls success when a spy is called.
*
* @example
* spyOn(foo, 'bar').andCallSuccessWith("baz");
* var options = {
* success: jasmine.createSpy();
* }
* foo.bar(options);
* expect(options.success).toBeCalledWith("baz");
@toddb
toddb / teamcity.pp
Created Mar 20, 2012
Puppet Teamcity script - straightforward, non-modularised & procedural
View teamcity.pp
class teamcity {
@package{ [ "java-1.6.0-openjdk", "wget", "tar", "gzip" ]:
ensure => installed,
}
$src="http://download.jetbrains.com/teamcity/TeamCity-7.0.tar.gz"
$username="teamcity"
$installdir="/opt"
@toddb
toddb / gist:1474205
Created Dec 13, 2011 — forked from mathieul/gist:966776
Require files using RequireJS before running Jasmine specs
View gist:1474205
/**
* @license Copyright (c) 2012, toddb GoneOpen Limited.
* Available via the MIT or new BSD license.
* based on https://gist.github.com/966776 (mathieul) and forked to https://gist.github.com/1474205
* jasmine.requirejs() returns a function that will load the file(s) required
* and will wait until it's done before proceeding with running specs.
* The function returned is intended to be passed to beforeEach() so the file(s)
* is(are) loaded before running each spec.
*
@toddb
toddb / update-host.psake.ps1
Created Aug 10, 2011
Update host file in psake
View update-host.psake.ps1
Property {
$domain = ""
}
Task Hostfile-Update -Description "Add new sites to the host file" {
$host_file = "$env:windir\System32\drivers\etc\hosts"
if ((Get-Content $host_file | ForEach-Object{$_ -eq "127.0.0.1 $domain "}) -notcontains "True")
{
Add-Content $host_file "`n127.0.0.1 $domain "
}
@toddb
toddb / db-setup.psake.ps1
Created Aug 10, 2011
Use sql script for sharepoint in psake
View db-setup.psake.ps1
Task Db-Setup -Description "Adds the current user for access to SharePoint schemas - DEV only" {
$userToAdd = Read-Host -Prompt 'User to add to Farm Admin group <DOMAIN>\<USERNAME>'
$db_env = Read-Host -Prompt 'Environment suffix of the database to setup'
Write-Host "If this script has a problem then you don't have login access - please sort this out first"
Write-Host "see http://www.sharepointassist.com/2010/01/29/the-local-farm-is-not-accessible-cmdlets-with-featuredependencyid-are-not-registered/"
$whoami = [Environment]::UserName
Write-Host "Adding dev user to database: $whoami"
Write-Host "Enter the password for the user $site_owner"
exec { sqlcmd -i .\dev-powershell-access.sql -U $whoami -v user=$userToAdd -v db_env=$db_env }
@toddb
toddb / adminuser-setup-psake.ps1
Created Aug 10, 2011
Admin user setup in Sharepoint power psake
View adminuser-setup-psake.ps1
Properties {
$site_owner = "domain\serviceaccount"
$ca_port = 3456
}
Task AdminUser-Setup -Depends Solution-Setup -Description "Sets the current user as a farm admin on current computer" {
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
$whoami = [Security.Principal.WindowsIdentity]::GetCurrent().Name
Write-Host "You are logged in as $whoami"