This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct IDataHandler | |
{ | |
virtual void handle(<data type #1> value) = 0; | |
... | |
virtual void handle(<data type N> value) = 0; | |
}; | |
using stored_data_type_t = std::function<void (IDataHandler&)>; | |
using data_vector_t = std::vector<stored_data_type_t>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <chrono> | |
#include <assert.h> | |
#include <cstring> | |
using namespace std; | |
using namespace std::chrono; | |
bool parse_oadr_time(system_clock::time_point& time, const char* input) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <chrono> | |
#include <thread> | |
int main(int argc, char* argv[]) | |
{ | |
int i = 0; | |
while (true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdint> | |
#include <limits> | |
using namespace std; | |
/* Produces output: | |
count16 is: 65536 | |
count16 is: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Functional solution in Scala to: | |
* http://www.scoopshot.com/hiring-developer/ | |
* | |
* Hopeless plagiarism of multiple sources | |
*/ | |
object PiFinder extends App { | |
def isPalindrome(digits: Seq[BigInt]): Boolean = digits == digits.reverse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import java.util.concurrent.ConcurrentSkipListSet; | |
import java.util.LinkedList; | |
import java.util.Set; | |
import java.util.UUID; | |
class UUIDGenThread extends Thread { | |
private final Set<UUID> set; | |
private final int numUUIDS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.UUID | |
object MutlithreadedUniquenessOfUUID extends App { | |
class UUIDThread(numUUID: Int, set: java.util.Set[UUID]) extends Thread { | |
override def run() { | |
for(i <- 1 to numUUID) { | |
val uuid = UUID.randomUUID() | |
if(!set.add(uuid)) println("Collision: " + uuid) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
import java.util.LinkedList; | |
import java.util.UUID; | |
public class UUIDTest { | |
public static void main(String[] args) throws InterruptedException { | |
HashSet<UUID> set = new HashSet<UUID>(1000); | |
LinkedList<Thread> threads = new LinkedList<Thread>(); | |
for(int i=0; i<128; ++i) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.automatak.archivist.server.uuid | |
import org.scalatest.FunSuite | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.junit.JUnitRunner | |
import org.junit.runner.RunWith | |
import com.automatak.commons.testing._ | |
import java.util.UUID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test | |
import org.scalatest.FunSuite | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.junit.JUnitRunner | |
import org.junit.runner.RunWith | |
import collection.immutable.SortedMap | |
import concurrent.stm.Ref | |
import java.util.UUID |
NewerOlder