Skip to content

Instantly share code, notes, and snippets.

zaus / bkmklt-replace-in-selected-text.js
Last active Oct 3, 2018
Bookmarklet - Replace in Selected Text
View bkmklt-replace-in-selected-text.js
(function() {
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
return text;
zaus / Test-Collection-Contains.linq.cs
Last active Jun 30, 2017
Comparing Collection.Contains for various sets of data
View Test-Collection-Contains.linq.cs
void Main()
test(10, 5, 10, true);
zaus / gist:71a7a89bc3bec0d8ea2faaa287c20c82
Last active Sep 22, 2016 — forked from marksteve/gist:877210
Monokai Notepad2 Color Scheme /mod
View gist:71a7a89bc3bec0d8ea2faaa287c20c82
[Default Text]
FileNameExtensions=txt; text; wtx; log; asc; doc
Default Style=font:DejaVu Sans Mono; size:10; fore:#F8F8F2; back:#000000
Margins and Line Numbers=size:-2; fore:#BCBCBC; back:#3B3A32
Matching Braces=size:+1; bold; fore:#000000; back:#FD971F
Matching Braces Error=size:+1; bold; fore:#F8F8F0; back:#F92672
Control Characters (Font)=size:-1
Indentation Guide (Color)=fore:#A0A0A0
Selected Text (Colors)=fore:#F8F8F2; back:#49483E; eolfilled
Whitespace (Colors, Size 0-5)=fore:#AA2B00
zaus / debug-me.php
Last active Feb 12, 2016
Simple WP debug helper "plugin"
View debug-me.php
Plugin Name: Dev Debug Me
Plugin URI:
Description: Just some developer includes for debugging. Not actually a plugin; activate to test log writing.
Author: zaus
Version: 0.1
Author URI:
zaus / compObj.js
Last active Jan 18, 2016
Simple javascript comparison of two objects with console logging/warning when different
View compObj.js
* Compare versions of objects and warn of differences
* @param {object} v1 variant 1
* @param {object} v2 variant 2
* @param {bool} stringify optionally (if provided and `true`) stringify the variant parameters when dumping
* @param {string} root [internal use] nested key placeholder
* @example <caption>Example comparing two things:</caption>
* // should result in warnings for 'foo' and 'somebool'
* compObj({foo: "bar", id: 123, somebool: true}, {bar: "foo", id: 123, somebool: 'true'});
* @returns {void} nothing -- see console logging
View header-loop-perf.cs
void Main()
var headers = new System.Net.WebHeaderCollection();
headers.Add("xxx", "yyy");
headers.Add("zzz", "f&&ff");
headers.Add("xxx", "ttt");
headers.Add("yyy", "33,3");
View enviro-switch.php
switch($_SERVER['HTTP_HOST']) {
case 'wp.sandbox:81':
define('DB_NAME', 'YOURDB');/** The name of the database for WordPress */
define('DB_USER', 'YOURUSER');/** MySQL database username */
define('DB_PASSWORD', 'YOURPASS');/** MySQL database password */
define('DB_HOST', 'localhost');/** MySQL hostname */ // may need to use actual computer ip in some cases
define('DB_NAME', 'YOURDB');/** The name of the database for WordPress */
define('DB_USER', 'YOURUSER');/** MySQL database username */
View SimpleServer.cs
using System.IO;
// modified from RestSharp unit tests
namespace UnitTesting
using System;
using System.Net;
using System.Security;
using System.Threading;
zaus /
Last active Aug 29, 2015
Demonstrating potential side effects (multiple evaluation) due to fast partitioning method from Stack Overflow answer


After using the suggested Partition solution on a set of data that had calculations applied to each element before being enumerated (see scenarios below), I noticed the application took much longer. Investigated via tests.cs and discovered that each item will be evaluated twice. See differences in sideeffect in results.

Original Scenario

var items = database.Fetch(filter).ToList();
var calculatedStuff = items.Select(item => new CalculatedItem(item));
// other stuff
var file = new SomeFileHelperThing("filename");
View Sign-In-Up-Transition.markdown
You can’t perform that action at this time.