This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'bigdecimal' | |
| def getRandomMoney(remainSize, remainMoney) | |
| if remainSize == 1 | |
| remainSize -= 1 | |
| return remainMoney.floor(2) | |
| end | |
| min = 0.01 | |
| max = remainMoney / remainSize * 2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * | |
| !*.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##### 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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib | |
| import hashlib | |
| import time | |
| import hmac | |
| import requests | |
| access_key = "access_key" | |
| secret_key = "secret_key" | |
| url = "/api/orders" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function delay(time, fn) { | |
| return new Promise(function(resolve, reject){ | |
| function fun () { | |
| resolve(fn()) | |
| } | |
| setTimeout(fun, time); | |
| }); | |
| } | |
| function checkRes(time = 1000) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Translucent borders | |
| */ | |
| body { | |
| background: url('http://csssecrets.io/images/stone-art.jpg'); | |
| } | |
| div { | |
| border: 10px solid hsla(0,0%,100%,.5); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Translucent borders | |
| */ | |
| body { | |
| background: url('http://csssecrets.io/images/stone-art.jpg'); | |
| } | |
| div { | |
| border: 10px solid hsla(0,0%,100%,.5); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { render } from "react-dom"; | |
| const log = name => { | |
| console.log("----------------------"); | |
| console.log(name); | |
| }; | |
| class Example extends React.Component { | |
| constructor(props) { |