Skip to content

Instantly share code, notes, and snippets.

@googya
googya / demo.gitignore
Created October 14, 2018 02:11
忽略 rust 运行出来的二进制文件, 但是不忽略源文件
*
!*.*
##### producer #####
require 'bunny'
require 'pry'
require 'json'
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.on('-r', '--routing_key key', 'Routing key for message') do |key|
@googya
googya / coinfit_api.py
Last active November 2, 2018 06:47
coinfit.io api request
import urllib
import hashlib
import time
import hmac
import requests
access_key = "access_key"
secret_key = "secret_key"
url = "/api/orders"
@googya
googya / gist:073123621ac4066659a0d0fb1c92ef03
Created June 19, 2018 16:30 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
var lengthOfLongestSubstring = function(s) {
var longStr = '', curStr = '';
var strArr = s.split('');
for (var i = 0; i < strArr.length; i++) {
if (curStr.indexOf(strArr[i]) == -1) {
curStr += strArr[i];
} else {
idx = curStr.indexOf(strArr[i]);
curStr = curStr.slice(idx+1);
@googya
googya / delayCheck.js
Last active May 3, 2018 09:58
轮询检查结果, 下次轮询时长为之前 1.5 倍
function delay(time, fn) {
return new Promise(function(resolve, reject){
function fun () {
resolve(fn())
}
setTimeout(fun, time);
});
}
function checkRes(time = 1000) {
@googya
googya / dabblet.css
Created April 26, 2018 03:11 — forked from csssecrets/dabblet.css
Translucent borders
/**
* Translucent borders
*/
body {
background: url('http://csssecrets.io/images/stone-art.jpg');
}
div {
border: 10px solid hsla(0,0%,100%,.5);
@googya
googya / dabblet.css
Last active April 26, 2018 03:10
Translucent borders
/**
* Translucent borders
*/
body {
background: url('http://csssecrets.io/images/stone-art.jpg');
}
div {
border: 10px solid hsla(0,0%,100%,.5);
import React from "react";
import { render } from "react-dom";
const log = name => {
console.log("----------------------");
console.log(name);
};
class Example extends React.Component {
constructor(props) {

Redux higher order components

Sometimes we need to share props and behaviour between multiple components/containers. For that we can do a higher order component. Example:

Decorator component

Higher Order Component that will decorate other component: