Skip to content

Instantly share code, notes, and snippets.

CREATE TABLE `User` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`inviterId` int(11) NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
CREATE TABLE `Post` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
@sources.Scene
export class FormDemo extends RootSectionModel {
@constraint.min(1)
public seatCount: number;
@constraint.required
public phoneNumber: string;
public message: string = '';
export class ListDemo extends RootSectionModel {
public from: number = 1;
public to: number = 9;
public get filteredReservations() {
return this.scene.query(Reservation_SeatInRange, { from: this.from, to: this.to });
}
public get totalCount() {
return this.filteredReservations.length;
}
}
import org.graalvm.polyglot.*;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws Exception {
try (Context context = Context.create("js")) {
context.eval("js", "" +
@taowen
taowen / main.lua
Created October 20, 2018 06:30
future in lua created by taowen - https://repl.it/@taowen/future-in-lua
function some_important_business_process(a, b)
result = a + b
c = 3
result = result * c
return result
end
result = some_important_business_process(1, 2)
print(result)
@taowen
taowen / main.lua
Created October 20, 2018 06:30
future in lua created by taowen - https://repl.it/@taowen/future-in-lua
function some_important_business_process(a, b)
result = a + b
c = 3
result = result * c
return result
end
result = some_important_business_process(1, 2)
print(result)
func ExampleUnboundedExecutor_Go_panic() {
concurrent.HandlePanic = func(recovered interface{}, funcName string) {
fmt.Println(funcName)
}
executor := concurrent.NewUnboundedExecutor()
executor.Go(willPanic)
time.Sleep(time.Second)
// output:
// github.com/modern-go/concurrent_test.willPanic
}
// set a logger to show who is blocking
concurrent.InfoLogger = log.New(os.Stdout, "", 0)
executor := concurrent.NewUnboundedExecutor()
executor.Go(func(ctx context.Context) {
everyMillisecond := time.NewTicker(time.Millisecond)
for {
select {
case <-ctx.Done():
// info log will be printed while we wait
time.Sleep(time.Second)
import "github.com/modern-go/concurrent"
executor := concurrent.NewUnboundedExecutor()
executor.Go(func(ctx context.Context) {
everyMillisecond := time.NewTicker(time.Millisecond)
for {
select {
case <-ctx.Done():
fmt.Println("goroutine exited")
return
#include <numeric>
#include <algorithm>
#include <random>
#include <vector>
#include <iostream>
#include <limits>
typedef int V;
typedef std::vector<V> vi;