Skip to content

Instantly share code, notes, and snippets.

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
@ivanursul
ivanursul / AccessDeniedIntegrationTest.scala
Created January 24, 2015 10:31
AccessDeniedIntegrationTest.scala
package org.lnu.is.integration.access
import io.gatling.core.Predef.checkBuilder2Check
import io.gatling.core.Predef.doIf
import io.gatling.core.Predef.exec
import io.gatling.core.Predef.findCheckBuilder2ValidatorCheckBuilder
import io.gatling.core.Predef.foreach
import io.gatling.core.Predef.feed
import io.gatling.core.Predef.stringToExpression
import io.gatling.core.Predef.validatorCheckBuilder2CheckBuilder
#Pausing all but x CPU-intensive tasks
PAUSEQUEUENUM=0
ACTIVEQUEUENUM=0
function putinpausequeue {
kill -STOP $1
PAUSEQUEUE="$PAUSEQUEUE $1"
PAUSEQUEUENUM=$(($PAUSEQUEUENUM+1))
echo "Notice. I am pausing $1 . The pause queue is now $PAUSEQUEUE"
@cbrumelle
cbrumelle / kd-tree.rb
Created March 10, 2010 21:23
KD-TREE's in ruby
require 'pp'
class KDTree
attr_reader :root
attr_reader :points
def initialize(points, dim)
@dim = dim
@root = KDNode.new(dim).parse(points)
end
@nschlimm
nschlimm / gist:2157558
Created March 22, 2012 10:14
Use PoolSizeCalculator
public class MyPoolSizeCalculator extends PoolSizeCalculator {
public static void main(String[] args) throws InterruptedException,
InstantiationException,
IllegalAccessException,
ClassNotFoundException {
MyThreadSizeCalculator calculator = new MyThreadSizeCalculator();
calculator.calculateBoundaries(new BigDecimal(1.0),
new BigDecimal(100000));
}
@solso
solso / autossh.sh
Created July 26, 2012 13:56
Support material for blog post of redis replication
#!/bin/sh
## --- tunnel_to_master_redis
REDIS_MASTER=XYZ
REDIS_SLAVE_PORT=6280
AUTOSSH_POLL=300
AUTOSSH_PORT=20000
AUTOSSH_GATETIME=10
AUTOSSH_LOGFILE=/var/log/autossh/autossh.log
@josiahcarlson
josiahcarlson / prefix_code.py
Created May 6, 2013 16:29
Encode/decode sequences of integers to offer the ability to easily compare encoded sequences of integers as though they were decoded (which can be used to implement array comparisons in a database that doesn't offer native arrays).
'''
prefix_code.py
Copyright 2012-2013 Josiah Carlson
Released under the GNU LGPL v 2.1 license
This module offers the ability to encode/decode a sequence of integers into
strings that can then be used to compare sequences of integers (or paths on
trees) quickly. This module was originally intended to be used in a case-
preserving index in a relational database (where 'Z' comes before 'a', as is
votes CF
"back in black" => { 201005211200 => '1', 201005201159 => '1', 201005201157 => '1', 201005011900 => '1', 201004190600 => '1' },
"black album" => { 201005021800 => '1', 201005010600 => '1' },
"black star" => { 201005011000 => '1' }
cached_counts CF
"back in black" => { 'cached_count' => 2, 'counted_until' => 201005011931 },
"black album" => { 'cached_count' => 1, 'counted_until' => 201005010600 }
@MatthewHannigan
MatthewHannigan / gist:5210474
Created March 21, 2013 03:28
atlassian gdb dump core script with modifications to use mktemp and trap to clean up untested :-)
#!/bin/bash
# atlassian-heap-dump.sh - dump a heap using GDB for a crashed application
# Accepts a single argument: the PID of the JVM
# Author: James Gray (jgray@atlassian.com)
# Copyright Atlassian P/L
# License: MIT
# Are we root?
if [ $UID -ne 0 ]; then
@kimble
kimble / ApplicationGuiceModule.java
Created May 6, 2012 19:01
Dropwizard instrumentation of Guice beans annotated with @timed
package com.developerb.dropbot;
import com.developerb.dropbot.instrumentation.MethodInvocationTimingInterceptor;
import com.google.inject.AbstractModule;
import com.yammer.metrics.annotation.Timed;
import static com.google.inject.matcher.Matchers.annotatedWith;
import static com.google.inject.matcher.Matchers.any;
/**