Skip to content

Instantly share code, notes, and snippets.

View douglasnomizo's full-sized avatar
👨‍💻
Working from home

Douglas Nomizo douglasnomizo

👨‍💻
Working from home
View GitHub Profile
// This Gist doesn't work with Graphql because of the deep nature of "selections" object
import { get } from 'lodash'
const memoizedResults = {}
export default (serializer: string, fn: Function): Function => async (
...args: Array<any>
): Promise<Object> => {
const [serializable, selections] = args
const identifier = get(serializable, 'id', get(serializable, 'uid'))
@douglasnomizo
douglasnomizo / js-frontend-resources.md
Last active July 17, 2017 15:46 — forked from diegopacheco/js-frontend-resources.md
Frontend / JavaScript Resources
@douglasnomizo
douglasnomizo / options.scala
Last active May 12, 2016 15:45
listCustom.scala.html
// Option 1
@defining(
(for {
custo <- cotacaoItem.custo
aliquotaSts <- custo.custoIcms.percentualAliquota
aliquotaFornecedor <- cotacaoItem.produto.percentualAliquotaIcms
cssClass <- if (aliquotaFornecedor.equals(aliquotaSts)) {Some("")} else {None}
} yield { cssClass }) getOrElse { "red" }
) { cssClass =>
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://gcm-http.googleapis.com/gcm/send":Connection timed out; nested exception is java.net.ConnectException: Connection timed out
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:580)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530)
at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:330)
at com.unicred.message.MessageService.sendMessage(MessageService.java:37)
at com.unicred.router.MessageRouter.sendToUser(MessageRouter.java:90)
at com.unicred.router.MessageRouter.route(MessageRouter.java:48)
at com.unicred.receiver.Receiver.receiveMessage(Receiver.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
{
"nodes":[
{
"id":12105,
"name":"ALICANTE04:PING",
"type":"IC",
"level":""
},
{
"id":12115,
require 'nokogiri'
class String
def underscore
self.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
def remove_tuples_from(string)
string.gsub! ' ', ''
string.gsub! /\(\)|[\,]?\([\d]*((\d\,)*\d)*\)|\(\)|\([\d]*((\d\,)*\d)*\)[\,]+|\(\)|\([\d]*((\d\,)*\d)*\)/x, ''
end
# 1. Transaction Fee Caculation
# We have a ladder fee structure. Please write a function to calculate total transaction fee we can get given the trading volume.
# Volume Fee
# 0 - 10 btc  2%
# 10 - 50 btc 1%
# 50 - 100 btc 0.5%
# 100 - 1000 btc 0.25%
# 1000 - 5000 btc 0.1%
require 'rspec'
require './transaction_fee_calculation'
describe 'calculation' do
it "tax should be 0.1 for 5 Bitcoins" do
expect(FeeCalculator.for(5)).to eq(0.1)
end
it "tax should be 0.2 for 10 Bitcoins" do
expect(FeeCalculator.for(10)).to eq(0.2)