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
/** | |
* Project File of Scala, Right Reserved by Darren Studio Works | |
* <p/> | |
* User: fujohnwang | |
* Date: 10/26/11 | |
*/ | |
public class SharedObject { | |
public int age; | |
public String name; | |
public boolean married; |
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
Class.forName("com.mysql.jdbc.Driver") | |
val connection = DriverManager.getConnection("jdbc:mysql://10.20.142.140/", "darren", "") | |
try { | |
val command = ComBinlogDump("mysql-bin.000001", 4L, 111) | |
val buffer = connection.asInstanceOf[JDBC4Connection].getIO.sendCommand(MysqlDefs.COM_BINLOG_DUMP, null, command.toMysqlBuffer(), false, null, 0) | |
println("buffer.getPosition=" + buffer.getPosition) | |
println("buffer.getBufLength=" + buffer.getBufLength) | |
println(buffer.dump()) | |
} finally { | |
connection.close() |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
class CreditCardValidator { | |
@BeanProperty | |
var cardNumberLength = 16 | |
def validate(cardNumber: String): Boolean = { | |
val numberString = StringUtils.deleteWhitespace(cardNumber) | |
if (numberString.length != cardNumberLength) return false | |
if (!StringUtils.isNumeric(numberString)) return false | |
val digits = numberString.map(c => java.lang.Byte.valueOf(String.valueOf(c))) | |
val total = digits.zipWithIndex.foldLeft(0)((total, e) => if (e._2 % 2 != 0) total + e._1 else total + doubleFlat(e._1)) |
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
trait Messenger { | |
def send(topic: String, message: String): Unit | |
def send(topic: String, messageKey: String, messageBody: String): Unit | |
} | |
class KafkaMessenger(producer: Producer[String, String]) extends Messenger { | |
override def send(topic: String, message: String): Unit = send(topic, null, message) | |
override def send(topic: String, messageKey: String, messageBody: String): Unit = { |
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
/** | |
* Hello world! | |
*/ | |
public class App { | |
public static void main(String[] args) { | |
Logger logger = LoggerFactory.getLogger("App"); | |
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | |
@Override | |
public void uncaughtException(Thread t, Throwable e) { | |
System.out.println("-----------------------we got here?"); |
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
<properties> | |
<compiler.version>1.6</compiler.version> | |
<java_source_version>1.6</java_source_version> | |
<java_target_version>1.6</java_target_version> | |
<file_encoding>UTF-8</file_encoding> | |
</properties> | |
<build> | |
<finalName>test</finalName> | |
<plugins> |
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
Question: | |
. How to run Ansible without specifying the inventory but the host directly? | |
. Run a playbook or command with arbitrary host not in the inventory hosts list? | |
. run ansible with arbitrary host/ip without inventory? | |
Answer: | |
Surprisingly, the trick is to append a , | |
The host parameter preceding the , can be either a hostname or an IPv4/v6 address. | |
ansible all -i example.com, |
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
哪有什么岁月静好,无非是有人替你寻衅滋事罢了,比如老罗与暖气片的故事 |
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
type D=Double;def w(x:D,y:D,a:D)={val(i,j)=(x-a,y-8);Math.sqrt(i*i+j*j)< 8};val l:Stream[Char]="love".toStream#:::l;val c=l.toIterator;def p(b:Boolean)=print(if(b)c.next else' ');for(y<-0 to 24){for(x<-0 to 32){if(y>7)p((16-x).abs< 24-y)else p(w(x,y,8)|w(x,y,24))};println} |
OlderNewer