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
//gcc -DPAD=0 -o test2_0 test2.c -lpthread;time ./test2_0 -- 6.5s | |
//gcc -DPAD=0x0C38 -o test2_0C38 test2.c -lpthread;time ./test2_0C38 -- 15s | |
#include <stdio.h> | |
#include <pthread.h> | |
#include <sys/time.h> | |
// very suprise, when PAD = 0x0C38, the speed is slow down | |
typedef struct _Block | |
{ |
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 wangzx.macros | |
import scala.language.experimental.macros | |
import scala.reflect.macros.Context | |
import java.lang.String | |
import scala.reflect.api.Symbols | |
object EnumsMacro { | |
def docs[A](obj: A): Map[Int, String] = macro docsMacro[A] |
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 demo | |
import reflect_demo.BindMacro._ | |
import reflect_demo._ | |
object BindDemo { | |
def main(args: Array[String]) { | |
val x = Box(10) |
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
<script languange="javascript"> | |
var begin = new Date(); | |
var pie = 0; | |
var loop = 1000 * 1000 * 100; | |
for(var i=1; i<loop; i++){ | |
var sign = (i % 2) == 0 ? -1.0 : 1.0; | |
pie = pie + sign / (2*i - 1) | |
} |
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 demo | |
object CodeWriter { | |
def main(args: Array[String]) { | |
val code = new CodeWriter | |
code.println("package wangzx.javabean") | |
code.println | |
code.println("public class Student extends Object"); |
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 jmxdemo; | |
import java.io.File; | |
import java.util.Set; | |
import javax.management.JMX; | |
import javax.management.MBeanServerConnection; | |
import javax.management.ObjectInstance; | |
import javax.management.ObjectName; | |
import javax.management.remote.JMXConnector; |
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 fbw | |
object FizzBuzzWhizz { | |
implicit class RichBoolean(bool: Boolean) { | |
def option[T](value:T) = if(bool) Some(value) else None | |
} | |
implicit class RichOption[T](option:Option[T]) { | |
def elseFlatMap(value: =>Option[T]) = option match { | |
case Some(_) => option |
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 volatile_demo; | |
import java.util.concurrent.BrokenBarrierException; | |
import java.util.concurrent.CyclicBarrier; | |
public class Test2 { | |
int a = 0; | |
int b = 0; | |
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
#!/bin/bash | |
# crontab | |
# * * * * * /home/wangzx/mysql-lock-wait/mysql_lock_wait_check.sh | |
function run_lock_wait() { | |
now=`date +%s` | |
seq=$(( $now / 30 % 600 )) # rotate 600 log file in 5 hours | |
logfile=~/mysql-lock-wait/log/mysql_lock_wait-$seq.log |
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 demo | |
import scala.tools.nsc.io.AbstractFile | |
import scala.tools.nsc.{Global, Phase} | |
import scala.tools.nsc.plugins.{Plugin, PluginComponent} | |
class DemoPlugin(val global: Global) extends Plugin { | |
import global._ | |
override def init(options: List[String], error: String => Unit): Boolean = true |