Skip to content

Instantly share code, notes, and snippets.

@Jim-Lin
Jim-Lin / file0.cs
Created August 14, 2015 09:32
[MongoDB .NET Driver] UpdateOneAsync & UpdateManyAsync sample ref: http://qiita.com/SHUAI/items/fc154ce42d6944bcedfe
var filter = Builders<Member>.Filter.Eq<string>(m => m.PersonId, id);
var update = Builders<Member>.Update.Set(m => m.Phone, phone);
var result = db.GetCollection<Member>(colName).UpdateOneAsync(filter, update).ConfigureAwait(continueOnCapturedContext: false);
@Jim-Lin
Jim-Lin / file0.cs
Last active September 10, 2015 12:45
[MongoDB .NET Driver] Upsert & SetOnInsert sample ref: http://qiita.com/SHUAI/items/e1f9bde6eb118de0fb88
public class Member
{
public ObjectId Id { get; set; }
public string PersonId { get; set; }
public string Name { get; set; }
public int Gender { get; set; }
@Jim-Lin
Jim-Lin / file0.groovy
Last active January 7, 2016 10:08
[ReactiveX Groovy] map & flatMap & concatMap sample ref: http://qiita.com/SHUAI/items/4b7d29b47919900d01bf
numbers = Observable.from([1, 2, 3, 4, 5]);
numbers.map({it * it}).subscribe(
{ println(it); }, // onNext
{ println("Error: " + it.getMessage()); }, // onError
{ println("Sequence complete"); } // onCompleted
);
@Jim-Lin
Jim-Lin / file0.java
Last active March 5, 2016 17:08
[Netty] brief talk about Non-Blocking I/O ref: http://qiita.com/SHUAI/items/bea4b8621380b642f116
// sample code:
read(file, tmp_buf, len);
write(socket, tmp_buf, len);
@Jim-Lin
Jim-Lin / file0.js
Last active March 21, 2016 16:33
[JavaScript] Reactive vs Promises ref: http://qiita.com/SHUAI/items/798ca865f5c853d2362c
console.clear();
var promise = new Promise((resolve) => {
setTimeout(() => {
resolve(42);
}, 500);
console.log('promise started');
});
@Jim-Lin
Jim-Lin / file0.java
Created May 15, 2016 09:23
[Spring MVC] Callable vs DeferredResult ref: http://qiita.com/SHUAI/items/205fc5e3064a70f1c22e
@RestController
public class AsyncCallableController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final TaskService taskService;
@Autowired
public AsyncCallableController(TaskService taskService) {
this.taskService = taskService;
}
@Jim-Lin
Jim-Lin / file0.java
Last active May 23, 2016 08:08
[Java] Fork/Join compute vs join ref: http://qiita.com/SHUAI/items/1ff257f4136416a2c9df
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveTask;
public class Main {
public static void main(String[] args) {
int poolSize = Runtime.getRuntime().availableProcessors();
System.out.println("poolSize: " + poolSize);
/**
@Jim-Lin
Jim-Lin / file0.txt
Created September 3, 2016 04:47
[Phabricator] Installation Guide with Docker ref: http://qiita.com/SHUAI/items/34d225d0b75cbd039d57
$ mkdir <work_dir>
$ cd <work_dir>
$ git clone https://github.com/phacility/libphutil.git
$ git clone https://github.com/phacility/arcanist.git
$ git clone https://github.com/phacility/phabricator.git
@Jim-Lin
Jim-Lin / file0.java
Last active October 9, 2017 09:19
[Java] Runtime Data Areas of JVM ref: http://qiita.com/SHUAI/items/9cd4b78f874f5a11c48c
public void add(java.lang.String);
Code:
Stack=2, Locals=2, Args_size=2
0: aload_0
1: getfield #15; //Field admin:Lcom/nhn/user/UserAdmin;
4: aload_1
5: invokevirtual #23; //Method com/nhn/user/UserAdmin.addUser:(Ljava/lang/String;)Lcom/nhn/user/User;
8: pop
9: return LineNumberTable:
line 14: 0
// Java
interface Collection<E> ... {
void addAll(Collection<E> items);
}
void copyAll(Collection<Object> to, Collection<String> from) {
to.addAll(from); // !!! Would not compile with the naive declaration of addAll
}