Skip to content

Instantly share code, notes, and snippets.

View Kieranties's full-sized avatar
🤘

Kieranties Kieranties

🤘
View GitHub Profile
@Kieranties
Kieranties / Copy-ItemWithPath
Last active August 29, 2015 13:56
Copy-ItemWithPath - Copy files while retaining a folder structure
Function Copy-ItemWithPath {
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[Alias("FullName")]
[string[]]$item,
[Parameter(Mandatory=$true, Position=1)]
[string]$destination,
[Parameter(Mandatory=$true, Position=2)]
[string]$root
)
@Kieranties
Kieranties / Install-IEVM.psm1
Last active August 29, 2015 14:05
Quick and dirty function to download VMs from http://Modern.ie and trigger extraction
<#
.EXAMPLE
Get the "Batch File Download" address for the (Hyper-V) VM of your choice from https://modern.ie/en-gb/virtualization-tools#downloads
PS> $source = "https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/HyperV_2012/IE11/Windows/IE11.Win7.For.Windows.HyperV_2012.txt"
PS> $destination = (mkdir "$env:USERPROFILE\downloads\vms" -Force) # or use default
PS> Install-IEVM $source $destination -import # Will import to default locations
#>
Function Install-IEVM {
param(
[Parameter(Mandatory=$true)]
@Kieranties
Kieranties / vnextTest.ps1
Created April 8, 2015 14:46
Test availability of vNext package
$feedStub = "http://www.myget.org/F/{0}/api/v2/FindPackagesById()?Id='{1}'"
$package = "Microsoft.Framework.Runtime.Roslyn"
$feeds = @("aspnetmaster", "aspnetvnext")
$feeds | % { Invoke-RestMethod -uri ($feedStub -f $_, $package) } | select -ExpandProperty properties | select version
<#
Output
Version
-------
@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()));
@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 / 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 / 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 / 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 / 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 / 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){