Skip to content

Instantly share code, notes, and snippets.

View adamfisher's full-sized avatar

Adam Fisher adamfisher

View GitHub Profile
@adamfisher
adamfisher / FileInfoExtensions.cs
Last active December 31, 2018 16:16
Extension method for FileInfo to split a big file into chunks.
/// <summary>
/// Splits a file into multiple files based on the specified chunk size of each file.
/// </summary>
/// <param name="file">The file.</param>
/// <param name="chunkSize">The maximum number of bytes to store in each file.
/// If a chunk size is not provided, files will be split into 1 MB chunks by default.
/// The breakOnNewlines parameter can slightly affect the size of each file.</param>
/// <param name="targetPath">The destination where the split files will be saved.</param>
/// <param name="deleteAfterSplit">if set to <c>true</c>, the original file is deleted after creating the newly split files.</param>
/// <param name="breakOnNewlines">if set to <c>true</c> break the file on the next newline once the chunk size limit is reached.</param>
/// <summary>
/// Gets the original file name from G-ZIP file.
/// </summary>
/// <returns>The decompressed file name.</returns>
private string GetFileNameFromGZipFile()
{
var bytes = File.OpenRead("abc.dat.gz");
bytes.ReadByte();
bytes.ReadByte();
var b = bytes.ReadByte();
@adamfisher
adamfisher / MIME Extension Mappings.xml
Created December 7, 2015 20:29
Maps file extensions to MIME types.
<staticContent lockAttributes="isDocFooterFileName">
<mimeMap fileExtension=".323" mimeType="text/h323" />
<mimeMap fileExtension=".aaf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".aca" mimeType="application/octet-stream" />
<mimeMap fileExtension=".accdb" mimeType="application/msaccess" />
<mimeMap fileExtension=".accde" mimeType="application/msaccess" />
<mimeMap fileExtension=".accdt" mimeType="application/msaccess" />
<mimeMap fileExtension=".acx" mimeType="application/internet-property-stream" />
<mimeMap fileExtension=".afm" mimeType="application/octet-stream" />
<mimeMap fileExtension=".ai" mimeType="application/postscript" />
@adamfisher
adamfisher / Reset Identity Value
Created October 31, 2014 13:07
Resets the identity value in a SQL Server Database to 1.
USE DatabaseName;
GO
DBCC CHECKIDENT ('TableName', RESEED, 1);
GO
@adamfisher
adamfisher / gist:a6f9abec8449575e8bd1
Created August 2, 2014 20:23
Auto Load WordPress CSS & JS Dynamically for Pages
/**
* Auto loads scripts and styles based on the page name if they exist.
*/
function mytheme_bootstrap_page_resources() {
if( is_page_template() ) {
$page_template = basename( get_page_template(), '.php' );
$css_file_path = get_stylesheet_directory() . "/css/templates/$page_template.css";
$js_file_path = get_stylesheet_directory() . "/js/templates/$page_template.js";
$css_file_uri = get_stylesheet_directory_uri() . "/css/templates/$page_template.css";
$js_file_uri = get_stylesheet_directory_uri() . "/js/templates/$page_template.js";
@adamfisher
adamfisher / Disable Windows Hibernation.ps1
Last active August 29, 2015 14:02
This command allows you to disable windows hibernation and reclaim the amount of space equal to the RAM installed on your machine.
powercfg /hibernate off
@adamfisher
adamfisher / YouTube Buffering Trick.ps1
Last active May 14, 2024 13:13
Eliminate YouTube buffering delays on Windows by running this command at the Windows command line. It prevents your computer from using CDN servers that rate limit the streaming speed of videos.
# Eliminates requests to YouTube's Buffering CDN Locations
#Install
netsh advfirewall firewall add rule name="YoutubeBufferTrick" dir=in action=block remoteip=173.194.55.0/24,206.111.0.0/16,208.117.251.0/24 enable=yes
#Uninstall
netsh advfirewall firewall delete rule name="YoutubeBufferTrick"