Skip to content

Instantly share code, notes, and snippets.

View ivanatpr's full-sized avatar

Ivan G ivanatpr

View GitHub Profile
//Note: quickly hacked together and only tested on one file
string xml = File.ReadAllText(@"sample.xfdf", Encoding.UTF8);
XDocument doc = XDocument.Load(new StringReader(xml));
var elements = doc.Root.Element(XName.Get("annots", "http://ns.adobe.com/xfdf/"))
.Elements(XName.Get("highlight", "http://ns.adobe.com/xfdf/"))
.OrderBy(e => int.Parse(e.Attribute("page").Value));
StringBuilder builder = new StringBuilder();
foreach (XElement element in elements)
{ var highlightText = element.Descendants(XName.Get("span", "http://www.w3.org/1999/xhtml")).FirstOrDefault()?.Value;
@ivanatpr
ivanatpr / multiRedditExportCopyPaste
Last active March 16, 2016 00:53 — forked from noelleleigh/multiRedditExportCopyPaste
Bookmerklet that converts a multi-reddit into an equivalent URL using the old syntax (e.g. reddit.com/r/funny+politics+gaming). Trivial change from original to produce a full reddit url, so result now includes the initial "http://reddit.com/r/"
javascript: (function() {
var ul_array = document.getElementsByClassName('subreddits').item(0).children;
var multiString = "http://reddit.com/r/";
for (var i = 0; i < ul_array.length; i++) {
var subName = ul_array[i].firstChild.firstChild.data.slice(3);
multiString += subName + "+"
}
window.prompt('Copy this string and send it to your phone. \n\nIn Alien Blue: \n\nTap "Edit" \nTap the "+" button next to the group you want the multi to be in. \nPaste the string into the "/r/" box. \nTap "Done"', multiString);
})()
@ivanatpr
ivanatpr / 7Zip_CompressDirButUseStoreBasedOnExtension.ps1
Created November 25, 2015 06:56
PowerShell script to use 7-Zip in order to compress a directory quickly by not attempting to recompress filetypes (like ZIP files) that are already compressed. These filetypes are included in the resulting archive by using the "store" method which skips compression for those files. All other filetypes are compressed like normal.
#REQUIRED: set the directory you want to compress.
$dirToArchive = "C:\path\to\dir\"
#leave blank in order to automatically use directory name as archive name, otherwise enter the filename of the archive to create
$archiveName = ""
#$archiveName = "Data.7z"
#path to 7z.exe
$exec = "C:\Program Files\7-Zip\7z.exe"
@ivanatpr
ivanatpr / TreeStyleTab_FireGesture_UserScripts
Last active December 24, 2015 09:39
Tree Style Tab specific scripts for use as user scripts within the FireGesture Firefox add-on. Scripts include: Close Current Tree; Close Children; Close Entire Tree (including parents); Close others except this tree Note: In order to use these you have to create a separate user script for each one.
/* Close Current Tree: Closes Current tabs and all descendants */
selTab = gBrowser.selectedTab;
TreeStyleTabService.getDescendantTabs(selTab).forEach(function(tab) {
try
{
gBrowser.removeTab(tab);
}
catch(e)
{
console.log("Failed to remove" + tab.label)