Skip to content

Instantly share code, notes, and snippets.

" pairs
for mapmode in [ "o", "x" ]
for delimiter in [ "{}", "()", "[]", "<>" ]
let opening = delimiter[0]
let closing = delimiter[1]
for modifier in [ "i", "a" ]
for trigger in [ opening, closing ]
execute mapmode . "noremap <silent> " . modifier . "n" . trigger . " :<C-U>normal! f" . opening . "v" . modifier . closing . "<CR>"
execute mapmode . "noremap <silent> " . modifier . "l" . trigger . " :<C-U>normal! F" . closing . "v" . modifier . opening . "<CR>"
endfor
#include <stdio.h>
// first couple of triangular numbers
// http://en.wikipedia.org/wiki/Triangular_number
const int triag[] = {0, 1, 3, 6, 10, 15, 21};
// returns numbers of elements in first `h` rows of pascal's triangle that are
// not divisible by 7
// http://projecteuler.net/problem=148
long not7(long h) {
@wellle
wellle / ascenders.c
Last active December 19, 2015 23:18
Regarding the ascenders problem from codility.com.
#include <stdio.h>
#include <stdlib.h>
struct Results {
int * R;
int N;
};
struct Results solution(int A[], int N) {
struct Results result;
@wellle
wellle / AppDelegate.m
Last active December 19, 2015 09:49
Small class that adds itself as observer, but never removes itself again.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ...
Terminate *terminate = [[Terminate alloc] init];
[terminate release];
return YES;
}
@wellle
wellle / gist:5796507
Created June 17, 2013 12:27
Ant build failure
sergio:~/git/Android-App$ ant
Buildfile: /Users/sergio/git/Android-App/build.xml
...bla bla bla...
-set-mode-check:
-set-release-mode:
-release-obfuscation-check:
~ ❱ gcc -dM -E - < /dev/null
#define OBJC_NEW_PROPERTIES 1
#define _LP64 1
#define __APPLE_CC__ 5621
#define __APPLE__ 1
#define __ATOMIC_ACQUIRE 2
#define __ATOMIC_ACQ_REL 4
#define __ATOMIC_CONSUME 1
#define __ATOMIC_RELAXED 0
#define __ATOMIC_RELEASE 3
@wellle
wellle / gist:5783452
Created June 14, 2013 16:45
Added tag v7-3-1189 for changeset dc78a26f6f64
src hg:default ❱ make
mkdir objects
CC="gcc -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -no-cpp-precomp " srcdir=. sh ./osdef.sh
gcc -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -no-cpp-precomp -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -o objects/buffer.o buffer.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -no-cpp-precomp -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -o objects/blowfish.o blowfish.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -no-cpp-precomp -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -o objects/charset.o charset.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -no-cpp-precomp -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -o objects/diff.o diff.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -no-cpp-precomp -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -o objects/digraph.o digraph.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -no-cpp-precomp -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -o objects/edit.o edit.c
@wellle
wellle / mbfcsstl.patch
Created June 3, 2013 21:20
support multi-byte 'fillchars' in custom 'statusline' https://groups.google.com/forum/#!topic/vim_dev/0Cta0HGEHI8
diff -r 99b2236c037c src/buffer.c
--- a/src/buffer.c Mon Jun 03 12:17:05 2013 +0200
+++ b/src/buffer.c Mon Jun 03 16:23:39 2013 +0200
@@ -3567,11 +3567,6 @@
if (fillchar == 0)
fillchar = ' ';
-#ifdef FEAT_MBYTE
- /* Can't handle a multi-byte fill character yet. */
- else if (mb_char2len(fillchar) > 1)
package main
import (
"launchpad.net/gocheck"
)
type containsChecker struct {
*gocheck.CheckerInfo
}
@wellle
wellle / reject.go
Last active December 15, 2015 20:29
Small go program to demonstrate a case for https://github.com/streadway/amqp/pull/56. Using the adeven fork, the program prints `Sucess! Body: payload`. Using streadway/amqp, the program prints `Get failed: Exception (501) Reason: "EOF"` Requirements: Local amqp server with a queue and a corresponding dead letter queue. Both should be empty.
package main
import (
"github.com/adeven/amqp" // `adeven` works, `streadway` doesn't
"log"
"time"
)
func main() {
amqpConfig := "amqp://guest:guest@localhost:5672/"