Skip to content

Instantly share code, notes, and snippets.

@agreatfool
agreatfool / cpu.go
Created March 26, 2019 06:43
cpu.go
package main
import (
"fmt"
"math/rand"
"net/http"
_ "net/http/pprof"
"runtime"
"time"
)
@agreatfool
agreatfool / memory.go
Last active March 26, 2019 05:53
memory.go
package main
import (
"flag"
"fmt"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
"runtime"
@agreatfool
agreatfool / event-loop-lag.js
Last active March 15, 2018 09:06
event-loop-lag.js
#!/usr/bin/env node
"use strict";
const interval = 1000; // 采样间隔,即在这个间隔的自然时间内,调用lag()得到的结果将只会得到同样的返回
const lag = require('event-loop-lag')(interval);
function consume() {
function fabonacci(n) {
if (n === 0) {
return 0;
import { Entity, Column, PrimaryGeneratedColumn, Index, BaseEntity } from 'typeorm';
@Entity('test_entity')
@Index('test_entity_index', ['columnB', 'columnC'], { unique: true })
export class TestEntity extends BaseEntity {
@PrimaryGeneratedColumn({ type: 'int', name: 'id' })
id: number;
@Column({ type: 'int', name: 'column_b' })
columnB: number;
Statistical profiling result from isolate-0x103000000-v8.log, (20819 ticks, 582 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
38 0.2% /usr/lib/system/libsystem_malloc.dylib
22 0.1% /usr/lib/system/libsystem_kernel.dylib
9 0.0% /usr/lib/system/libsystem_platform.dylib
4 0.0% /usr/lib/system/libsystem_c.dylib
1 0.0% /usr/lib/system/libsystem_pthread.dylib
{
"name": "profile",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
@agreatfool
agreatfool / book.swagger.json
Created February 6, 2018 07:59
Generated swagger.json
{
"swagger": "2.0",
"info": {
"title": "book/book.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
@agreatfool
agreatfool / book.proto
Created February 6, 2018 07:52
Sample proto file
syntax = "proto3";
package com.book;
message Book {
int64 isbn = 1;
string title = 2;
string author = 3;
}
@agreatfool
agreatfool / book_grpc_pb.d.ts
Created February 6, 2018 07:49
Codes generated by grpc-tools
// package: com.book
// file: book/book.proto
import * as grpc from "grpc";
import * as book_book_pb from "../book/book_pb";
interface IBookServiceService extends grpc.IMethodsMap {
getBook: IGetBook;
getBooksViaAuthor: IGetBooksViaAuthor;
getGreatestBook: IGetGreatestBook;
@agreatfool
agreatfool / compiled.d.ts
Last active February 6, 2018 07:48
Static codes generated by protobuf.js
import * as $protobuf from "protobufjs";
/** Namespace com. */
export namespace com {
/** Namespace book. */
namespace book {
/** Properties of a Book. */
interface IBook {