Skip to content

Instantly share code, notes, and snippets.

@catlion
catlion / gist:1148977
Created August 16, 2011 12:40
ClosedXML OutOfMemoryException
private static byte[] ConvertReportToExcel(List<Dictionary<string, object>> report)
{
var file = new XLWorkbook();
var sheet = file.Worksheets.Add("Report");
if (report.Count() == 0) {
sheet.Cell("A1").SetValue("Report is empty");
} else {
// First row filled with keys
var firstRow = report.ElementAt(0);
for (int j = 0; j < firstRow.Count; j++) {
@catlion
catlion / gist:1204396
Created September 8, 2011 19:14
equinox
public static IEnumerable<MessageDetails> Folder(ImapClient ic, string folderName)
{
var selRes = ic.Select(folderName);
if (!selRes.IsOk) {
throw new InvalidOperationException(selRes.ReasonForFailure);
}
return ic.Messages.Where(x => x.Uid >= uidNext).Select(y => new MessageDetails {
From = y.From.FirstOrDefault().ToString(),
Uid = y.Uid,
@catlion
catlion / netReps.js
Created October 7, 2011 06:13
NTLM authentication check for Firebug
isCorrectNtlm: function(file)
{
var resp = file.responseHeadersText.match(/www-authenticate:\s(.+)/i)[1]; // file.responseHeaders is undefined here
return (resp && resp.search(/ntlm|negotiate/i) >= 0);
},
isError: function(file)
{
if (file.aborted)
return true;
@catlion
catlion / gist:1875572
Created February 21, 2012 09:58
Great programming quotes SO topic backup
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head>
<link rel="stylesheet" href="http://www.stackprinter.com/stylesheets/export.css"/>
<style type="text/css">
.comment { color: Gray; margin-bottom:4px; }
</style>
</head>
<body>
<div id="home">
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PsortTest
{
class Program
{
@catlion
catlion / gist:3011514
Created June 28, 2012 13:52
Subgraphs
-- Get all friends of the given one
group :: [(Int,Int)] -> [Int] -> Int -> [Int]
group [] acc x = acc
group l [] x = group l [x] x
group ((x1, x2):tl) acc x =
case xx of (True, False) -> (group tl (x2 : (group tl (x2 : acc) x)) x2)
(False, True) -> group tl (x1 : (group tl (x1 : acc) x)) x1
otherwise -> group tl acc x
where xx = (isin x1 x2, isin x2 x1)
isin d p = not (p `elem` acc) && (d == x || d `elem` acc)
declare @max_mrdate datetime
declare @max_nexteval datetime
select
@max_mrdate=max(cast(mrdate as datetime)),
@max_nexteval=max(cast(nexteval as datetime))
from tblpms
where CaseNo = 'TR13-011-CRW'
select *
@catlion
catlion / F# build
Created June 26, 2013 17:35
F# build failed on mono
make -C src/fsharp all
make[1]: Entering directory `/home/artem/dev/mono3/fsharp/src/fsharp'
make do-proto
make[2]: Entering directory `/home/artem/dev/mono3/fsharp/src/fsharp'
make -C FSharp.Build-proto do-proto
make[3]: Entering directory `/home/artem/dev/mono3/fsharp/src/fsharp/FSharp.Build-proto'
mkdir -p .libs/proto
mkdir -p .libs/proto//2.0
mkdir -p .libs/proto//4.0
mono --gc=sgen /home/artem/dev/mono3/fsharp/lib/bootstrap/4.0/../2.0/fssrgen.exe ../FSharp.Build/FSBuild.txt .libs/proto/FSBuild.fs .libs/proto/FSBuild.resx

A Few Useful Things to Know about Machine Learning

The paper presents some key lessons and "folk wisdom" that machine learning researchers and practitioners have learnt from experience and which are hard to find in textbooks.

1. Learning = Representation + Evaluation + Optimization

All machine learning algorithms have three components:

  • Representation for a learner is the set if classifiers/functions that can be possibly learnt. This set is called hypothesis space. If a function is not in hypothesis space, it can not be learnt.
  • Evaluation function tells how good the machine learning model is.
  • Optimisation is the method to search for the most optimal learning model.
@catlion
catlion / gist:b24686474d1692239afb
Created January 28, 2016 20:47 — forked from anonymous/gist:e04333e0aa5173a3b090
Build Target and Web.config file transformations
Target "Build" (fun _ ->
!! "ContractLookup.sln"
|> MSBuild buildDir "Build" [
"Optimize", "True"
"DebugSymbols", "True"
"Configuration", "Debug"
"Platform", "Any CPU"
]
|> Log "Build-Output: "