This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adding as an authorised user is much the same as getting. Just provide the template and name fields | |
Add-SitecoreItem sitecore.local -user apiuser -pass password -database master ` | |
-name "Awesome new item" -template "Sample/Sample Item" | |
<# | |
totalCount resultCount items StatusCode | |
---------- ----------- ----- ---------- | |
1 1 {@{Database=master; Displa... 200 | |
#> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
function checkboxlimit(checkgroup, limit){ | |
var checkgroup=checkgroup | |
var limit=limit | |
for (var i=0; i<checkgroup.length; i++){ | |
checkgroup[i].onclick=function(){ | |
var checkedcount=0 | |
for (var i=0; i<checkgroup.length; i++) | |
checkedcount+=(checkgroup[i].checked)? 1 : 0 | |
if (checkedcount>limit){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void executeMultipartPost(String url, String imgPath, String field1, String field2){ | |
try { | |
HttpClient client = new DefaultHttpClient(); | |
HttpPost poster = new HttpPost(url); | |
File image = new File(imgPath); //get the actual file from the device | |
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); | |
entity.addPart("field1", new StringBody(field1)); | |
entity.addPart("field2", new StringBody(field2)); | |
entity.addPart("image", new FileBody(image)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sites = Retriever.GetSites(new UserOptions{ Email = "email", Password = "password" }); | |
if (sites != null) | |
{ | |
var primarySite = sites.Single(s => s.IsPrimary); | |
//get posts | |
var posts = Retriever.GetPosts(new PostOptions{SiteId = primarySite.Id, MaxPosts = 50}); | |
//get tags | |
var tags = Retriever.GetTags(new TagOptions { SiteId = primarySite.Id }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Define a Settings model object | |
Properties are defined with getters and setters against the setting object itself. | |
*/ | |
var settings = { | |
implement: function(){ | |
var args = Array.prototype.slice.call(arguments); //take any number of arguments | |
args.forEach(function(name){ | |
if(!this.hasOwnProperty(name)){ //only implement properties not already defined | |
Object.defineProperty(this, name, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
### ### | |
# This script assumes you're kicking things off from a clean install of Ubuntu # | |
# You're welcome to skip parts which you've already installed! # | |
### ### | |
# Required - install curl | |
sudo apt-get install curl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [0, 1, 2, 3, null, undefined, '', "test"]; | |
/* Remove 'falsy' values */ | |
//using the filter method available in Javascript 1.6 | |
var output = arr.filter(function(x){return !!x}); | |
console.log(output)// [1, 2, 3, "test"] | |
//using jQuery grep function | |
var jqOutput = $.grep(arr, function(x){return !!x}); | |
console.log(jqOutput )// [1, 2, 3, "test"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var email = "[email protected]"; | |
var password = "password"; | |
var repo = SharpnoteRepository<Note>.Instance; | |
if (repo.Connect(email, password)) | |
{ | |
//Create a new note | |
//Notes must have content to be saved | |
var note = new Note | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var email = "[email protected]"; | |
var password = "password"; | |
var repo = SharpnoteRepository<Note>.Instance; | |
if (repo.Connect(email, password)) | |
{ | |
repo.GetIndex() | |
.OrderBy(rn => rn.Modified) | |
.ToList() | |
.ForEach(rn => Console.WriteLine(rn.Modified.ToString())); |
NewerOlder