Skip to content

Instantly share code, notes, and snippets.

@karlseguin
karlseguin / logs.csv
Created October 18, 2019 09:53
1 months worth of probes to an open 80 and 443
timestamp method uri ip
Oct 18, 2019 @ 09:41:02.000 - - 61.219.11.153
Oct 18, 2019 @ 09:34:37.000 GET / 164.52.24.162
Oct 18, 2019 @ 09:33:12.000 - - 61.219.11.153
Oct 18, 2019 @ 09:32:28.000 - - 61.219.11.153
Oct 18, 2019 @ 09:26:41.000 GET /otsmobile/app/mgs/mgw.htm 110.105.80.110
Oct 18, 2019 @ 09:23:42.000 GET /ftpsync.settings 185.234.216.20
Oct 18, 2019 @ 09:23:41.000 GET /deployment-config.json 185.234.216.20
Oct 18, 2019 @ 09:23:40.000 GET /.vscode/ftp-sync.json 185.234.216.20
Oct 18, 2019 @ 09:23:40.000 GET /.vscode/sftp.json 185.234.216.20
@karlseguin
karlseguin / fakeresponse.go
Created March 10, 2013 12:51
A fake http.ResponseWriter class, used for testing. See http://openmymind.net/Testing-In-Go/
package fakeresponse
import (
"testing"
"net/http"
)
type FakeResponse struct {
t *testing.T
headers http.Header
@karlseguin
karlseguin / intern.go
Created September 15, 2013 12:26
String interning in Golang
package intern
import (
"sync"
)
type Pool struct {
sync.RWMutex
lookup map[string]string
}
@karlseguin
karlseguin / gist:782765
Created January 17, 2011 11:57
Handling nhibernate exceptions
using System;
using System.Data.SqlClient;
using NHibernate.Exceptions;
public class ExceptionConverter : ISQLExceptionConverter
{
public Exception Convert(AdoExceptionContextInfo context)
{
var exception = ADOExceptionHelper.ExtractDbException(context.SqlException) as SqlException;
if (exception != null)
@karlseguin
karlseguin / spec.go
Last active February 20, 2018 19:42
A simple test helper for Go. See http://openmymind.net/Testing-In-Go/
package tests
import (
"testing"
)
type S struct {
t *testing.T
}
@karlseguin
karlseguin / gist:1846067
Created February 16, 2012 16:05
Paul Vick on Microsoft's IsNot Patent

This is taken from http://archive.org/ and originally appeared at http://www.panopticoncentral.net/archive/2004/11/20/2321.aspx

##Software patents In the wake of the IsNot patent brouhaha, aside from the "you are scum" comments, people have had several reasonable questions about my own feelings about the situation. So let me pause and talk about software patents for a moment. Lest there be any question about this, what follows are my own personal feelings about the matter and have nothing to do with official Micorosoft policy.

Personally, I don't believe software patents are a good idea. I realize that algorithms lie in that grey area between a mechanical process (which is patentable) and an abstract idea (which is not), but at a purely practical level I think that software patents generally do much more harm than good. As such, I'd like to see them go away and the US patent office focus on more productive tasks. I have nothing but contempt for any company that tries to use patents to achieve what they coul

func LoadArticle(res http.ResponseWriter, req *http.Request) {
if article, err := FindArticleById(...)
if err != nil {
handleError(res, err)
return
}
if article == nil {
handleNotFound(res, err)
}
}
// x.go
package di
var someCall = func() string {
return "original implementation"
}
func SomeMethodToTest() string {
return someCall()
@karlseguin
karlseguin / gist:a659ef87b3a4a5d590e9
Created January 13, 2015 16:51
UnixBench run on a AWS EC2 c4.2xlarge
BYTE UNIX Benchmarks (Version 5.1.3)
System: ip-172-30-0-152: GNU/Linux
OS: GNU/Linux -- 3.13.0-36-generic -- #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014
Machine: x86_64 (x86_64)
Language: en_US.utf8 (charmap="ANSI_X3.4-1968", collate="ANSI_X3.4-1968")
CPU 0: Intel(R) Xeon(R) CPU E5-2666 v3 @ 2.90GHz (5800.1 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
CPU 1: Intel(R) Xeon(R) CPU E5-2666 v3 @ 2.90GHz (5800.1 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
def to_route(url)
#strip out the /v4/
url = url[4..-1]
dot = url.index('.')
#strip out the extension
url = url[0...dot] unless dot.nil?
parts = url.split('/')
if parts.length == 1
"list #{parts[0]}"