Skip to content

Instantly share code, notes, and snippets.

View paulirwin's full-sized avatar
🙃

Paul Irwin paulirwin

🙃
View GitHub Profile
@paulirwin
paulirwin / gist:6780136
Created October 1, 2013 15:20
Lucene.net 4.3 failing test case. writer.ForceMerge(1) fails. Also fails in the same way if you commit enough docs to automatically merge.
public void RunTest()
{
var analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_43);
using (var dir = FSDirectory.Open("C:\\Index\\43TestCases\\TestCase1"))
using (var writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.Net.Util.Version.LUCENE_43, analyzer)))
{
var doc = new Document();
doc.Add(new IntField("DocID", 123, Field.Store.YES));
doc.Add(new TextField("Text", "Ramaria botrytis, commonly known as the clustered coral, the pink-tipped coral mushroom, or the cauliflower coral, is an edible species of coral fungus in the family Gomphaceae. Its robust fruit body can grow up to 15 cm (6 in) in diameter and 20 cm (8 in) tall, and resembles some marine coral. Its dense branches, which originate from a stout, massive base, are swollen at the tips and divided into several small branchlets. The branches are initially whitish but age to buff or tan, with tips that are pink to reddish
@paulirwin
paulirwin / gist:6784284
Created October 1, 2013 20:04
Lucene.net 4.3 failing test case. This results in an "already finished" InvalidOperationException in FST.cs on the .Commit() call.
public void RunTest()
{
var analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_43);
using (var dir = FSDirectory.Open("C:\\Index\\43TestCases\\TestCase1"))
using (var writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.Net.Util.Version.LUCENE_43, analyzer)))
{
var doc = new Document();
doc.Add(new IntField("DocID", 123, Field.Store.YES));
doc.Add(new TextField("Text", "Ramaria botrytis, commonly known as the clustered coral, the pink-tipped coral mushroom, or the cauliflower coral, is an edible species of coral fungus in the family Gomphaceae. Its robust fruit body can grow up to 15 cm (6 in) in diameter and 20 cm (8 in) tall, and resembles some marine coral. Its dense branches, which originate from a stout, massive base, are swollen at the tips and divided into several small branchlets. The branches are initially whitish but age to buff or tan, with tips that are pink to reddish. The fl
@paulirwin
paulirwin / gist:6812316
Created October 3, 2013 16:04
How to set up your dev environment for porting Lucene 4.3.1 code to Lucene.net
Porting Lucene 4.3.1 code to Lucene.net Guide
Note that not all projects build currently in the Lucene.net solution. You can build individual projects as you go.
1. Fork a repo that contains the lucene_4_3_0 or branch_4x branch. Since the Apache repo is currently out of sync, you can fork mine: https://github.com/paulirwin/lucene.net.git -- or you can clone the official apache git repo in step 2.
2. Clone your repo locally: git clone [https url]
3. Switch to the correct branch. If forked from my repo, use lucene_4_3_0: cd lucene.net; git checkout lucene_4_3_0
@paulirwin
paulirwin / gist:bae92250cb8196bb2d77
Created January 2, 2015 20:50
Use plain ES6 classes in JSX with React
// This gets around the stock .hasOwnProperty check in React 0.12 that prevents using plain ES6 classes
// as a parameter to React.createClass or React.createFactory. Or, at least, this makes it work with
// the React.NET transformer -- I cannot testify that this is needed for traditional JSX transformation.
class ES6Reactifier {
static createFactory(type) {
var obj = {};
for (var m in type.prototype) {
obj[m] = type.prototype[m];
}
@paulirwin
paulirwin / BetterDate.ts
Last active August 29, 2015 14:14
BetterDate: a sane JavaScript Date API for handling just dates without UTC issues
class BetterDate {
private _date: Date;
constructor(unixTime: number) {
this._date = new Date(unixTime);
}
toDate(): Date {
return this._date;
@paulirwin
paulirwin / Program.cs
Last active August 29, 2015 14:18
Git repo most modified files analyzer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LensLib
{
class Program
{
@paulirwin
paulirwin / Harness.fs
Created June 4, 2015 19:49
Smoke Testing in F# with Canopy
module harness
open canopy
open canopy.types
open runner
open System
let mutable baseurl = "http://localhost:49774"
let login username password =
SELECT
migs.avg_total_user_cost * (migs.avg_user_impact / 100.0) * (migs.user_seeks + migs.user_scans) AS improvement_measure,
'CREATE INDEX [IX_' + LEFT (PARSENAME(mid.statement, 1), 32) + '_' + REPLACE(REPLACE(REPLACE(ISNULL(mid.equality_columns,''), '[', ''), ']', ''), ',', '_')
+ CASE WHEN mid.equality_columns IS NOT NULL AND mid.inequality_columns IS NOT NULL THEN '_' ELSE '' END
+ REPLACE(REPLACE(REPLACE(ISNULL(mid.inequality_columns,''), '[', ''), ']', ''), ',', '_')
+ '] ON ' + REPLACE(mid.statement, '['+DB_NAME()+'].', '')
+ ' (' + ISNULL (mid.equality_columns,'')
+ CASE WHEN mid.equality_columns IS NOT NULL AND mid.inequality_columns IS NOT NULL THEN ',' ELSE '' END
+ ISNULL (mid.inequality_columns, '')
+ ')'
@paulirwin
paulirwin / vs.bat
Last active September 12, 2019 17:25
vs.bat
@echo off
start "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe" %1
@paulirwin
paulirwin / GetNewId.sql
Last active March 3, 2016 16:56
T-SQL NEWMSID() function for creating Azure Mobile Apps compatible IDs
CREATE VIEW [dbo].[GetNewId]
AS SELECT NEWID() AS [NewId]