Skip to content

Instantly share code, notes, and snippets.

View aslakhellesoy's full-sized avatar
🤠
typing...

Aslak Hellesøy aslakhellesoy

🤠
typing...
View GitHub Profile
// Translates a Google diff-match-patch diff to an array of ottypes textv1 ops
// Pretty straight-forward!
module.exports = function (diff) {
var ops = [];
for(var i = 0; i < diff.length; i++) {
var diffComp = diff[i];
switch(diffComp[0]) {
case -1: // DELETION
ops.push({d:diffComp[1].length});
break;
@aslakhellesoy
aslakhellesoy / README.md
Last active August 29, 2015 14:07
VMWare Fusion 7 borked

Every time I start VMWare Fusion 7.0 I get this:

VMWare error

I have tried to drag the VMWare app in the trash and manually remove a lot of files and then reinstall.

But the dialog keeps coming back.

I'm on OS X 10.9.4.

@aslakhellesoy
aslakhellesoy / drop_collections.js
Created September 17, 2014 17:30
Some code I use in tests to drop collections between tests.
var async = require('async');
var collections = ['projects', 'users', 'drafts', 'share_docs', 'share_docs_ops'];
module.exports = function(db, cb) {
function dropCollection(name, cb) {
db.collection(name, function(err, collection) {
if(err) return cb(err);
collection.drop(cb);
});
}
package lambdas;
import sun.reflect.ConstantPool;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public class TypeTest {
@FunctionalInterface
@aslakhellesoy
aslakhellesoy / gist:9321274
Created March 3, 2014 09:15
Limechat defaults
defaults read net.limechat.LimeChat "main_window"
{
h = 713;
info = 250;
log = 150;
root = 0;
"spell_checking" = 1;
tree = 120;
w = 1025;
x = 141;
@aslakhellesoy
aslakhellesoy / Dockerfile
Last active July 11, 2018 12:58
Docker Subversion image
# Sets up
FROM ubuntu:precise
# Install Subversion 1.8 and Apache
RUN apt-get install -y wget
RUN echo 'deb http://us.archive.ubuntu.com/ubuntu/ precise universe' >> /etc/apt/sources.list
RUN sh -c 'echo "deb http://opensource.wandisco.com/ubuntu precise svn18" >> /etc/apt/sources.list.d/WANdisco.list'
RUN wget -q http://opensource.wandisco.com/wandisco-debian.gpg -O- | apt-key add -
RUN apt-get update -y
@aslakhellesoy
aslakhellesoy / Makefile
Last active August 29, 2015 13:56
How to concatenate and minify js with make
BIN = node_modules/.bin
# Combine, ngmin and minify all of our own scripts
public/app.js: \
ng-app/providers/providers.js \
ng-app/providers/*.js \
ng-app/cucumber_pro.js \
ng-app/**/*.js
ifdef DEBUG
@aslakhellesoy
aslakhellesoy / del.txt
Created December 27, 2013 21:27
Delete redis keys by wildcard
eval "return redis.call('del', unpack(redis.call('keys', 'foo.*')))" 0
@aslakhellesoy
aslakhellesoy / create_github_files.sh
Created November 14, 2013 12:50
Can't create a new empty file on GitHub using API
# This works
curl -u USER:PASS https://api.github.com/repos/USER/REPO/contents/a.txt --request PUT --data-ascii $'{"path": "a.txt", "content": "bXkgbmV3IGZpbGUgY29udGVudHM=", "message": "hello"}'
# Does not work
curl -u USER:PASS https://api.github.com/repos/USER/REPO/contents/a.txt --request PUT --data-ascii $'{"path": "a.txt", "content": "", "message": "hello"}'
# HTTP status 422. Body:
# {
# "message": "content is not valid Base64",
# "documentation_url": "http://developer.github.com/v3/repos/contents/"
@aslakhellesoy
aslakhellesoy / gist:6667907
Created September 23, 2013 08:31
Subversion WebDAV respose
<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://subversion.tigris.org/xmlns/dav/">
<D:href>/svn/svnrepo/!svn/vcc/default</D:href>
<D:propstat>
<D:prop>
<lp1:checked-in><D:href>/svn/svnrepo/!svn/bln/7</D:href></lp1:checked-in>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>