Skip to content

Instantly share code, notes, and snippets.

View JamesSkemp's full-sized avatar

James Skemp JamesSkemp

View GitHub Profile
@JamesSkemp
JamesSkemp / Read large file.md
Last active September 20, 2016 16:08
Read a large file (via LINQPad)
string line;
// Read the file and display it line by line.
using (StreamReader file = new StreamReader(@"D:\$R3D4NK0.log"))
{
	var lineCount = 0;

    while ((line = file.ReadLine()) != null && lineCount < 25)
    {    
 Console.WriteLine(line);
@JamesSkemp
JamesSkemp / ConsoleZ setup.md
Last active August 11, 2016 20:31
Setup of ConsoleZ on a new machine.

Install Chocolatey from an elevated PowerShell prompt.

iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Then install ConsoleZ

choco install consolez

console.exe can now be found in C:\ProgramData\chocolatey\bin

@JamesSkemp
JamesSkemp / Sitecore Missing Templates Check.sql
Created June 7, 2016 20:51
Sitecore check for missing templates
USE XXX_Master
-- Find items that don't have a template set.
SELECT TOP 10 *
FROM Items mi
LEFT JOIN Items ti ON mi.TemplateID = ti.ID
WHERE ti.ID IS NULL
@JamesSkemp
JamesSkemp / readme from png images in directory.cs
Created March 17, 2016 01:47
Create README.md with PNG images from a directory
void Main()
{
// Can run in LINQPad.
var directory = @"C:\Users\James\Projects\directory" + Path.DirectorySeparatorChar;
parsePngFiles(directory);
}
// Define other methods and classes here
void parsePngFiles(string directory)
1. Create Git repo: https://github.com/JamesSkemp/blog.git
2. Clone locally:
	C:\Users\James\Projects> git clone https://github.com/JamesSkemp/blog.git
3. .\hugo.exe new site blog --force
4. cd blog
5a. Create content\posts\ and put file within
5b. Could also run ..\hugo.exe new posts\test.md and then either switch from draft or have Hugo check drafts
6. ..\hugo.exe server
7. Test site (doesn't work / blank)

Table altering, in T-SQL

Change table schema

Change the schema on an existing table.

ALTER SCHEMA projectManagement
TRANSFER dbo.RequestPriority

Change column

@JamesSkemp
JamesSkemp / WordPress Xml Content Search.cs
Last active February 10, 2016 19:43
Search a WordPress XML export for text in pages/posts.
// For running in LINQPad.
var typesToExclude = new List<string>() { "nav_menu_item", "attachment" };
var typesToInclude = new List<string>() { "page", "post" };
var searchTerm = "example.com/wp-content/uploads";
var xmlPath = @"C:\Users\jskemp\Downloads\example.wordpress.2016-01-22.xml";
var xml = XDocument.Load(xmlPath);
@JamesSkemp
JamesSkemp / RP2SambaSeagate.md
Last active January 18, 2021 19:06
Raspberry Pi 2 Samba server w/ a Seagate Backup Plus Slim 1TB

Setting up a Raspberry Pi 2 Samba server (in early January 2016)

The following is how I configured a Raspberry Pi 2 as a samba server, using a Seagate Backup Plus Slim, 1TB, drive.

For ease I purchased the CanaKit Raspberry Pi 2 Complete Starter Kit. It runs about $70 and includes enough to get up and running with the Raspberry Pi 2, with the Pi itself, a nice case, power supply, HDMI cable, WiFi adapter, and SD card with NOOBS/Raspbian installer.

For the hard drive I opted to purchase a Seagate Backup Plus Slim 1TB Portable External Hard Drive, since I've had good enough luck with Seagate in the past, and reviews are generally favorable. This ran me $60. I confirmed that it worked fine on my Windows 10 machine, and was already formatted to NTFS.

Unfortunately, once I received the Pi and drive I found that the power supply/Pi wasn't putting off enough power to keep the drive running. After looking at the options, including tweaking the Pi to pass throu

@JamesSkemp
JamesSkemp / Zenva academy full width video.js
Last active April 19, 2016 01:01
Zenva academy full width video
// Run the following in your browser's console, after page load.
// Works as of 1/8/2016 on https://academy.zenva.com.
$('#sidebar').hide();$('#main').css('width', '95%');
@JamesSkemp
JamesSkemp / Convert iMDB list links to RSS links.js
Last active December 31, 2015 23:40
Convert iMDB list links to RSS links