Skip to content

Instantly share code, notes, and snippets.

@thoward
thoward / LuceneDisposableExample.cs
Created November 12, 2010 00:57
An example workaround to add IDisposable support to objects that don't implement it (like Lucene.Net objects).
using System;
using Lucene.Net.Index;
namespace Lucene.Net.Extensions
{
public class Disposable<T> : IDisposable
{
public Disposable() { }
public Disposable(T entity, Action<T> disposeAction)
{
@thoward
thoward / MultiTokenStreamExample.Program.cs
Created December 17, 2010 03:33
An example of how to do something like Solr's copy fields in a Lucene Index...
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.Documents;
using Lucene.Net.Index;
using Lucene.Net.QueryParsers;
@thoward
thoward / index.html
Created November 20, 2012 01:30
SSI example
<html>
<body>
<h1>Party time!</h1>
<!--#include virtual="quote.html" -->
</body>
using System;
using System.Diagnostics;
using Mono.Simd;
namespace VectorizedQueryTest
{
class Program
{
static void Main(string[] args)
{
@thoward
thoward / equality_vs_bitwise_or.cs
Created January 28, 2013 01:13
This should be true for all values of x, y, z, and w (when comparing to zero anyway)
int x=0;
int y=0;
int z=0;
int w=0;
var bitwise_or = (x | y | z | w) == 0;
var equality = x == 0 && y == 0 && z == 0 && w == 0;
System.Diagnostics.Debug.Assert(bitwise_or == equality);
@thoward
thoward / untar.sh
Created March 20, 2013 01:08
Simple untar script that does the obvious thing and creates a directory named after the tar file, then extracts a tar in that directory. This is a handy to install in user scope to augment tar.
#/bin/bash
# cross platform absolute path function
abspath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
outd=`abspath ``basename $1 .tgz```
target=`abspath $1`
@thoward
thoward / jsig_methods.md
Created April 3, 2013 06:26
Description of method specification vs type specification... concept for jsig.

Example 1

Param array must implement method reduce, with arity of 2.

// !array => !reduce(_,_)
function reduce(array, reducer, seed) {
  return array.reduce(reducer, seed);
}
@thoward
thoward / output.txt
Created May 21, 2013 06:55
Explanation of my calculations about StrangeLoop economics, based on public information available in sponsorship prospectus/sponsor page/ticketing page/etc. Relevant Links: https://thestrangeloop.com/sponsors https://thestrangeloop.com/sponsors-page/prospectus
Total Sponsorship
70000
Total Ticket Sales
550000
Total Income
620000
Total Cost
@thoward
thoward / iptables-udp-flood.txt
Created August 8, 2013 00:04
Prevent UDP flood
# Outbound UDP Flood protection in a user defined chain.
iptables -N udp-flood
iptables -A OUTPUT -p udp -j udp-flood
iptables -A udp-flood -p udp -m limit --limit 50/s -j RETURN
iptables -A udp-flood -j LOG --log-level 4 --log-prefix 'UDP-flood attempt: '
iptables -A udp-flood -j DROP

Man-Eating-Cats

by Haruki Murakami
Translated by Philip Gabriel

Source

I bought a newspaper at the harbor and came across an article about an old woman who had been eaten by cats. She was seventy years old and lived alone in a small suburb of Athens -- a quiet sort of life, just her and her three cats in a small one-room apartment. One day, she suddenly keeled over face down on the sofa -- a heart attack, most likely. Nobody knew how long it had taken for her to die after she collapsed. The old woman didn't have any relatives or friends who visited her regularly, and it was a week before her body was discovered. The windows and door were closed, and the cats were trapped. There wasn't any food in the apartment. Granted, there was probably something in the fridge, but cats haven't evolved to the point where they can open refrigerators. On the verge of starvation, they were forced to devour their owner's flesh.

I read this articl