Skip to content

Instantly share code, notes, and snippets.

@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 / 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);
using System;
using System.Diagnostics;
using Mono.Simd;
namespace VectorizedQueryTest
{
class Program
{
static void Main(string[] args)
{
@thoward
thoward / index.html
Created November 20, 2012 01:30
SSI example
<html>
<body>
<h1>Party time!</h1>
<!--#include virtual="quote.html" -->
</body>
@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 / 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)
{