Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Kieranties's full-sized avatar
🤘

Kieranties Kieranties

🤘
View GitHub Profile
@Kieranties
Kieranties / Add-SitecoreItem.ps1
Last active December 14, 2015 08:39
Using PSSitecoreItemWebAPI
# 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
#>
@Kieranties
Kieranties / gist:2924879
Created June 13, 2012 15:42
TabChoices
<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){
@Kieranties
Kieranties / httpclient.java
Created March 28, 2012 10:44
Using HttpClient with MultipartEntity in Android
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));
@Kieranties
Kieranties / gist:2028241
Created March 13, 2012 11:31
Using PostLib
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 });
}
@Kieranties
Kieranties / storage.js
Created November 20, 2011 13:14
A Simple LocalStorage Model
/*
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, {
@Kieranties
Kieranties / clean_install_node.sh
Created August 8, 2011 14:15
Installing Node on Ubuntu
#! /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
@Kieranties
Kieranties / arrayFilter.js
Created July 6, 2011 11:34
Filtering an array using Javascript 1.6 or jQuery
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"]
@Kieranties
Kieranties / gist:703880
Created November 17, 2010 19:18
Using Sharpnote.net to connect to Simplenote and create some notes
var email = "user@example.com";
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
{
@Kieranties
Kieranties / gist:663161
Created November 4, 2010 20:47
Using Sharpnote.net to connect to Simplenote and return notes from the index
var email = "user@example.com";
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()));