Skip to content

Instantly share code, notes, and snippets.

View seank-com's full-sized avatar

Sean Kelly seank-com

View GitHub Profile
@seank-com
seank-com / createAndSaveCompositeImage.js
Last active June 23, 2017 16:19
Create a composite image of all the visible img tags in the DOM and save it to the app data directory of a Windows 8 Application
function SaveSplash() {
window.msWriteProfilerMark("start-render");
var body = document.body,
appdata = Windows.Storage.ApplicationData.current,
localfolder = appdata.localFolder,
canvas = document.createElement("canvas"),
ctx = canvas.getContext("2d"),
imgs = document.body.getElementsByTagName("img"),
@seank-com
seank-com / saveHTMLWithEmbeddedImgTags.js
Last active June 23, 2017 16:17
Update HTML by embedding visible img tags with base64 encoded data URIs then saving it to the app data directory of a Windows 8 Application
function EncodePngBase64(arr) {
var map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
result = "data:image/png;base64,",
size = arr.length,
b1 = 0, b2 = 0, b3 = 0, enc1, enc2, enc3, enc4, i;
for(i = 0; i < size; i += 3) {
b1 = arr[i];
b2 = arr[i + 1] || 0;
@seank-com
seank-com / saveCanvasBitmapsToFiles.js
Last active October 8, 2015 08:37
Save visible image tags to app data directory then update HTML with ms-appdata uris and save HTML to app data directory.
function SaveImage(strm, localfolder, filename) {
return localfolder.createFileAsync(filename, Windows.Storage.CreationCollisionOption.replaceExisting).then(function (file) {
return file.openAsync(Windows.Storage.FileAccessMode.readWrite);
}).then(function (ras) {
var os = ras.getOutputStreamAt(0),
is = strm.getInputStreamAt(0);
return Windows.Storage.Streams.RandomAccessStream.copyAndCloseAsync(is, os);
});
}
@seank-com
seank-com / AttachedDependencyPropertySample.cpp
Last active October 12, 2015 15:47
Xaml Attached Dependency Property
// Usage in Xaml
//
// <FlipView UpdateOnChange.VisualState="{Binding Path=VisualState}">
//
//
// Header File
#pragma once
@seank-com
seank-com / XMLDOMNodeHelper.cpp
Last active January 3, 2016 04:19
A friend of mine found himself working with IXMLDOMNodeList a bit and was writing out the same iteration code several times long length = 0; ChkHr(list->get_length(&length); for (int index = 0; index < length; index++) { ComPtr<IXMLDOMNode> element; ChkHr(list->get_item(index, &element)); ... } He started to miss range based for loops like this.…
class XmlDomNodeListIterator
{
public:
XmlDomNodeListIterator(_In_ IXMLDOMNodeList* list, long index)
: _list(list), _index(index)
{}
ComPtr<IXMLDOMNode> operator*() const
{
@seank-com
seank-com / assignment.cpp
Last active August 29, 2015 14:09
Calculate all shortest paths from one coordinate to the other
#include <stdio.h>
#include <tchar.h>
#include <vector>
#include <string>
#include <math.h>
#include <iostream>
using namespace std;
@seank-com
seank-com / create-and-attach-vhd
Created March 15, 2016 01:41
Create and Attach a VHD using DiskPart
REM
REM Use this script to create and attach a VHD by executing diskpart likeso
REM
REM DiskPart /s create-and-attach-vhd
REM
REM This script creates a 10MB VHD named seed.vhd and attaches it as drive L:
REM
create vdisk file="C:\Users\seank\Desktop\seed.vhd" maximum=10 type=expandable
select vdisk file="C:\Users\seank\Desktop\seed.vhd"
attach vdisk sd=D:(A;;GA;;;WD)
REM
REM Use this script to detach a VHD by executing diskpart likeso
REM
REM DiskPart /s detach-vhd
REM
select vdisk file="C:\Users\seank\Desktop\seed.vhd"
detach vdisk
@seank-com
seank-com / is-corrupt.cmd
Created March 15, 2016 20:06
Detect if an mp4 is corrupt
@REM
@REM Assumes ffmpeg.exe (https://www.ffmpeg.org/)
@REM in the same folder and invokes it to detect if an mp4 is corrupt.
@REM
@%~dp0\ffmpeg.exe -v error -i %1 -f null - >error.log 2>&1
@seank-com
seank-com / m2nf.cmd
Created March 15, 2016 20:10
Send To | A New Folder - Adds menu item to Send To menu on Windows to move the selected files to a new folder. Great for organizing.
@echo off
goto start
With this script properly installed you can right click a group of files and select Send To | A New Folder and
much like Send To | Compressed (zipped) folder, it it will create a folder with the name of the first selected
item and then move all the items selected into that new folder.
To set up:
- Open this folder in explorer, use "start ." from a command console.