Skip to content

Instantly share code, notes, and snippets.

@dinhhuydh
dinhhuydh / events_input.elm
Last active August 14, 2023 03:00
Add more information for Events.onInput in elm
{-| Suppose that you have many inputs for list of users (first_name, last_name)
To handle event onInput for inputs for each elements, it needs to bind Event.onInput for
inputs but Event.onInput support pass one string value. To customize that it's able to
include more information, for example user id, we can declare the Message as below:
-}
type Msg
= UpdateFirstName Int String
-- View
@dinhhuydh
dinhhuydh / bitrix24.rb
Created June 17, 2019 10:22
Create product on Bitrix24 with inbound webhook API
# Resolve errors: Name is not specified
connection = Faraday.new(url: @@base_url)
connection.post do |req|
req.url 'crm.product.add'
req.headers['Content-Type'] = 'application/json'
req.body = { fields: { NAME: product_name, PRICE: estate.gia_khoi_diem, DESCRIPTION: product_description } }.to_json
end
@dinhhuydh
dinhhuydh / notes.ex
Last active October 18, 2022 07:51
Scripts and note on Elixir
# Explain Ecto Query
Repo.explain(:all, Analytics.Queries.conversations_created_between(1, start_date, end_date))
# Disable spam log when playing `iex -S mix`. Set config in config/dev.secret.exs
config :logger,
level: String.to_atom(System.get_env("LOG_LEVEL", "debug")),
console: [format: "[$level] $message\n"]
# Then run the command
LOG_LEVEL=warning iex -S mix
@dinhhuydh
dinhhuydh / gist:0d44b0560c99968496597c3bd79ce754
Last active October 27, 2020 07:05
Install rgeo on ubuntu
# Install dependency
sudo apt install libgeos-3.6.2 libgeos-dev libgeos++-dev libproj-dev libproj12
# Make link to dependency
sudo find / -name 'libgeos*'
sudo ln -s /usr/lib/x86_64-linux-gnu/libgeos-3.6.2.so /usr/lib/libgeos.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libgeos-3.6.2.so /usr/lib/libgeos.so.1
# Clear cache
module RuboCop
module Cop
module Migration
class AddIndexName < RuboCop::Cop::Cop
# Postgres and MySQL have different naming conventions, so if we need to remove them we cannot predict accurately what the constraint name would be.
MSG = 'Please explicitly name your index or constraint.'.freeze
CONSTRAINT_METHODS = %i{
add_unique_constraint add_constraint add_foreign_key add_index add_primary_key add_full_text_index add_spatial_index
unique_constraint constraint foreign_key index primary_key full_text_index spatial_index
}.freeze
## require in .rubocop.yml
require
- ./linters/migration/add_index_name.rb
## config in .hound.yml
ruby:
config_file: .rubocop.yml
# added to .git-hooks/pre_commit/debugger.rb
module Overcommit::Hook::PreCommit
# Check for Debugger
class Debugger < Base
def run
keywords = config['keywords']
result = execute(command, args: [keywords.join('|')] + applicable_files)
unless result.stdout.empty?
extract_messages(

Principle

  • It does not predict a price up or down
  • It only notify when there is a rise on a coin. Price change is > 1.5% and volume change > 2%
  • It gets data on Poloniex page
  • The bot fetch data every 3 minutes

Examples

Ripple 1.0559% rises vs previous price. Volume: 22.6 btc. 24h Volume: 61960.10461694 btc. Rise streak: 1. Rise percentage (recent 100): 50.5%. Trend: 1.05% -0.73% -0.83% -0.13% -1.88% -1.23% 1.25% 0.63% -1.76% -1.5% . Watch & buy?

  • Rise 1.0559% to previous price in btc
  • Volume: 22.6 btc (estimated, maybe incorrect because Poloniex does not supply)
  • 24h Volume
# 1 Print square of number from 1 to n
# eg1: squares(3) => [1, 4, 9]
# 2: Print all numbers with 3 digits have two '1' digits like 112, 131
# 3. Calculate sum of digits in the numbers
# eg1: [12, 4, 154] => [3, 4, 10]
# 4. Transform a number to simple word of digits
# eg1: 12 => one two
# 1. count number of words in a string
# E.g 1: count_words("this is an object") ==> 4
# 2. Count how many max numbers
# eg1: [3,5,6,3,6] => 2
# eg2: [1,5,6,6,6] => 3
# 3. Find longest string
# eg 1: ['a', 'bbbbb', 'zzz'] => 'bbbb'