Skip to content

Instantly share code, notes, and snippets.

@LaptopHeaven
LaptopHeaven / to-pinboard.js
Created June 21, 2019 15:00
Save To Pinboard Bookmarket
javascript:(function(){var e=false;var t=null;var r=false;var n={javascript:"javascript",js:"javascript",python:"python",ios:"ios",youtube:"video",vimeo:"video",video:"video",books:"book",book:"book",arduino:"arduino",recipe: "recipe"};var o={"github.com":".entry-title .js-current-repository"};var i={"www.kickstarter.com":".short-blurb"};var a=function(e){return e.toLowerCase()};var c=function(e){return e?e.textContent.trim().replace(/\s+/g," "):null};var u=a(document.title);var l=function(e){if(e){return u.indexOf(a(e))!=-1}else{return false}};var f=function(e,t,r){r=r||window;var n=e.length;var o;for(var i=0;i<n;++i){o=t.call(r,e.item(i));if(o!==null){return o}}return null};var v=function(){var e=location.href;var t=location.hostname;var r;if(t in o){r=document.querySelector(o[t]);if(r){return c(r)}}var n=document.title;var r=document.querySelector("meta[property='og:title']");if(r){n=r.content.trim().replace(/\s+/g," ")}var i,a;if(f(document.getElementsByClassName("hentry"),function(e){return true})){var u
@LaptopHeaven
LaptopHeaven / utm-free.js
Created June 21, 2019 14:59
UTM Free: remove utm querystring
javascript:(function(){var t,a,o,c;if(t=location.search.replace(/^\?/,"").split("&"),a=[],t){for(o=t.length;o--;)t[o].match(/^utm_|^fb_action|^fb_source|^action_object_map|^action_type_map|^action_ref_map|^_r|^cmp|^imm_|^mc_|^mqsc|^trk|^midToken|^fromEmail|^ut|^fbclid|^wpmm|^wpisrc|^_hsmi|^_hsenc/)?c=!0:a.push(t[o]);c&&history.pushState("","",location.pathname+(a.length?"?"+a.join("&"):""))}})();
@LaptopHeaven
LaptopHeaven / MapDouble.cs
Created January 15, 2015 17:44
C# method to map a value to a new scale. Requires the value, the current min and max values and the new min and max values.
public static double Map(double value, double fromMin, double fromMax, double toMin, double toMax)
{
return (value - fromMin) * (toMax - toMin) / (fromMax - fromMin) + toMin;
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace kygeek.AyendeRuns
{
class Program
{
static void Main(string[] args)
{
@LaptopHeaven
LaptopHeaven / XmlTools.cs
Created February 7, 2013 14:46
Simple extension method to write and load data to xml. There are lots of caveats to this code, like all items in class T need to be Serializable.
using System.IO;
using System.Xml.Serialization;
public static class XmlTools
{
public static void SaveAsXml<T>(T data, string filename)
{
var serializer = new XmlSerializer(typeof(T));
using (var w = new StreamWriter(filename))
{
using System;
using System.Diagnostics;
using System.Net;
namespace ConsoleApplication1 {
internal class Program {
private const int COUNT = 20;
private static void Main() {
var urls = new[] {