Skip to content

Instantly share code, notes, and snippets.

View dcb9's full-sized avatar

Du, Chengbin dcb9

View GitHub Profile
@dcb9
dcb9 / ColumnSchemaBuilder.php
Created March 25, 2016 04:00
add comment function for MySQL ColumnSchemaBuilder in yii2 2.0.7
<?php
namespace common\components;
class ColumnSchemaBuilder extends \yii\db\ColumnSchemaBuilder
{
protected $comment;
/**
* @inheritdoc
@dcb9
dcb9 / DependencyInjectionForFuncExample.php
Created September 6, 2016 08:51
Dependency Injection For Function Example
<?php
/*
* # installation
*
* $ cat composer.json
* {
* "require": {
* "pimple/pimple": "~3.0"
* }
@dcb9
dcb9 / sicp-1.7.sc
Created August 23, 2017 09:50
sicp-1.7 created by dcb9 - https://repl.it/KVr5/1
(define (average x) (/ x 2))
(define (square x) (* x x))
(define (abs x) (if (< x 0) (- 0 x) x))
; (define (good-enough? guess x)
; (if (< (abs (- (square guess) x)) 0.00000000001)
; #t
; #f))
(define (good-enough? guess x)
@dcb9
dcb9 / sicp-1.8.sc
Last active August 24, 2017 01:09
sicp-1.8 created by dcb9 - https://repl.it/KVqC/7
(define (square x) (* x x))
(define (double x) (+ x x))
(define (athird x) (/ x 3))
(define (cube x) (* x x x))
(define (abs x) (if (< x 0) (- 0 x) x))
(define (good-enough? guess x)
(< (abs (- (cube guess) x)) 0.0000001))
(define (improve guess x)
@dcb9
dcb9 / http-status-codes.md
Created November 1, 2017 07:53 — forked from subfuzion/http-status-codes.md
General REST API HTTP Status Codes

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
@dcb9
dcb9 / restore-private-key-from-keystore.go
Created December 7, 2017 14:31
restore private key from ethereum, geth test net keystore
package main
import (
"encoding/hex"
"fmt"
"io/ioutil"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/crypto"
)
<!--
HTML5. Use tags like <article>, <section>, etc.
See: http://www.sitepoint.com/web-foundations/doctypes/
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
func ethGetLogs(contractAddress string, hexOfEvent string) {
generateZeros := func() string {
str := ""
for i := 0; i < 24; i++ {
str += "0"
}
return str
}
ethAddress = fmt.Sprintf("0x%s%s", generateZeros(), ethAddress[2:])
package main
import (
"fmt"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
)
@dcb9
dcb9 / bem.md
Created March 26, 2018 05:57
CSS BEM 书写规范 fork from https://github.com/Tencent/tmt-workflow

BEM命名约定


使用 [BEM][1] 命名规范,理论上讲,每行 css 代码都只有一个选择器。

BEM代表 “块(block),元素(element),修饰符(modifier)”,我们常用这三个实体开发组件。

在选择器中,由以下三种符号来表示扩展的关系: