Code examples from this stack overflow answer.
This file contains hidden or 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
| # coding=utf-8 | |
| """ | |
| Demonstrates how a [Mapped Diagnostic Context](http://logback.qos.ch/manual/mdc.html) | |
| of log4j MDC fame (and also provided in slf4j) could be implemented in Python | |
| """ | |
| import json | |
| import logging | |
| import sys | |
| import threading |
This file contains hidden or 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 hello; | |
| import javax.sql.DataSource; | |
| import jp.sf.amateras.mirage.SqlManager; | |
| import jp.sf.amateras.mirage.SqlManagerImpl; | |
| import jp.sf.amateras.mirage.dialect.HyperSQLDialect; | |
| import jp.sf.amateras.mirage.integration.spring.SpringConnectionProvider; | |
| import org.apache.commons.dbcp.BasicDataSource; |
This file contains hidden or 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
| public static void runServer() { | |
| try { | |
| MulticastSocket s = new MulticastSocket(4446); | |
| InetAddress group = InetAddress.getByName("224.0.0.10"); | |
| s.joinGroup(group); | |
| byte[] data = new byte[100]; | |
| DatagramPacket datagramPacket = new DatagramPacket(data, data.length); | |
| s.receive(datagramPacket); | |
| Log.i("Received: " + data); | |
| return; |
This file contains hidden or 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
| sourceSets { | |
| generated { | |
| java { | |
| srcDirs = ['src/main/generated'] | |
| } | |
| } | |
| } | |
| configurations { | |
| querydslapt |
This file contains hidden or 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
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |