Skip to content

Instantly share code, notes, and snippets.

View ikrabbe's full-sized avatar

Ingo Krabbe ikrabbe

View GitHub Profile
@ikrabbe
ikrabbe / stackoverflow_41320825_test.go
Created December 25, 2016 12:14
stackoverflow test file
// Package test is a pure testing package
package test
import (
"bytes"
"encoding/json"
"fmt"
)
const data = `
@ikrabbe
ikrabbe / xmltags_test.go
Created November 28, 2016 08:04
Test code with and without xml tags for xmlns QName Input/Output
package xmltags
import (
"encoding/xml"
"fmt"
"testing"
)
// Plain type is used for initialization
type Plain struct {
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
// select TEST 1 or 2. TEST=0 reads from stdin
#ifndef DO_TEST
#define DO_TEST 1
@ikrabbe
ikrabbe / parse_float_with_test.c
Last active March 18, 2016 13:22
A parse_float function with test
enum parseFloatErrorCodes {
SUCCESS, DOUBLE_DOT,PARSE_ERROR, INTEGER_OVERFLOW,
TOO_MANY_DIGITS_AFTER_DECIMAL_POINT
};
int parse_float(char* inp, float *x)
{
char *p;
int ival, dot;
for (ival = 0, dot = 0, p = inp; *p; ++p) {
int overflow_check = ival;
@ikrabbe
ikrabbe / sorted_array.js
Last active August 29, 2015 14:26
Three Javascript Functions to manage sorted arrays through a binary search function
/* Search in a sorted array A with the comparison function gt(v,w), that
* returns true if v greater than w and false otherwise, for a value x.
* Returns index i with 0 <= i < A.length, if the element has an exact match.
* Otherwise it returns the position p<0, that we can insert the new value
* sorted behind position -p-1
*/
function searchArray(A,x,gt)
{
var l=A.length;
var low=0,high=l-1,mid=0;
@ikrabbe
ikrabbe / threadDump-20150725-191027.txt
Created July 25, 2015 17:22
Android Studio 1.2 freeze ThreadDump
"AWT-EventQueue-0 1.2#AI-141.1890965, eap:false" prio=0 tid=0x0 nid=0x0 runnable
java.lang.Thread.State: RUNNABLE
(in native)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1400(ZipFile.java:56)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:679)
at com.intellij.openapi.util.io.FileUtilRt.loadBytes(FileUtilRt.java:577)
at com.intellij.openapi.util.io.FileUtil.loadBytes(FileUtil.java:1512)
at com.intellij.util.lang.MemoryResource.load(MemoryResource.java:75)
at com.intellij.util.lang.JarLoader.getResource(JarLoader.java:106)
@ikrabbe
ikrabbe / bond_tap_demo
Created February 6, 2014 10:05
What happens when I add tap1 to a bridge through a bond
root:tmp# /usr/sbin/brctl show br0
bridge name bridge id STP enabled interfaces
br0 8000.e4115bb36664 no bond0
root:tmp# ping -c1 172.30.78.1
PING 172.30.78.1 (172.30.78.1) 56(84) bytes of data.
64 bytes from 172.30.78.1: icmp_req=1 ttl=64 time=0.634 ms
--- 172.30.78.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.634/0.634/0.634/0.000 ms