Skip to content

Instantly share code, notes, and snippets.

@examinedliving
examinedliving / split_output.cmd
Last active January 11, 2020 05:34
Split Windows Path variable (or anything else) into seperate lines to view easily from command line.
:: This assumes you are running from command line. To run from batch script, add the next commented out line to the top of
:: your batch file. Also, in a batch file the % sign before the i should be doubled, .e.g. %%i.
:: batch file only - remove preceeding semicolons from the next line and insert in batch file.
:: SETLOCAL ENABLEDELAYEDEXPANSION
:: from command prompt only - add the next line
cmd /v:on
@examinedliving
examinedliving / getDocTypeStr
Created August 22, 2013 16:23
Extract as an html string the doctype tag and html open tag for parsing out doctypes and xmlns when altering html documents.
function getDocTypeStr(htmlStr){
var getByXMLNS,docTypeStr, index=htmlStr.indexOf('<head>');
getByXMLNS=function(){
if(!htmlStr.match(/xmlns/i)){
return false;
} else {
var index_tmp,docTypeStr,newIndex,index=htmlStr.indexOf('xmlns'),
sub_tmp=htmlStr.substr(index);
index_tmp=sub_tmp.indexOf('>');
newIndex=index_tmp + index;
@examinedliving
examinedliving / elementMatcher
Last active December 18, 2017 04:09
RegExp That will match opening and closing tags in the same element. Useful For Replacing Tags in an HTML Element String. Useful for things like sublime find and replace.
# 'elem' Should Be Replaced With the name of the tag to matched.
/<\/?elem>/
@examinedliving
examinedliving / parser.js
Created August 24, 2013 13:06
jQuery.Parser - specific use jQuery.plugin
(function($) {
$.parser = function(site, args) {
var dfr = $.Deferred(),
result = {
getPages: function() {
var $this = this,
get = $.get('../' + site + '.lsth');
$.extend($this, {
site: site
@examinedliving
examinedliving / echo No_new_line
Created August 24, 2013 23:11
Batch command to echo text withou CR/LF.
<nul (set/p _any_variable=string to emit)
@examinedliving
examinedliving / bkbak.cmd
Created August 25, 2013 19:11
Backup File For a Directory for backing up grepped replacements and avoiding overwrites
@echo off
setlocal enabledelayedexpansion
set rand=%random%
set a=0
mkdir arch\%rand%
for /r %%i in (*bak) do (
if /i not exist arch\%rand%\%%~nxi (
@examinedliving
examinedliving / replaceUnderscore.bat
Created September 3, 2013 23:35
Renames a bunch of files that have an underscore as the first character to the name without the underscore. The extension and first character are changeable - also could be multiple first characters.
setlocal enabledelayedexpansion
for /r %%i in (*.html) do (
set a=%%~nxi
set b=!a:~0,1!
if /i NOT "!b!"=="_ " (
del "%%i"
) else (
set c=%%~nxi
set d=!c:~1,1000!
var ED = ED || {};
// Utility functions
ED.util = (function() {
// Data structure functions
function each(object, callback) {
if (object === null) return;
@examinedliving
examinedliving / ar.js
Created August 23, 2014 04:01
Simple Easy Aspect Ratio Script
// I got tired of forgetting how to calculate image aspect ratio valuables, and then trying to solve the algebra, instead of actually thinking it through --
// so I wrote the worlds simplest function
// h= current image height in pixels
// w= current image width
// nw= the width the image will be
// returns new height that will preserve aspect ratio at new width
//
@examinedliving
examinedliving / rgbToHex.js
Created September 24, 2014 14:42
rgbToHex
// created from this StackOverflow post: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
function rgbToHex(r,g,b){
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}