829 Matching Annotations
  1. Dec 2019
  2. Nov 2019
  3. Oct 2019
    1. 抵押金

      币安有 抵押金 和 保证金 的概念

      这个例子里,抵押金多 41.3K,而保证金少 8.7k

      但是清算时,是考虑抵押金的,不知道这么分,有啥用处。。。

    2. 爆仓价格
      • 强行价格对应 Liquidation Price,对应亏光保证金的价格
      • 爆仓价格对应:Bankruptcy Price,对应亏光保证金 + 抵押金的价格
    3. 强行价格: 10,000 - 49,800/5 = 40

      Liquidation Price: 10000 - 49800/5 = 40

      即清算价格

      BTC 当前价格: 10K,

      当抵押金亏完, 只剩下保证金时:200 时,这时保证金率降到 0.4%,即到达清算线。

      而保证金现在有 49.8 K (= 50k - 用作保证金的200)

      五枚BTC 每枚亏 49.8k / 5,可以亏光,即价格跌到:10k - 49.8/5 = 40刀,会启动清算

    1. margin 的比例是当前仓位减掉负债后,占仓位价值的比例,还是比较直观的,其实就是当前仓位的净资产就是保证金,我们对这个保证金占仓位价值的比例有一个要求,或者反过来就是当前债务的占比有一个要求,不能超过多少

      文中的例子:

      初始保证金

      • 初始保证金 50%,则仓位 10k 时,对应 5k 保证金,5k 借款
      • 初始保证金 65%,则仓位 10k 时,对应 6.5k 保证金,3.5k 借款

        # 维持保证金

      股价跌倒一半后,仓位只有 5k,其中债务不变:

      • initial margin 50% 对应债务 5k,保证金 0k,比例为零,这时整个仓位只够刚好还债,真实情况中,早已经在这之前执行清算
      • initial margin 65% 对应债务 3.5k,保证金 1.5k,保证金比例 = 1.5 / 5 = 30% ,如果 maintenance margin 为 30%,则这时再跌一点点,就将执行清算
    1. Different DeFi projects have taken different approaches to implementing this oracle, but they can generally all be classified in one of five ways

      5 ways of price oracle

  4. Jul 2019
  5. Jun 2019
    1. So what is the benefit of this strange kind of hashing algorithm? Why not just concatenate all the chunks together into a single big chunk and use a regular hashing algorithm on that? The answer is that it allows for a neat mechanism known as Merkle proofs:

      Reason why Merkle Tree

    1. For example, summing two numbers costs 3 gas. Multiplying them costs 5 gas. Storing a 256bit word into the blockchain costs 20000 gas, which means storing 1kb of data costs 640000 gas.

      computation is cheap, storing is expensive

      • add: 3gas
      • mul: 5gas
      • storing 32 bytes: 2w
  6. May 2019
    1. For more on objects and prototypes see Object.prototype. For an explanation of object prototypes and the object prototype chains see Inheritance and the prototype chain.

      todo if need to know more about prototype and prototype chain

    2. We have introduced another keyword: new. new is strongly related to this. It creates a brand new empty object, and then calls the function specified, with this set to that new object.

      difference between calling function directly and using the key word: new is all about the meaning of this:

      • directly call: this is the obj current func called upon
      • new: this is a newly created empty object
    3. Person.prototype is an object shared by all instances of Person

      Person() is a function, function is object

      Person.prototype is an object shared by all instances created by the function: Person()

    1. An interface value

      没太懂这个 interface value 有什么特别的


      知道了,注意这里变量 i 的类型是 interface I, 而非具体的 struct T 或 type F


      interface value 是 value:一个值,这个值的类型是满足某个 interface 的具体类型

      比如 T{"Hello"} 这个值,它的类型是满足 interface M 的具体类型: T

  7. Apr 2019
    1. two ways: by selling the Shares they hold to another trader in exchange for Ether, or by Settling their Shares with Augur’s smart contracts.

      2 ways:

      1. settle with another trader before finalized, burn Complete set, get back ETH
      2. settle with augur contract if market finalized, give winning Share, get back ETH
    1. Create Complete Set

      这儿 Alice 和 Bob 赔率上是达成了一致的,即 8:2

      注意 Bob 这儿是想以 0.2 的价格买 B,和想以 0.8 的价格买 A 的 Alice 刚好能够凑成 Complete Set

      只不过 Bob 这儿只想买半个 Share,所以是 Partial Fill

    2. Direct Trade

      Share 可以直接转移和买卖,看来 Share 很可能也是一种 ERC20

      不知道是每个 Market 专属的,还是整个 Augur 通用的。

    3. Note that Bob could have also wanted to sell 1 SHARE of A for 0.8 ETH, which would have been a “Ask Outcome A, 1 SHARE for 0.8 ETH”. This would have had created the same result as shown above, even though he has no SHARES.

      "Sell 1 Share of Yes for 0.8ETH" is the same as:

      "Buy 1 Share of No for 0.2ETH"

      以上两个动作分别记做 Action-Y 和 Action-N

      两者都是在对事件押注,Action-Y 表示说我觉得事件发生的概率是 0.8,即不发生的概率是 0.2

      这儿所谓的 is the same, 是不是指的:

      当没有 Share of Yes 的时候,我想 sell Yes, 其实不是在卖Yes,而系统实际上是在买 No ?


      本质是在一个达成共识的赔率上,做两边的下注。<br> 而在一个达成共识的赔率上,到底下注哪边,其本质反映的是我心理预期的概率和实际赔率的不一致。

      如果我心理的概率和赔率完全一致,比如硬币正反面对赌,赔率是 1:1,那么我还参加这个赌局,就是完全碰运气而已了。

      但是如果正反的赔率是1:2,我肯定买正面,因为我心理预期的概率是1:1,当前赔率和预期发生了偏离,我觉得有利可图,于是买正面。


      所以 Augur 里的 Complete Set,指的是一个在达成共识的赔率上形成了对手方的对赌。

      上面到底是买 Yes,还是卖 No,其实是不同的事情,是在同一赔率下,我觉得 Yes 实际的概率会更大,于是 Action-Y,这时,为了形成有效赌局,我需要一个人来买该赔率下的另一边,也即是等一个觉的 No 的概率大于赔率所示的另一人来下注。

  8. Mar 2018
  9. Oct 2017
  10. www.silhouette.rocks www.silhouette.rocks
  11. www.silhouette.rocks www.silhouette.rocks
  12. www.silhouette.rocks www.silhouette.rocks
    1. An endpoint in Play is either an Action or a WebSocket and Silhouette provides mechanisms to secure both of them.

      endpoint: an action, or more specifically, an url to call

      simple and stupid

  13. www.silhouette.rocks www.silhouette.rocks
    1. In Silhouette a provider is a service that handles the authentication of an identity.

      a service that handles the authentication of an identity

      那和 Authenticator 有啥区别?

    1. It can be stateless with the disadvantages that the JWT can’t be invalidated.

      我理解这儿 stateless 的意思是不需要后端的数据库的支撑,直接通过 privatekey 来校验 jwt 的合法性,但是无法使其过期(或者说提前过期)

    2. Authenticator

      没太搞懂这个是干啥的

      按字面意思,应该是一坨做认证逻辑的代码,不过看这儿的描述,不太像这个意思。反倒是这儿提到的 Authenticator Service 可能是做这个的

  14. Sep 2017
  15. Mar 2017
  16. Feb 2017
  17. Jan 2017
    1. 注意,经过上面的设置,无法调节系统的声音大小了。等用完了录屏的需求,可以按下面的操作恢复系统音量调节的功能。

      Mac 录屏,收录系统音的解决方案

  18. Dec 2016
    1. The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

      执行object.wait()的线程必须拥有该object的锁

      执行 .wait() 之后,线程将释放该锁,并进入等待状态

      直到被其他线程执行的object.notify唤醒,并将在拿到锁之后,继续执行。

    1. Telescope system on moon, 有100 telescopes, 天文学家可以用它们拍照观测,每个观测任务可能会要couple hours和地球通信只能用radio signal,latency会很高;设计系统manage Telescopes, 要fault tolerant,任务调度,deploy update思路:类似long distance data center的manage, moon上多台app server负责控制telescope,每台server会与地球的master用radio作为heartbeat通信;如何deployupdate时,选一台active server发送file,然后分chunk,在moon上peer to peer的用gossip传播update

      Sys Design

      System on the Moon

    1. All team members can create their own development certificate. Only a team agent or admin can create a distribution certificate.

      Best Practice:

      • One dev certificate per coder
      • One distribution certificate per team
  19. Nov 2016
  20. Oct 2016
    1. This model of microservices that register themselves to a global registry will have a lot of advantages when it comes to building one or multiple applications using a microservice architectural approach. Eureka on its own won't have that much of use, but as you'll see in the future blogposts, Eureka will be the key element to locate all of our microservices.

      How to use Eureka locate our microservices?

      all Eureka clients register itself in the register center(Eureka Server)

  21. Sep 2016
    1. Server RPC interfaces started to be declared as part of protocol files, with the protocol compiler generating stub classes that users could override with actual implementations of the server's interface.

      ?

    1. If omitted, the protocol buffer compiler generates a warning and "proto2" is used as the default. This warning will be turned into an error in a future release.

      syntax = "proto3";

    1.     @Bean    ProtobufHttpMessageConverter protobufHttpMessageConverter() {        return new ProtobufHttpMessageConverter();    }

      convert response to protobuff msgs

    1. Feign is a handy project from Netflix that lets you describe a REST API client declaratively with annotations on an interface.

      Feign: Annotate a REST API

    1. User DataSource User EntityManagerFactory (userEntityManager) User TransactionManager (userTransactionManager)

      a little scary

      需要测试一下可行性,以及可能的坑

    1. Spring Security 提供了对访问控制列表(Access Control List,ACL)的支持,可以很方便的对不同的领域对象设置针对不同用户的权限

      一颗赛艇

  22. Aug 2016
    1. Reminders are alarms triggered at a specified time before an event starts. Notifications allow users to find out about changes to events in their calendar.

      Reminder: alarm<br> Notification: info updates

    1. Susan's calendar list includes her primary calendar as well as calendars for her team and cello lessons.

      1 person can have(subscribe to) a list of calendars

    1. It is important to note that no infrastructure for session expirations is configured for you out of the box. This is because things like session expiration are highly implementation dependent. This means if you require cleaning up expired sessions, you are responsible for cleaning up the expired sessions.

      Session Expiration should be handled by ourself?

    2. This section describes how Spring Session provides transparent integration with HttpSession. The intent is so that user’s can understand what is happening under the covers. This functionality is already integrated and you do NOT need to implement this logic yourself.

      How SpringSession works, briefly

    3. By passing in a custom HttpServletRequest implementation into the FilterChain we ensure that anything invoked after our Filter uses the custom HttpSession implementation.

      Wrapped HttpServletRequest in a wrapper, and makes all the invokes in the FilterChain after use our custom HttpSession

    1. This guide describes how to use Spring Session to manage multiple simultaneous browser sessions (i.e Google Accounts).

      Just like Google Account

      1 user can login in several accounts at the same time.

      keep track of several sessions for 1 user

    1. We customize Spring Session’s HttpSession integration to use HTTP headers to convey the current session information instead of cookies.

      Use HttpHeader instead of cookie

    1. It is extremely important that Spring Session’s springSessionRepositoryFilter is invoked before Spring Security’s springSecurityFilterChain.

      springSessionRepoFilter must before springSecurityFilterChain

      this ensures that spring security has the HttpSession to use

    1. Here we show how to use Spring Security OAuth together with Spring Cloud to extend our API Gateway to do Single Sign On and OAuth2 token authentication to backend resources.

      SSO+OAuth2

    2. Here we show how to build an API Gateway to control the authentication and access to the backend resources using Spring Cloud.

      Two parts

      1. use gateway control authentication
      2. distribute reqs to backends using SpringCloud
    3. A Secure Single Page Application

      Part I

      setup a simple hello-world app with SpringBoot as backend & Angular as frontend, request call guarded by SpringSecurity

    4. Here we show how to modularize the client-side code, and how to use "nice" URL paths without the fragment notation (e.g. "/#/login") which Angular uses by default, but most users dislike.
      • Modularize Angular code
      • rm the fragment notation
    5. a UI (HTML and JavaScript) and a Resource server

      这儿和一般常用的术语不太一样的地方是:

      UI指得就是平常的界面 (html & javascript) 而 resource 所谓的资源,并非常常指的静态资源,而是API resource,实际是接口数据。

    6. Remember from Part II of this series that Spring Security uses the HttpSession to store authentication data by default. It doesn’t interact directly with the session though: there’s an abstraction layer (SecurityContextRepository) in between that you can use to change the storage backend. If we can point that repository, in our resource server, to a store with an authentication verified by our UI, then we have a way to share authentication between the two servers. The UI server already has such a store (the HttpSession), so if we can distribute that store and open it up to the resource server, we have most of a solution.

      share the storage of authentication between 2 servers

    7. Here we start by breaking out the "greeting" resource that we are using as the dynamic content in our application into a separate server, first as an unprotected resource, and then protected by an opaque token.

      separate resource and backend server?

    8. The HTML resources need to be available to anonymous users, not just ignored by Spring Security, for reasons that will become clear.

      anonymous is a kind of authentication too

    9. So, even though the resource is protected and you can’t curl it directly, the browser was able to access the content.

      why this happened?

      还是需要用户名密码的

    10. but it is best practice for a production application to consolidate scripts to avoid chatter between the browser and the server (or content delivery network).

      reason why use need preprocessing & packaging front end assets

    1. 实时消息回调

      聊天基本是一个黑盒子,基本被环信承包了,这儿回调就是暴露了部分,供我们来做额外的操作,比如在自己服务器上保存聊天记录等

    2. 需要回调的类型,目前有两种消息类型可以回调(chat 和 chat_offline)。

      可以配置回调的类型:

      * chat 上行消息 
      * chat_offline 离线消息
      
    1. 消息历史记录只会保留14天

      只在环信的服务器上存储14天,如果需要跨设备存储长期聊天记录,需要我们自己的服务器处理。

    1. persistence.xml files should provide a unique name for each "persistence unit". Applications use this name to reference the configuration when obtaining an `javax.persistence.EntityManagerFactory reference.

      use persistence unit name to reference an EntityMangerFactory

  23. Jul 2016
    1. If a valid SecurityContext cannot be obtained from the HttpSession for whatever reason

      this means SecurityContext is retrieved from HttpSession

  24. Jun 2016
    1. A persistence context is a set of entity instances in which for any persistent entity identity there is a unique entity instance

      A set of entities is persistence context?

      Persistence Context:

      一堆实例,其中,每一个每一条数据库记录(持久化实例的ID)都对应一个单独的实例。

    1. Persistence simply means that we would like our application’s data to outlive the applications process.

      更直白些就是 写数据到数据库

    1. Jackson的三种模式(High level -> low):

      • DataBinding - 利用ObjectMapper在json string和class之间转换 mapper.readValue(src, MyClass.class)
      • TreeModel - mapper.readValue(src, JsonNode.class)
      • Streaming API - 直接利用 JsonGenerator 写 json
    2. Raw

      这里的raw是相对我们熟的自定义 class 而言

      raw 生肉 Java 自带的类型, Map String List<br> 熟肉 我们自定义的class

    1. This standard message resolver expects to find messages for /WEB-INF/templates/home.html in .properties files in the same folder and with the same name as the template, like:

      default name for externalizing txt file: home.properties

    1. 如果网页授权的作用域为snsapi_base,则本步骤中获取到网页授权access_token的同时,也获取到了openid

      通过code换取access token 的同时,也获得了openid,scope 为 snsapi_basic 的流程结束