Skip to content

Instantly share code, notes, and snippets.

@rnewson
rnewson / gist:8256811
Created January 4, 2014 16:02
trivial SOCKS5 handling in Erlang.
#!/usr/bin/env escript
-define(VERSION, 16#05).
-define(CONNECT, 16#01).
-define(NO_AUTH, 16#00).
-define(RESERVED, 16#00).
-define(ATYP_IPV4, 16#01).
-define(ATYP_DOMAINNAME, 16#03).
@rnewson
rnewson / haproxy.cfg
Last active November 18, 2021 22:12
haproxy.cfg stanzas to enable Perfect Forward Secrecy and HTTP Strict Transport Security. Requires OpenSSL 1.0.1g or so.
# Bind SSL port with PFS-enabling cipher suite
bind :443 ssl crt path_to_certificate no-tls-tickets ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-GCM-SHA384:AES128-SHA256:AES128-SHA:AES256-SHA256:AES256-SHA:!MD5:!aNULL:!DH:!RC4
# Distinguish between secure and insecure requests
acl secure dst_port eq 443
# Mark all cookies as secure if sent over SSL
rsprep ^Set-Cookie:\ (.*) Set-Cookie:\ \1;\ Secure if secure
# Add the HSTS header with a 1 year max-age
[notice] 2021-09-15T15:51:36.748239Z node1@127.0.0.1 <0.1433.0> ebbea2aab1 FOO1 [{total,6},{offset,4}]
{"rows":[]}
[notice] 2021-09-15T15:51:36.748278Z node1@127.0.0.1 <0.1433.0> ebbea2aab1 FOO2 {view_row,<<"foo">>,<<"doc2">>,null,undefined,undefined}
---
[notice] 2021-09-15T15:54:36.287647Z node1@127.0.0.1 <0.1489.0> cdb108a194 FOO1 [{total,6},{offset,4}]
[notice] 2021-09-15T15:54:36.287664Z node1@127.0.0.1 <0.1489.0> cdb108a194 FOO5 complete
[notice] 2021-09-15T15:54:36.287672Z node1@127.0.0.1 <0.1489.0> cdb108a194 FOO1 [{total,6},{offset,4}]
{"total_rows":12,"offset":8,"rows":[
@rnewson
rnewson / README
Last active December 31, 2020 00:39
Strava
Python script to insert missing trackpoints while paused
From https://support.strava.com/hc/en-us/articles/216919277-Auto-Pause:
"We will do server-side resting time calculations (per above)unless
there are manual pause events. If there are manual pause events, we
assume that you want to control the time and will calculate moving
time with respect to timer time instead."
This script detects these gaps and inserts trackpoints representing
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
% License for the specific language governing permissions and limitations under
@rnewson
rnewson / ebtree.erl
Created July 24, 2020 16:03
ebtree.erl with improved collation wrapper
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
% License for the specific language governing permissions and limitations under
{
"views": {
"foo": {
"map":"function(doc) { ... }",
"reduce":"function(keys,values,rereduce) { ... }"
},
"bar": {
"map":"function(doc) { ... }",
"reduce":"function(keys,values,rereduce) { ... }"
}
@rnewson
rnewson / gist:2387973
Created April 14, 2012 21:31
CouchDB Future Feature List - Round 2
A list of features that we want to see in CouchDB. Needs to be voted on so that it can become a priority queue.
User Facing Features
====================
1. Conflicts are the rule, not the exception
All previous versions of CouchDB hide conflicts by default (selecting
an arbitrary but consistent winning revision). Expert users can find
and resolve conflicts.
➜ ~ curl -gi 'http://foo:bar@localhost:15984/db1/_design/personen/_view/actief?keys=["10002","10003"]'
HTTP/1.1 200 OK
Cache-Control: must-revalidate
Content-Type: application/json
Date: Tue, 27 Aug 2019 10:53:16 GMT
Server: CouchDB/2.3.1-dirty (Erlang OTP/22)
Transfer-Encoding: chunked
X-Couch-Request-ID: 447c12072b
X-CouchDB-Body-Time: 0
keyword -> org.apache.lucene.analysis.core.KeywordAnalyzer
simple -> org.apache.lucene.analysis.core.SimpleAnalyzer
whitespace -> org.apache.lucene.analysis.core.WhitespaceAnalyzer
arabic -> org.apache.lucene.analysis.ar.ArabicAnalyzer
bulgarian -> org.apache.lucene.analysis.bg.BulgarianAnalyzer
brazilian -> org.apache.lucene.analysis.br.BrazilianAnalyzer
catalan -> org.apache.lucene.analysis.ca.CatalanAnalyzer
cjk -> org.apache.lucene.analysis.cjk.CJKAnalyzer
chinese -> org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer
czech -> org.apache.lucene.analysis.cz.CzechAnalyzer