What is ElenaUSD (USE) | What is ElenaUSD token | What is USE token

In this article, we’ll discuss information about the ElenaUSD project and USE token

Introduction to Elena protocol

As Elena protocol is a 100% fair launch project, there was no VC, or pre-sale to raise capital for the expansion of the project, everything was self-funded by the founders. We have set up an eco-system vault for further development of ELENA.

We are introducing Elena Protocol and USE Stablecoin. The goal of USE is to peg to 1 USD. In the Genesis period, we will use DAI as collateral, 1 USE is 100% backed by 1 DAI. We are inspired by many outstanding algorithmic stablecoin projects, i.e. FEI, FRAX, FLOAT, and UST. With the combination of the best elements from those projects, we have created Elena protocol.

FRAX

We will be using the core structure from FRAX, in the genesis period, 100% of USE is minted from DAI. In order to encourage liquidity providers in the early stage, providing and staking USE/DAI LP will receive ELENA, and this is the only method to obtain ELENA. Due to 1 USE is backed by 1 DAI in the early stage, the liquidity mining has close to 0 Impermanent Loss. After the genesis, the collateral ratio will be lowered and ELENA will play an important role to back USE’s peg.

UST (LUNA)

At the moment, FRAX’s collateral rate is at around 85% to 90%. In an ideal situation, it should reach 0%, meaning that 100% of FRAX is minted by FXS. In this model, it is close to UST, as UST is 100% minted and redeemed from LUNA, which is the ultimate goal of USE.

FEI

The core structure of Elena protocol is inspired by FRAX, as the stability of FRAX is verified by the market. However, the collateral ratio of FRAX is not as good as it originally planned, as we can see it stayed at the range of 85%-90% for some time now. The main reason is that the volatility risk has been transferred to FXS, while FXS’s price at the moment is 100% decided by the market. There are many factors that are uncertain, including the volatility of the whole crypto market, as well as the emotion of the investors, this will still be impacted by the “bad weather”. Protocol Controlled Value (PCV) introduced by FEI, is a “visible hand” when the market is acting extremely, instead of exposure to 100% market risk, it is a more reasonable and better protocol to protect the whole system. This will achieve the goal to maximize the value and size of ELENA, for the investors, there is less worried about impairment loss by providing liquidity to USE/DAI. Compare with FRAX, 100% of the reward will be provided to USE/DAI liquidity pool, and ELENA’s liquidity is controlled by PCV. This makes Elena protocol potentially the highest APY in stablecoin mining.

FLOAT

We have implemented the “Oasis Vault” inspired by the design of Float Protocol. When USE is greater than 1 DAI, there are opportunities for arbitrage, the DAI used for minting USE will be saved in the Oasis Vault. This helps the efficiency of PCV, whereas having a direct impact on the liquidity of ELENA. In theory, the bigger the vault, the more stable the system, the better the liquidity of ELENA. When there is enough liquidity of ELENA, Oasis Vault + PCV will lower the collateral ratio, towards its ultimate goal, 0% collateral ratio.

In the future roadmap of Elena protocol, we will release a few products which use USE as stablecoin. Including synthetic assets, which creating more use cases for USE.

USE holders benefit from the mechanisms designed to create a high-fidelity peg and liquid exchange.

Protocol Design

As shown in the chart below, Elena protocol includes the following core units: USE Stablecoin, Oasis Vault, PCV, USE Pools, Staking, Incentive, ELENA Governance Token, and DAO.

USE Stablecoin

USE Token is an ERC20 Token with unlimited supply, adjusted by the market demand. USE as a stablecoin can be used in different use cases, i.e. exchange, store value, synthetic assets, lending, yield aggregators, etc.

Oasis Vault

Oasis Vault is the core module of Elena protocol, anyone can mint or redeem USE fixed at 1 DAI per USE. There is room for arbitrage due to the movement in the price of USE/DAI on Uniswap. i.e. When USE/DAI price is 0.9, you can purchase USE in Uniswap, and redeem it in the vault. Or if USE/DAI is trading at 1.1, you can mint USE with 1 DAI and sell it in Uniswap.

Mint

Vault can mint USE depends on the current collateral ratio. I.e. if the current collateral ratio is 99%, investors will need to provide 0.99 DAI and $0.01 worth of ELENA (assuming the price of ELENA is $10, then investors need to provide 0.001 ELENA), to mint 1 USE.

Redeem

Investors can redeem USE from the vault. If the current collateral ratio is 99%, after redemption, investors will get 0.99 DAI and $0.01 worth of ELENA(assuming the price of ELENA is $10, then investors will get 0.001 ELENA).

Please note that redemption will be closed if the reserve ratio falls below the threshold. When this happens, the investors can only sell their position of USE on Uniswap. When there is enough reserve, the redemption function will be available again. Through the activate/deactivate redemption function, the system is more stable and better protected from unexpected events.

Collateral Ratio

Collateral Ratio means when minting, the percentage of DAI required. The ratio will be adjusted periodically. When USE/DAI is greater than 1, means that there is more demand for USE in the market and investors have faith in the project. The collateral ratio will be adjusted to a lower number. In contrast, if USE/DAI is less than 1, meaning that there is less demand in the market, the collateral ratio will be adjusted higher.

At Genesis, the collateral ratio is set to 100%, meaning that to mint 1 USE, you will need to deposit 1 DAI to the vault. In the fractional period, the collateral ratio will be moving in between 100%, and 0%. If we reach uncollateral period, the collateral ratio will be 0%.

Reserve Ratio

When USE/DAI is trading above or below 1, the vault will still mint or redeem at 1, there are opportunities for arbitrage, when doing so, the price is pushed back to 1. When the price is below 1, the result of arbitrage is the reduction of the reserve. We define reserve ratio as:

vaultReserve: the number of DAI in the vault.

swapPoolReserve: the value of liquidity pool, i.e. the number of DAI in USE/DAI pool in Uniswap

The reserve ratio is an indicator of whether the protocol can survive in a massive dump. If the ratio is too small, meaning it is under-reserved. In most cases, the protocol should have enough reserve, as mentioned above, there is a policy to stop redemption when the reserve is too low, as well as other designs to protect USE peg to 1 DAI in the long term.

USE Pools

There are two pools on Uniswap, USE/DAI, and USE/ELENA. We will support more tokens in the vault and will have different pools on Uniswap. In order to incentivize investors providing liquidity, we will be running a liquidity mining program for USE/DAI. USE/ELENA’s liquidity will be provided and controlled by PCV, ensure the pool has better liquidity and reduced slippage.

PCV

The price control system of the Elena protocol has two parts: Oasis Vault, and USE/ELENA liquidity pool. The vault aims to ensure the pegging system works in the long term. USE/ELENA is controlled by PCV, the goal of PCV is to maintain a highly stable, deep liquidity stablecoin system, which benefits investors in the long term.

Price Oracle

We will use Uniswap TWAP Oracle Price to determine the current price of USE and ELENA.

Eco-system Vault

The vault will allocate an additional 2.5% ELENA to the vault when minting and redeeming. As well as 20% on the profit generated to liquidity providers. Please note that the allocation will not be minted directly, it will only happen when a payment is needed. This is the maximum percentage that can be minted, the actual number to be minted can be smaller than the maximum planned.

The fund from the vault will be used in the following areas:

  1. Marketing
  2. Advisors
  3. Developers’ Salary
  4. Airdrop
  5. Strategic Partners

Governance

The governance for a fair launch project is crucial. We use ELENA as governance tokens, the holders of ELENA are able to participate in the governance.

Including but not limited to:

  1. New tokens in the vault
  2. Adjust PCV’s target and rules
  3. Adjust reward
  4. Upcoming synthetic assets
  5. Airdrops

Fees

Compare with Frax, which charges up to 0.45% for minting and redeeming, USE charges **0 fees **for both activities.

Risk

Off Peg

The key point of whether USE can peg to 1 DAI is if arbitrage works. If when the price USE deviates from 1 DAI, if there is enough room for profit. This requires the vault to have enough reserve. When there is not enough reserve in the vault, it is likely that the protocol enters a death spiral.

Reserve Ratio is an indicator of whether the current reserve is sufficient, as well as if it is in a balanced position with its liquidity. In most cases, the reserve ratio will increase over time. When the collateral ratio is 100%, its sell-off pressure is as follows:

s: the percentage of sell-off, i.e. if 0.2 means there is 20% USE sell orders to USE/DAI pool

rr: reserve ratio

As can be seen above, it is a sub-linear curve, when s increases, its underlying reserve decreases, but it is smaller than a linear model.

When the collateral ratio is below 80%, things get a bit more complicated. As the reserve ratio is 80% (less than 100%), after the first sell-off doing arbitrage, the seller needs to sell 20% worth of ELENA, which makes the 2nd sell-off. After the 2nd sell-off repricing, there will be the 3rd sell-off, the arbitrager keeps doing so until there is no profit for doing so.

Based on this, we have a new generalized formula

Based on the formulas above, we studied the relationship between sell-off pressure in different collateral ratio and reserve ratio. This helps DAO better in terms of evaluating the risk level of the current system.

Elena Protocol Fractional Phase Quick Start Guide

Elena Protocol will officially move into the fractional stage on April 26, 2021 (UTC), which means that Elena will become more valuable because each time when minting USE, Elena is needed. The amount of Elena needed will vary with the update of the collateral rate. When the collateral rate decreases, the amount of ELENA required for minting USE will increase. Our goal is to gradually reduce the collateral rate from 100% to 0%. Then ELENA will eventually be used to mint USE, so ELENA will be always needed.

In the beginning, we decrease the collateral rate to 99%. For instance, if we want to mint 100 USE, it requires $99 of collateral which are 99 DAI, and an additional $1 worth of ELENA. The system will automatically calculate the amount of ELENA needed, and finally, click MINT 100USE.

Here we would like to demonstrate how to obtain ELENA. We have released a customized Swap page as requested by our investors. Due to Uniswap’s front-end restrictions, users can only use USE to purchase ELENA. This is inconvenient. To make life easier, we made an enhancement based on Uniswap’s open source codes (Thanks again to Hayden, you changed the world!) by updating the token swap routing (We will compose an article to explain how this was done, which is another interesting topic).

Via the customized Swap page,  https://swap.elena.finance, all popular tokens, such as ETH, DAI, USDC, USDT, WBTC, CRV, FRAX, YFI, etc., and ELENA can be traded directly. The Swap page can be accessed through the navigation bar at the homepage.

The same as minting USE, when redeeming USE, we will get DAI and ELENA based on the current collateral rate, correspondingly.

When we enter the number of USE to be redeemed, the system will automatically calculate the DAI and ELENA that will be collected. One important thing to keep in mind: Redeeming is a two step action: 1. Redeem, 2. Collect. After clicking REDEEM button, you still need to click COLLECT button to claim back your tokens (DAI and ELENA) into your wallet.

This two steps design of redeeming is a best practice for security reasons to avoid some malicious attacks, such as flashloan attacks.

The USE/DAI liquidity providers can always get rewards. After minting USE, staking USE-DAI LP tokens on the Staking page will continue receiving ELENA rewards.

Elena Protocol Liquidity Mining Quick Start Guide

Step1: mint USE

The ELENA protocol will incentivize the liquidity pool of USE/DAI. USE token can be minted through DAI and ELENA. When the collateral rate is 100%, 1 USE is minted by 1 DAI. As the collateral rate decreases, the **_percentage of _**ELENA as collateral will gradually increase during minting USE.

Before minting USE, we need to Approve it first, and then we enter the amount of DAI we want to mint, and the amount of ELENA needed will be automatically calculated based on the current collateral rate. Subsequently, we confirm and click the Mint button, and wait for the execution of the contract after interacting with Metamask.

Step2: Staking

After we receive the minted USE token, we could provide liquidity for the USE/DAI pool in Uniswap. We can jump to the Uniswap pair page by clicking the “add liquidity” link as shown on the page. After providing the liquidity in Uniswap, we could return to the Staking page to stake the USE-DAI LP token we just received. Here you need to click the “+” sign to stake.

Next, we need to fill in the number of USE-DAI LPs we want to stake in the pop-up window, then submit after confirmation. Now your liquidity mining starts, and your rewards are automatically calculated.

We can check the earnings in the panel on the left and withdraw the rewards at any time. If we want to quit liquidity mining, we can also click “UNSTAKE” button to withdraw the USE-DAI LP tokens from the contract. Note that no fees will be charged during all actions, all you need to pay is ETH gas fee.

At last, on the home page, we can see all the data of the Elena protocol, such as the test data shown below, the current collateral rate is 95%, the price of USE stablecoin is $0.9971, and the price of Elena is $156.2227. In the upper right corner, we can jump directly to Uniswap to buy or sell ELENA or USE.

How and Where to Buy ElenaUSD (USE)?

ElenaUSD token is now live on the Ethereum mainnet. The token address for ElenaUSD is 0x147E3d644d53ADadD18a28201b91e2B98aEB7f94. Be cautious not to purchase any other token with a smart contract different from this one (as this can be easily faked). We strongly advise to be vigilant and stay safe throughout the launch. Don’t let the excitement get the best of you.

Just be sure you have enough ETH in your wallet to cover the transaction fees.

You will have to first buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT), Binance (BNB)…

We will use Binance Exchange here as it is one of the largest crypto exchanges that accept fiat deposits.

Once you finished the KYC process. You will be asked to add a payment method. Here you can either choose to provide a credit/debit card or use a bank transfer, and buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT), Binance (BNB)…

SIGN UP ON BINANCE

Step by Step Guide : What is Binance | How to Create an account on Binance (Updated 2021)

Next step

You need a wallet address to Connect to Uniswap Decentralized Exchange, we use Metamask wallet

If you don’t have a Metamask wallet, read this article and follow the steps

What is Metamask wallet | How to Create a wallet and Use

Transfer $ETH to your new Metamask wallet from your existing wallet

Next step

Connect Metamask wallet to Uniswap Decentralized Exchange and Buy, Swap USE token

Contract: 0x147E3d644d53ADadD18a28201b91e2B98aEB7f94

Read more: What is Uniswap | Beginner’s Guide on How to Use Uniswap

The top exchange for trading in USE token is currently 

There are a few popular crypto exchanges where they have decent daily trading volumes and a huge user base. This will ensure you will be able to sell your coins at any time and the fees will usually be lower. It is suggested that you also register on these exchanges since once USE gets listed there it will attract a large amount of trading volumes from the users there, that means you will be having some great trading opportunities!

Top exchanges for token-coin trading. Follow instructions and make unlimited money

https://www.binance.com
  ☞ https://www.bittrex.com
  ☞ https://www.poloniex.com
  ☞ https://www.bitfinex.com
  ☞ https://www.huobi.com

Find more information USE

WebsiteExplorerExplorer 2Source CodeSocial ChannelSocial Channel 2Message BoardCoinmarketcap

🔺DISCLAIMER: The Information in the post isn’t financial advice, is intended FOR GENERAL INFORMATION PURPOSES ONLY. Trading Cryptocurrency is VERY risky. Make sure you understand these risks and that you are responsible for what you do with your money.

🔥 If you’re a beginner. I believe the article below will be useful to you

⭐ ⭐ ⭐ What You Should Know Before Investing in Cryptocurrency - For Beginner ⭐ ⭐ ⭐

I hope this post will help you. Don’t forget to leave a like, comment and sharing it with others. Thank you!

#blockchain #bitcoin #use #elenausd

What is GEEK

Buddha Community

What is ElenaUSD (USE) | What is ElenaUSD token | What is USE token
Chloe  Butler

Chloe Butler

1667425440

Pdf2gerb: Perl Script Converts PDF Files to Gerber format

pdf2gerb

Perl script converts PDF files to Gerber format

Pdf2Gerb generates Gerber 274X photoplotting and Excellon drill files from PDFs of a PCB. Up to three PDFs are used: the top copper layer, the bottom copper layer (for 2-sided PCBs), and an optional silk screen layer. The PDFs can be created directly from any PDF drawing software, or a PDF print driver can be used to capture the Print output if the drawing software does not directly support output to PDF.

The general workflow is as follows:

  1. Design the PCB using your favorite CAD or drawing software.
  2. Print the top and bottom copper and top silk screen layers to a PDF file.
  3. Run Pdf2Gerb on the PDFs to create Gerber and Excellon files.
  4. Use a Gerber viewer to double-check the output against the original PCB design.
  5. Make adjustments as needed.
  6. Submit the files to a PCB manufacturer.

Please note that Pdf2Gerb does NOT perform DRC (Design Rule Checks), as these will vary according to individual PCB manufacturer conventions and capabilities. Also note that Pdf2Gerb is not perfect, so the output files must always be checked before submitting them. As of version 1.6, Pdf2Gerb supports most PCB elements, such as round and square pads, round holes, traces, SMD pads, ground planes, no-fill areas, and panelization. However, because it interprets the graphical output of a Print function, there are limitations in what it can recognize (or there may be bugs).

See docs/Pdf2Gerb.pdf for install/setup, config, usage, and other info.


pdf2gerb_cfg.pm

#Pdf2Gerb config settings:
#Put this file in same folder/directory as pdf2gerb.pl itself (global settings),
#or copy to another folder/directory with PDFs if you want PCB-specific settings.
#There is only one user of this file, so we don't need a custom package or namespace.
#NOTE: all constants defined in here will be added to main namespace.
#package pdf2gerb_cfg;

use strict; #trap undef vars (easier debug)
use warnings; #other useful info (easier debug)


##############################################################################################
#configurable settings:
#change values here instead of in main pfg2gerb.pl file

use constant WANT_COLORS => ($^O !~ m/Win/); #ANSI colors no worky on Windows? this must be set < first DebugPrint() call

#just a little warning; set realistic expectations:
#DebugPrint("${\(CYAN)}Pdf2Gerb.pl ${\(VERSION)}, $^O O/S\n${\(YELLOW)}${\(BOLD)}${\(ITALIC)}This is EXPERIMENTAL software.  \nGerber files MAY CONTAIN ERRORS.  Please CHECK them before fabrication!${\(RESET)}", 0); #if WANT_DEBUG

use constant METRIC => FALSE; #set to TRUE for metric units (only affect final numbers in output files, not internal arithmetic)
use constant APERTURE_LIMIT => 0; #34; #max #apertures to use; generate warnings if too many apertures are used (0 to not check)
use constant DRILL_FMT => '2.4'; #'2.3'; #'2.4' is the default for PCB fab; change to '2.3' for CNC

use constant WANT_DEBUG => 0; #10; #level of debug wanted; higher == more, lower == less, 0 == none
use constant GERBER_DEBUG => 0; #level of debug to include in Gerber file; DON'T USE FOR FABRICATION
use constant WANT_STREAMS => FALSE; #TRUE; #save decompressed streams to files (for debug)
use constant WANT_ALLINPUT => FALSE; #TRUE; #save entire input stream (for debug ONLY)

#DebugPrint(sprintf("${\(CYAN)}DEBUG: stdout %d, gerber %d, want streams? %d, all input? %d, O/S: $^O, Perl: $]${\(RESET)}\n", WANT_DEBUG, GERBER_DEBUG, WANT_STREAMS, WANT_ALLINPUT), 1);
#DebugPrint(sprintf("max int = %d, min int = %d\n", MAXINT, MININT), 1); 

#define standard trace and pad sizes to reduce scaling or PDF rendering errors:
#This avoids weird aperture settings and replaces them with more standardized values.
#(I'm not sure how photoplotters handle strange sizes).
#Fewer choices here gives more accurate mapping in the final Gerber files.
#units are in inches
use constant TOOL_SIZES => #add more as desired
(
#round or square pads (> 0) and drills (< 0):
    .010, -.001,  #tiny pads for SMD; dummy drill size (too small for practical use, but needed so StandardTool will use this entry)
    .031, -.014,  #used for vias
    .041, -.020,  #smallest non-filled plated hole
    .051, -.025,
    .056, -.029,  #useful for IC pins
    .070, -.033,
    .075, -.040,  #heavier leads
#    .090, -.043,  #NOTE: 600 dpi is not high enough resolution to reliably distinguish between .043" and .046", so choose 1 of the 2 here
    .100, -.046,
    .115, -.052,
    .130, -.061,
    .140, -.067,
    .150, -.079,
    .175, -.088,
    .190, -.093,
    .200, -.100,
    .220, -.110,
    .160, -.125,  #useful for mounting holes
#some additional pad sizes without holes (repeat a previous hole size if you just want the pad size):
    .090, -.040,  #want a .090 pad option, but use dummy hole size
    .065, -.040, #.065 x .065 rect pad
    .035, -.040, #.035 x .065 rect pad
#traces:
    .001,  #too thin for real traces; use only for board outlines
    .006,  #minimum real trace width; mainly used for text
    .008,  #mainly used for mid-sized text, not traces
    .010,  #minimum recommended trace width for low-current signals
    .012,
    .015,  #moderate low-voltage current
    .020,  #heavier trace for power, ground (even if a lighter one is adequate)
    .025,
    .030,  #heavy-current traces; be careful with these ones!
    .040,
    .050,
    .060,
    .080,
    .100,
    .120,
);
#Areas larger than the values below will be filled with parallel lines:
#This cuts down on the number of aperture sizes used.
#Set to 0 to always use an aperture or drill, regardless of size.
use constant { MAX_APERTURE => max((TOOL_SIZES)) + .004, MAX_DRILL => -min((TOOL_SIZES)) + .004 }; #max aperture and drill sizes (plus a little tolerance)
#DebugPrint(sprintf("using %d standard tool sizes: %s, max aper %.3f, max drill %.3f\n", scalar((TOOL_SIZES)), join(", ", (TOOL_SIZES)), MAX_APERTURE, MAX_DRILL), 1);

#NOTE: Compare the PDF to the original CAD file to check the accuracy of the PDF rendering and parsing!
#for example, the CAD software I used generated the following circles for holes:
#CAD hole size:   parsed PDF diameter:      error:
#  .014                .016                +.002
#  .020                .02267              +.00267
#  .025                .026                +.001
#  .029                .03167              +.00267
#  .033                .036                +.003
#  .040                .04267              +.00267
#This was usually ~ .002" - .003" too big compared to the hole as displayed in the CAD software.
#To compensate for PDF rendering errors (either during CAD Print function or PDF parsing logic), adjust the values below as needed.
#units are pixels; for example, a value of 2.4 at 600 dpi = .0004 inch, 2 at 600 dpi = .0033"
use constant
{
    HOLE_ADJUST => -0.004 * 600, #-2.6, #holes seemed to be slightly oversized (by .002" - .004"), so shrink them a little
    RNDPAD_ADJUST => -0.003 * 600, #-2, #-2.4, #round pads seemed to be slightly oversized, so shrink them a little
    SQRPAD_ADJUST => +0.001 * 600, #+.5, #square pads are sometimes too small by .00067, so bump them up a little
    RECTPAD_ADJUST => 0, #(pixels) rectangular pads seem to be okay? (not tested much)
    TRACE_ADJUST => 0, #(pixels) traces seemed to be okay?
    REDUCE_TOLERANCE => .001, #(inches) allow this much variation when reducing circles and rects
};

#Also, my CAD's Print function or the PDF print driver I used was a little off for circles, so define some additional adjustment values here:
#Values are added to X/Y coordinates; units are pixels; for example, a value of 1 at 600 dpi would be ~= .002 inch
use constant
{
    CIRCLE_ADJUST_MINX => 0,
    CIRCLE_ADJUST_MINY => -0.001 * 600, #-1, #circles were a little too high, so nudge them a little lower
    CIRCLE_ADJUST_MAXX => +0.001 * 600, #+1, #circles were a little too far to the left, so nudge them a little to the right
    CIRCLE_ADJUST_MAXY => 0,
    SUBST_CIRCLE_CLIPRECT => FALSE, #generate circle and substitute for clip rects (to compensate for the way some CAD software draws circles)
    WANT_CLIPRECT => TRUE, #FALSE, #AI doesn't need clip rect at all? should be on normally?
    RECT_COMPLETION => FALSE, #TRUE, #fill in 4th side of rect when 3 sides found
};

#allow .012 clearance around pads for solder mask:
#This value effectively adjusts pad sizes in the TOOL_SIZES list above (only for solder mask layers).
use constant SOLDER_MARGIN => +.012; #units are inches

#line join/cap styles:
use constant
{
    CAP_NONE => 0, #butt (none); line is exact length
    CAP_ROUND => 1, #round cap/join; line overhangs by a semi-circle at either end
    CAP_SQUARE => 2, #square cap/join; line overhangs by a half square on either end
    CAP_OVERRIDE => FALSE, #cap style overrides drawing logic
};
    
#number of elements in each shape type:
use constant
{
    RECT_SHAPELEN => 6, #x0, y0, x1, y1, count, "rect" (start, end corners)
    LINE_SHAPELEN => 6, #x0, y0, x1, y1, count, "line" (line seg)
    CURVE_SHAPELEN => 10, #xstart, ystart, x0, y0, x1, y1, xend, yend, count, "curve" (bezier 2 points)
    CIRCLE_SHAPELEN => 5, #x, y, 5, count, "circle" (center + radius)
};
#const my %SHAPELEN =
#Readonly my %SHAPELEN =>
our %SHAPELEN =
(
    rect => RECT_SHAPELEN,
    line => LINE_SHAPELEN,
    curve => CURVE_SHAPELEN,
    circle => CIRCLE_SHAPELEN,
);

#panelization:
#This will repeat the entire body the number of times indicated along the X or Y axes (files grow accordingly).
#Display elements that overhang PCB boundary can be squashed or left as-is (typically text or other silk screen markings).
#Set "overhangs" TRUE to allow overhangs, FALSE to truncate them.
#xpad and ypad allow margins to be added around outer edge of panelized PCB.
use constant PANELIZE => {'x' => 1, 'y' => 1, 'xpad' => 0, 'ypad' => 0, 'overhangs' => TRUE}; #number of times to repeat in X and Y directions

# Set this to 1 if you need TurboCAD support.
#$turboCAD = FALSE; #is this still needed as an option?

#CIRCAD pad generation uses an appropriate aperture, then moves it (stroke) "a little" - we use this to find pads and distinguish them from PCB holes. 
use constant PAD_STROKE => 0.3; #0.0005 * 600; #units are pixels
#convert very short traces to pads or holes:
use constant TRACE_MINLEN => .001; #units are inches
#use constant ALWAYS_XY => TRUE; #FALSE; #force XY even if X or Y doesn't change; NOTE: needs to be TRUE for all pads to show in FlatCAM and ViewPlot
use constant REMOVE_POLARITY => FALSE; #TRUE; #set to remove subtractive (negative) polarity; NOTE: must be FALSE for ground planes

#PDF uses "points", each point = 1/72 inch
#combined with a PDF scale factor of .12, this gives 600 dpi resolution (1/72 * .12 = 600 dpi)
use constant INCHES_PER_POINT => 1/72; #0.0138888889; #multiply point-size by this to get inches

# The precision used when computing a bezier curve. Higher numbers are more precise but slower (and generate larger files).
#$bezierPrecision = 100;
use constant BEZIER_PRECISION => 36; #100; #use const; reduced for faster rendering (mainly used for silk screen and thermal pads)

# Ground planes and silk screen or larger copper rectangles or circles are filled line-by-line using this resolution.
use constant FILL_WIDTH => .01; #fill at most 0.01 inch at a time

# The max number of characters to read into memory
use constant MAX_BYTES => 10 * M; #bumped up to 10 MB, use const

use constant DUP_DRILL1 => TRUE; #FALSE; #kludge: ViewPlot doesn't load drill files that are too small so duplicate first tool

my $runtime = time(); #Time::HiRes::gettimeofday(); #measure my execution time

print STDERR "Loaded config settings from '${\(__FILE__)}'.\n";
1; #last value must be truthful to indicate successful load


#############################################################################################
#junk/experiment:

#use Package::Constants;
#use Exporter qw(import); #https://perldoc.perl.org/Exporter.html

#my $caller = "pdf2gerb::";

#sub cfg
#{
#    my $proto = shift;
#    my $class = ref($proto) || $proto;
#    my $settings =
#    {
#        $WANT_DEBUG => 990, #10; #level of debug wanted; higher == more, lower == less, 0 == none
#    };
#    bless($settings, $class);
#    return $settings;
#}

#use constant HELLO => "hi there2"; #"main::HELLO" => "hi there";
#use constant GOODBYE => 14; #"main::GOODBYE" => 12;

#print STDERR "read cfg file\n";

#our @EXPORT_OK = Package::Constants->list(__PACKAGE__); #https://www.perlmonks.org/?node_id=1072691; NOTE: "_OK" skips short/common names

#print STDERR scalar(@EXPORT_OK) . " consts exported:\n";
#foreach(@EXPORT_OK) { print STDERR "$_\n"; }
#my $val = main::thing("xyz");
#print STDERR "caller gave me $val\n";
#foreach my $arg (@ARGV) { print STDERR "arg $arg\n"; }

Download Details:

Author: swannman
Source Code: https://github.com/swannman/pdf2gerb

License: GPL-3.0 license

#perl 

What is ElenaUSD (USE) | What is ElenaUSD token | What is USE token

In this article, we’ll discuss information about the ElenaUSD project and USE token

Introduction to Elena protocol

As Elena protocol is a 100% fair launch project, there was no VC, or pre-sale to raise capital for the expansion of the project, everything was self-funded by the founders. We have set up an eco-system vault for further development of ELENA.

We are introducing Elena Protocol and USE Stablecoin. The goal of USE is to peg to 1 USD. In the Genesis period, we will use DAI as collateral, 1 USE is 100% backed by 1 DAI. We are inspired by many outstanding algorithmic stablecoin projects, i.e. FEI, FRAX, FLOAT, and UST. With the combination of the best elements from those projects, we have created Elena protocol.

FRAX

We will be using the core structure from FRAX, in the genesis period, 100% of USE is minted from DAI. In order to encourage liquidity providers in the early stage, providing and staking USE/DAI LP will receive ELENA, and this is the only method to obtain ELENA. Due to 1 USE is backed by 1 DAI in the early stage, the liquidity mining has close to 0 Impermanent Loss. After the genesis, the collateral ratio will be lowered and ELENA will play an important role to back USE’s peg.

UST (LUNA)

At the moment, FRAX’s collateral rate is at around 85% to 90%. In an ideal situation, it should reach 0%, meaning that 100% of FRAX is minted by FXS. In this model, it is close to UST, as UST is 100% minted and redeemed from LUNA, which is the ultimate goal of USE.

FEI

The core structure of Elena protocol is inspired by FRAX, as the stability of FRAX is verified by the market. However, the collateral ratio of FRAX is not as good as it originally planned, as we can see it stayed at the range of 85%-90% for some time now. The main reason is that the volatility risk has been transferred to FXS, while FXS’s price at the moment is 100% decided by the market. There are many factors that are uncertain, including the volatility of the whole crypto market, as well as the emotion of the investors, this will still be impacted by the “bad weather”. Protocol Controlled Value (PCV) introduced by FEI, is a “visible hand” when the market is acting extremely, instead of exposure to 100% market risk, it is a more reasonable and better protocol to protect the whole system. This will achieve the goal to maximize the value and size of ELENA, for the investors, there is less worried about impairment loss by providing liquidity to USE/DAI. Compare with FRAX, 100% of the reward will be provided to USE/DAI liquidity pool, and ELENA’s liquidity is controlled by PCV. This makes Elena protocol potentially the highest APY in stablecoin mining.

FLOAT

We have implemented the “Oasis Vault” inspired by the design of Float Protocol. When USE is greater than 1 DAI, there are opportunities for arbitrage, the DAI used for minting USE will be saved in the Oasis Vault. This helps the efficiency of PCV, whereas having a direct impact on the liquidity of ELENA. In theory, the bigger the vault, the more stable the system, the better the liquidity of ELENA. When there is enough liquidity of ELENA, Oasis Vault + PCV will lower the collateral ratio, towards its ultimate goal, 0% collateral ratio.

In the future roadmap of Elena protocol, we will release a few products which use USE as stablecoin. Including synthetic assets, which creating more use cases for USE.

USE holders benefit from the mechanisms designed to create a high-fidelity peg and liquid exchange.

Protocol Design

As shown in the chart below, Elena protocol includes the following core units: USE Stablecoin, Oasis Vault, PCV, USE Pools, Staking, Incentive, ELENA Governance Token, and DAO.

USE Stablecoin

USE Token is an ERC20 Token with unlimited supply, adjusted by the market demand. USE as a stablecoin can be used in different use cases, i.e. exchange, store value, synthetic assets, lending, yield aggregators, etc.

Oasis Vault

Oasis Vault is the core module of Elena protocol, anyone can mint or redeem USE fixed at 1 DAI per USE. There is room for arbitrage due to the movement in the price of USE/DAI on Uniswap. i.e. When USE/DAI price is 0.9, you can purchase USE in Uniswap, and redeem it in the vault. Or if USE/DAI is trading at 1.1, you can mint USE with 1 DAI and sell it in Uniswap.

Mint

Vault can mint USE depends on the current collateral ratio. I.e. if the current collateral ratio is 99%, investors will need to provide 0.99 DAI and $0.01 worth of ELENA (assuming the price of ELENA is $10, then investors need to provide 0.001 ELENA), to mint 1 USE.

Redeem

Investors can redeem USE from the vault. If the current collateral ratio is 99%, after redemption, investors will get 0.99 DAI and $0.01 worth of ELENA(assuming the price of ELENA is $10, then investors will get 0.001 ELENA).

Please note that redemption will be closed if the reserve ratio falls below the threshold. When this happens, the investors can only sell their position of USE on Uniswap. When there is enough reserve, the redemption function will be available again. Through the activate/deactivate redemption function, the system is more stable and better protected from unexpected events.

Collateral Ratio

Collateral Ratio means when minting, the percentage of DAI required. The ratio will be adjusted periodically. When USE/DAI is greater than 1, means that there is more demand for USE in the market and investors have faith in the project. The collateral ratio will be adjusted to a lower number. In contrast, if USE/DAI is less than 1, meaning that there is less demand in the market, the collateral ratio will be adjusted higher.

At Genesis, the collateral ratio is set to 100%, meaning that to mint 1 USE, you will need to deposit 1 DAI to the vault. In the fractional period, the collateral ratio will be moving in between 100%, and 0%. If we reach uncollateral period, the collateral ratio will be 0%.

Reserve Ratio

When USE/DAI is trading above or below 1, the vault will still mint or redeem at 1, there are opportunities for arbitrage, when doing so, the price is pushed back to 1. When the price is below 1, the result of arbitrage is the reduction of the reserve. We define reserve ratio as:

vaultReserve: the number of DAI in the vault.

swapPoolReserve: the value of liquidity pool, i.e. the number of DAI in USE/DAI pool in Uniswap

The reserve ratio is an indicator of whether the protocol can survive in a massive dump. If the ratio is too small, meaning it is under-reserved. In most cases, the protocol should have enough reserve, as mentioned above, there is a policy to stop redemption when the reserve is too low, as well as other designs to protect USE peg to 1 DAI in the long term.

USE Pools

There are two pools on Uniswap, USE/DAI, and USE/ELENA. We will support more tokens in the vault and will have different pools on Uniswap. In order to incentivize investors providing liquidity, we will be running a liquidity mining program for USE/DAI. USE/ELENA’s liquidity will be provided and controlled by PCV, ensure the pool has better liquidity and reduced slippage.

PCV

The price control system of the Elena protocol has two parts: Oasis Vault, and USE/ELENA liquidity pool. The vault aims to ensure the pegging system works in the long term. USE/ELENA is controlled by PCV, the goal of PCV is to maintain a highly stable, deep liquidity stablecoin system, which benefits investors in the long term.

Price Oracle

We will use Uniswap TWAP Oracle Price to determine the current price of USE and ELENA.

Eco-system Vault

The vault will allocate an additional 2.5% ELENA to the vault when minting and redeeming. As well as 20% on the profit generated to liquidity providers. Please note that the allocation will not be minted directly, it will only happen when a payment is needed. This is the maximum percentage that can be minted, the actual number to be minted can be smaller than the maximum planned.

The fund from the vault will be used in the following areas:

  1. Marketing
  2. Advisors
  3. Developers’ Salary
  4. Airdrop
  5. Strategic Partners

Governance

The governance for a fair launch project is crucial. We use ELENA as governance tokens, the holders of ELENA are able to participate in the governance.

Including but not limited to:

  1. New tokens in the vault
  2. Adjust PCV’s target and rules
  3. Adjust reward
  4. Upcoming synthetic assets
  5. Airdrops

Fees

Compare with Frax, which charges up to 0.45% for minting and redeeming, USE charges **0 fees **for both activities.

Risk

Off Peg

The key point of whether USE can peg to 1 DAI is if arbitrage works. If when the price USE deviates from 1 DAI, if there is enough room for profit. This requires the vault to have enough reserve. When there is not enough reserve in the vault, it is likely that the protocol enters a death spiral.

Reserve Ratio is an indicator of whether the current reserve is sufficient, as well as if it is in a balanced position with its liquidity. In most cases, the reserve ratio will increase over time. When the collateral ratio is 100%, its sell-off pressure is as follows:

s: the percentage of sell-off, i.e. if 0.2 means there is 20% USE sell orders to USE/DAI pool

rr: reserve ratio

As can be seen above, it is a sub-linear curve, when s increases, its underlying reserve decreases, but it is smaller than a linear model.

When the collateral ratio is below 80%, things get a bit more complicated. As the reserve ratio is 80% (less than 100%), after the first sell-off doing arbitrage, the seller needs to sell 20% worth of ELENA, which makes the 2nd sell-off. After the 2nd sell-off repricing, there will be the 3rd sell-off, the arbitrager keeps doing so until there is no profit for doing so.

Based on this, we have a new generalized formula

Based on the formulas above, we studied the relationship between sell-off pressure in different collateral ratio and reserve ratio. This helps DAO better in terms of evaluating the risk level of the current system.

Elena Protocol Fractional Phase Quick Start Guide

Elena Protocol will officially move into the fractional stage on April 26, 2021 (UTC), which means that Elena will become more valuable because each time when minting USE, Elena is needed. The amount of Elena needed will vary with the update of the collateral rate. When the collateral rate decreases, the amount of ELENA required for minting USE will increase. Our goal is to gradually reduce the collateral rate from 100% to 0%. Then ELENA will eventually be used to mint USE, so ELENA will be always needed.

In the beginning, we decrease the collateral rate to 99%. For instance, if we want to mint 100 USE, it requires $99 of collateral which are 99 DAI, and an additional $1 worth of ELENA. The system will automatically calculate the amount of ELENA needed, and finally, click MINT 100USE.

Here we would like to demonstrate how to obtain ELENA. We have released a customized Swap page as requested by our investors. Due to Uniswap’s front-end restrictions, users can only use USE to purchase ELENA. This is inconvenient. To make life easier, we made an enhancement based on Uniswap’s open source codes (Thanks again to Hayden, you changed the world!) by updating the token swap routing (We will compose an article to explain how this was done, which is another interesting topic).

Via the customized Swap page,  https://swap.elena.finance, all popular tokens, such as ETH, DAI, USDC, USDT, WBTC, CRV, FRAX, YFI, etc., and ELENA can be traded directly. The Swap page can be accessed through the navigation bar at the homepage.

The same as minting USE, when redeeming USE, we will get DAI and ELENA based on the current collateral rate, correspondingly.

When we enter the number of USE to be redeemed, the system will automatically calculate the DAI and ELENA that will be collected. One important thing to keep in mind: Redeeming is a two step action: 1. Redeem, 2. Collect. After clicking REDEEM button, you still need to click COLLECT button to claim back your tokens (DAI and ELENA) into your wallet.

This two steps design of redeeming is a best practice for security reasons to avoid some malicious attacks, such as flashloan attacks.

The USE/DAI liquidity providers can always get rewards. After minting USE, staking USE-DAI LP tokens on the Staking page will continue receiving ELENA rewards.

Elena Protocol Liquidity Mining Quick Start Guide

Step1: mint USE

The ELENA protocol will incentivize the liquidity pool of USE/DAI. USE token can be minted through DAI and ELENA. When the collateral rate is 100%, 1 USE is minted by 1 DAI. As the collateral rate decreases, the **_percentage of _**ELENA as collateral will gradually increase during minting USE.

Before minting USE, we need to Approve it first, and then we enter the amount of DAI we want to mint, and the amount of ELENA needed will be automatically calculated based on the current collateral rate. Subsequently, we confirm and click the Mint button, and wait for the execution of the contract after interacting with Metamask.

Step2: Staking

After we receive the minted USE token, we could provide liquidity for the USE/DAI pool in Uniswap. We can jump to the Uniswap pair page by clicking the “add liquidity” link as shown on the page. After providing the liquidity in Uniswap, we could return to the Staking page to stake the USE-DAI LP token we just received. Here you need to click the “+” sign to stake.

Next, we need to fill in the number of USE-DAI LPs we want to stake in the pop-up window, then submit after confirmation. Now your liquidity mining starts, and your rewards are automatically calculated.

We can check the earnings in the panel on the left and withdraw the rewards at any time. If we want to quit liquidity mining, we can also click “UNSTAKE” button to withdraw the USE-DAI LP tokens from the contract. Note that no fees will be charged during all actions, all you need to pay is ETH gas fee.

At last, on the home page, we can see all the data of the Elena protocol, such as the test data shown below, the current collateral rate is 95%, the price of USE stablecoin is $0.9971, and the price of Elena is $156.2227. In the upper right corner, we can jump directly to Uniswap to buy or sell ELENA or USE.

How and Where to Buy ElenaUSD (USE)?

ElenaUSD token is now live on the Ethereum mainnet. The token address for ElenaUSD is 0x147E3d644d53ADadD18a28201b91e2B98aEB7f94. Be cautious not to purchase any other token with a smart contract different from this one (as this can be easily faked). We strongly advise to be vigilant and stay safe throughout the launch. Don’t let the excitement get the best of you.

Just be sure you have enough ETH in your wallet to cover the transaction fees.

You will have to first buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT), Binance (BNB)…

We will use Binance Exchange here as it is one of the largest crypto exchanges that accept fiat deposits.

Once you finished the KYC process. You will be asked to add a payment method. Here you can either choose to provide a credit/debit card or use a bank transfer, and buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT), Binance (BNB)…

SIGN UP ON BINANCE

Step by Step Guide : What is Binance | How to Create an account on Binance (Updated 2021)

Next step

You need a wallet address to Connect to Uniswap Decentralized Exchange, we use Metamask wallet

If you don’t have a Metamask wallet, read this article and follow the steps

What is Metamask wallet | How to Create a wallet and Use

Transfer $ETH to your new Metamask wallet from your existing wallet

Next step

Connect Metamask wallet to Uniswap Decentralized Exchange and Buy, Swap USE token

Contract: 0x147E3d644d53ADadD18a28201b91e2B98aEB7f94

Read more: What is Uniswap | Beginner’s Guide on How to Use Uniswap

The top exchange for trading in USE token is currently 

There are a few popular crypto exchanges where they have decent daily trading volumes and a huge user base. This will ensure you will be able to sell your coins at any time and the fees will usually be lower. It is suggested that you also register on these exchanges since once USE gets listed there it will attract a large amount of trading volumes from the users there, that means you will be having some great trading opportunities!

Top exchanges for token-coin trading. Follow instructions and make unlimited money

https://www.binance.com
  ☞ https://www.bittrex.com
  ☞ https://www.poloniex.com
  ☞ https://www.bitfinex.com
  ☞ https://www.huobi.com

Find more information USE

WebsiteExplorerExplorer 2Source CodeSocial ChannelSocial Channel 2Message BoardCoinmarketcap

🔺DISCLAIMER: The Information in the post isn’t financial advice, is intended FOR GENERAL INFORMATION PURPOSES ONLY. Trading Cryptocurrency is VERY risky. Make sure you understand these risks and that you are responsible for what you do with your money.

🔥 If you’re a beginner. I believe the article below will be useful to you

⭐ ⭐ ⭐ What You Should Know Before Investing in Cryptocurrency - For Beginner ⭐ ⭐ ⭐

I hope this post will help you. Don’t forget to leave a like, comment and sharing it with others. Thank you!

#blockchain #bitcoin #use #elenausd

Why Use WordPress? What Can You Do With WordPress?

Can you use WordPress for anything other than blogging? To your surprise, yes. WordPress is more than just a blogging tool, and it has helped thousands of websites and web applications to thrive. The use of WordPress powers around 40% of online projects, and today in our blog, we would visit some amazing uses of WordPress other than blogging.
What Is The Use Of WordPress?

WordPress is the most popular website platform in the world. It is the first choice of businesses that want to set a feature-rich and dynamic Content Management System. So, if you ask what WordPress is used for, the answer is – everything. It is a super-flexible, feature-rich and secure platform that offers everything to build unique websites and applications. Let’s start knowing them:

1. Multiple Websites Under A Single Installation
WordPress Multisite allows you to develop multiple sites from a single WordPress installation. You can download WordPress and start building websites you want to launch under a single server. Literally speaking, you can handle hundreds of sites from one single dashboard, which now needs applause.
It is a highly efficient platform that allows you to easily run several websites under the same login credentials. One of the best things about WordPress is the themes it has to offer. You can simply download them and plugin for various sites and save space on sites without losing their speed.

2. WordPress Social Network
WordPress can be used for high-end projects such as Social Media Network. If you don’t have the money and patience to hire a coder and invest months in building a feature-rich social media site, go for WordPress. It is one of the most amazing uses of WordPress. Its stunning CMS is unbeatable. And you can build sites as good as Facebook or Reddit etc. It can just make the process a lot easier.
To set up a social media network, you would have to download a WordPress Plugin called BuddyPress. It would allow you to connect a community page with ease and would provide all the necessary features of a community or social media. It has direct messaging, activity stream, user groups, extended profiles, and so much more. You just have to download and configure it.
If BuddyPress doesn’t meet all your needs, don’t give up on your dreams. You can try out WP Symposium or PeepSo. There are also several themes you can use to build a social network.

3. Create A Forum For Your Brand’s Community
Communities are very important for your business. They help you stay in constant connection with your users and consumers. And allow you to turn them into a loyal customer base. Meanwhile, there are many good technologies that can be used for building a community page – the good old WordPress is still the best.
It is the best community development technology. If you want to build your online community, you need to consider all the amazing features you get with WordPress. Plugins such as BB Press is an open-source, template-driven PHP/ MySQL forum software. It is very simple and doesn’t hamper the experience of the website.
Other tools such as wpFoRo and Asgaros Forum are equally good for creating a community blog. They are lightweight tools that are easy to manage and integrate with your WordPress site easily. However, there is only one tiny problem; you need to have some technical knowledge to build a WordPress Community blog page.

4. Shortcodes
Since we gave you a problem in the previous section, we would also give you a perfect solution for it. You might not know to code, but you have shortcodes. Shortcodes help you execute functions without having to code. It is an easy way to build an amazing website, add new features, customize plugins easily. They are short lines of code, and rather than memorizing multiple lines; you can have zero technical knowledge and start building a feature-rich website or application.
There are also plugins like Shortcoder, Shortcodes Ultimate, and the Basics available on WordPress that can be used, and you would not even have to remember the shortcodes.

5. Build Online Stores
If you still think about why to use WordPress, use it to build an online store. You can start selling your goods online and start selling. It is an affordable technology that helps you build a feature-rich eCommerce store with WordPress.
WooCommerce is an extension of WordPress and is one of the most used eCommerce solutions. WooCommerce holds a 28% share of the global market and is one of the best ways to set up an online store. It allows you to build user-friendly and professional online stores and has thousands of free and paid extensions. Moreover as an open-source platform, and you don’t have to pay for the license.
Apart from WooCommerce, there are Easy Digital Downloads, iThemes Exchange, Shopify eCommerce plugin, and so much more available.

6. Security Features
WordPress takes security very seriously. It offers tons of external solutions that help you in safeguarding your WordPress site. While there is no way to ensure 100% security, it provides regular updates with security patches and provides several plugins to help with backups, two-factor authorization, and more.
By choosing hosting providers like WP Engine, you can improve the security of the website. It helps in threat detection, manage patching and updates, and internal security audits for the customers, and so much more.

Read More

#use of wordpress #use wordpress for business website #use wordpress for website #what is use of wordpress #why use wordpress #why use wordpress to build a website

Royce  Reinger

Royce Reinger

1658068560

WordsCounted: A Ruby Natural Language Processor

WordsCounted

We are all in the gutter, but some of us are looking at the stars.

-- Oscar Wilde

WordsCounted is a Ruby NLP (natural language processor). WordsCounted lets you implement powerful tokensation strategies with a very flexible tokeniser class.

Features

  • Out of the box, get the following data from any string or readable file, or URL:
    • Token count and unique token count
    • Token densities, frequencies, and lengths
    • Char count and average chars per token
    • The longest tokens and their lengths
    • The most frequent tokens and their frequencies.
  • A flexible way to exclude tokens from the tokeniser. You can pass a string, regexp, symbol, lambda, or an array of any combination of those types for powerful tokenisation strategies.
  • Pass your own regexp rules to the tokeniser if you prefer. The default regexp filters special characters but keeps hyphens and apostrophes. It also plays nicely with diacritics (UTF and unicode characters): Bayrūt is treated as ["Bayrūt"] and not ["Bayr", "ū", "t"], for example.
  • Opens and reads files. Pass in a file path or a url instead of a string.

Installation

Add this line to your application's Gemfile:

gem 'words_counted'

And then execute:

$ bundle

Or install it yourself as:

$ gem install words_counted

Usage

Pass in a string or a file path, and an optional filter and/or regexp.

counter = WordsCounted.count(
  "We are all in the gutter, but some of us are looking at the stars."
)

# Using a file
counter = WordsCounted.from_file("path/or/url/to/my/file.txt")

.count and .from_file are convenience methods that take an input, tokenise it, and return an instance of WordsCounted::Counter initialized with the tokens. The WordsCounted::Tokeniser and WordsCounted::Counter classes can be used alone, however.

API

WordsCounted

WordsCounted.count(input, options = {})

Tokenises input and initializes a WordsCounted::Counter object with the resulting tokens.

counter = WordsCounted.count("Hello Beirut!")

Accepts two options: exclude and regexp. See Excluding tokens from the analyser and Passing in a custom regexp respectively.

WordsCounted.from_file(path, options = {})

Reads and tokenises a file, and initializes a WordsCounted::Counter object with the resulting tokens.

counter = WordsCounted.from_file("hello_beirut.txt")

Accepts the same options as .count.

Tokeniser

The tokeniser allows you to tokenise text in a variety of ways. You can pass in your own rules for tokenisation, and apply a powerful filter with any combination of rules as long as they can boil down into a lambda.

Out of the box the tokeniser includes only alpha chars. Hyphenated tokens and tokens with apostrophes are considered a single token.

#tokenise([pattern: TOKEN_REGEXP, exclude: nil])

tokeniser = WordsCounted::Tokeniser.new("Hello Beirut!").tokenise

# With `exclude`
tokeniser = WordsCounted::Tokeniser.new("Hello Beirut!").tokenise(exclude: "hello")

# With `pattern`
tokeniser = WordsCounted::Tokeniser.new("I <3 Beirut!").tokenise(pattern: /[a-z]/i)

See Excluding tokens from the analyser and Passing in a custom regexp for more information.

Counter

The WordsCounted::Counter class allows you to collect various statistics from an array of tokens.

#token_count

Returns the token count of a given string.

counter.token_count #=> 15

#token_frequency

Returns a sorted (unstable) two-dimensional array where each element is a token and its frequency. The array is sorted by frequency in descending order.

counter.token_frequency

[
  ["the", 2],
  ["are", 2],
  ["we",  1],
  # ...
  ["all", 1]
]

#most_frequent_tokens

Returns a hash where each key-value pair is a token and its frequency.

counter.most_frequent_tokens

{ "are" => 2, "the" => 2 }

#token_lengths

Returns a sorted (unstable) two-dimentional array where each element contains a token and its length. The array is sorted by length in descending order.

counter.token_lengths

[
  ["looking", 7],
  ["gutter",  6],
  ["stars",   5],
  # ...
  ["in",      2]
]

#longest_tokens

Returns a hash where each key-value pair is a token and its length.

counter.longest_tokens

{ "looking" => 7 }

#token_density([ precision: 2 ])

Returns a sorted (unstable) two-dimentional array where each element contains a token and its density as a float, rounded to a precision of two. The array is sorted by density in descending order. It accepts a precision argument, which must be a float.

counter.token_density

[
  ["are",     0.13],
  ["the",     0.13],
  ["but",     0.07 ],
  # ...
  ["we",      0.07 ]
]

#char_count

Returns the char count of tokens.

counter.char_count #=> 76

#average_chars_per_token([ precision: 2 ])

Returns the average char count per token rounded to two decimal places. Accepts a precision argument which defaults to two. Precision must be a float.

counter.average_chars_per_token #=> 4

#uniq_token_count

Returns the number of unique tokens.

counter.uniq_token_count #=> 13

Excluding tokens from the tokeniser

You can exclude anything you want from the input by passing the exclude option. The exclude option accepts a variety of filters and is extremely flexible.

  1. A space-delimited string. The filter will normalise the string.
  2. A regular expression.
  3. A lambda.
  4. A symbol that names a predicate method. For example :odd?.
  5. An array of any combination of the above.
tokeniser =
  WordsCounted::Tokeniser.new(
    "Magnificent! That was magnificent, Trevor."
  )

# Using a string
tokeniser.tokenise(exclude: "was magnificent")
# => ["that", "trevor"]

# Using a regular expression
tokeniser.tokenise(exclude: /trevor/)
# => ["magnificent", "that", "was", "magnificent"]

# Using a lambda
tokeniser.tokenise(exclude: ->(t) { t.length < 4 })
# => ["magnificent", "that", "magnificent", "trevor"]

# Using symbol
tokeniser = WordsCounted::Tokeniser.new("Hello! محمد")
tokeniser.tokenise(exclude: :ascii_only?)
# => ["محمد"]

# Using an array
tokeniser = WordsCounted::Tokeniser.new(
  "Hello! اسماءنا هي محمد، كارولينا، سامي، وداني"
)
tokeniser.tokenise(
  exclude: [:ascii_only?, /محمد/, ->(t) { t.length > 6}, "و"]
)
# => ["هي", "سامي", "وداني"]

Passing in a custom regexp

The default regexp accounts for letters, hyphenated tokens, and apostrophes. This means twenty-one is treated as one token. So is Mohamad's.

/[\p{Alpha}\-']+/

You can pass your own criteria as a Ruby regular expression to split your string as desired.

For example, if you wanted to include numbers, you can override the regular expression:

counter = WordsCounted.count("Numbers 1, 2, and 3", pattern: /[\p{Alnum}\-']+/)
counter.tokens
#=> ["numbers", "1", "2", "and", "3"]

Opening and reading files

Use the from_file method to open files. from_file accepts the same options as .count. The file path can be a URL.

counter = WordsCounted.from_file("url/or/path/to/file.text")

Gotchas

A hyphen used in leu of an em or en dash will form part of the token. This affects the tokeniser algorithm.

counter = WordsCounted.count("How do you do?-you are well, I see.")
counter.token_frequency

[
  ["do",   2],
  ["how",  1],
  ["you",  1],
  ["-you", 1], # WTF, mate!
  ["are",  1],
  # ...
]

In this example -you and you are separate tokens. Also, the tokeniser does not include numbers by default. Remember that you can pass your own regular expression if the default behaviour does not fit your needs.

A note on case sensitivity

The program will normalise (downcase) all incoming strings for consistency and filters.

Roadmap

Ability to open URLs

def self.from_url
  # open url and send string here after removing html
end

Are you using WordsCounted to do something interesting? Please tell me about it.

Gem Version 

RubyDoc documentation.

Demo

Visit this website for one example of what you can do with WordsCounted.


Contributors

See contributors.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Author: Abitdodgy
Source Code: https://github.com/abitdodgy/words_counted 
License: MIT license

#ruby #nlp 

Words Counted: A Ruby Natural Language Processor.

WordsCounted

We are all in the gutter, but some of us are looking at the stars.

-- Oscar Wilde

WordsCounted is a Ruby NLP (natural language processor). WordsCounted lets you implement powerful tokensation strategies with a very flexible tokeniser class.

Are you using WordsCounted to do something interesting? Please tell me about it.

 

Demo

Visit this website for one example of what you can do with WordsCounted.

Features

  • Out of the box, get the following data from any string or readable file, or URL:
    • Token count and unique token count
    • Token densities, frequencies, and lengths
    • Char count and average chars per token
    • The longest tokens and their lengths
    • The most frequent tokens and their frequencies.
  • A flexible way to exclude tokens from the tokeniser. You can pass a string, regexp, symbol, lambda, or an array of any combination of those types for powerful tokenisation strategies.
  • Pass your own regexp rules to the tokeniser if you prefer. The default regexp filters special characters but keeps hyphens and apostrophes. It also plays nicely with diacritics (UTF and unicode characters): Bayrūt is treated as ["Bayrūt"] and not ["Bayr", "ū", "t"], for example.
  • Opens and reads files. Pass in a file path or a url instead of a string.

Installation

Add this line to your application's Gemfile:

gem 'words_counted'

And then execute:

$ bundle

Or install it yourself as:

$ gem install words_counted

Usage

Pass in a string or a file path, and an optional filter and/or regexp.

counter = WordsCounted.count(
  "We are all in the gutter, but some of us are looking at the stars."
)

# Using a file
counter = WordsCounted.from_file("path/or/url/to/my/file.txt")

.count and .from_file are convenience methods that take an input, tokenise it, and return an instance of WordsCounted::Counter initialized with the tokens. The WordsCounted::Tokeniser and WordsCounted::Counter classes can be used alone, however.

API

WordsCounted

WordsCounted.count(input, options = {})

Tokenises input and initializes a WordsCounted::Counter object with the resulting tokens.

counter = WordsCounted.count("Hello Beirut!")

Accepts two options: exclude and regexp. See Excluding tokens from the analyser and Passing in a custom regexp respectively.

WordsCounted.from_file(path, options = {})

Reads and tokenises a file, and initializes a WordsCounted::Counter object with the resulting tokens.

counter = WordsCounted.from_file("hello_beirut.txt")

Accepts the same options as .count.

Tokeniser

The tokeniser allows you to tokenise text in a variety of ways. You can pass in your own rules for tokenisation, and apply a powerful filter with any combination of rules as long as they can boil down into a lambda.

Out of the box the tokeniser includes only alpha chars. Hyphenated tokens and tokens with apostrophes are considered a single token.

#tokenise([pattern: TOKEN_REGEXP, exclude: nil])

tokeniser = WordsCounted::Tokeniser.new("Hello Beirut!").tokenise

# With `exclude`
tokeniser = WordsCounted::Tokeniser.new("Hello Beirut!").tokenise(exclude: "hello")

# With `pattern`
tokeniser = WordsCounted::Tokeniser.new("I <3 Beirut!").tokenise(pattern: /[a-z]/i)

See Excluding tokens from the analyser and Passing in a custom regexp for more information.

Counter

The WordsCounted::Counter class allows you to collect various statistics from an array of tokens.

#token_count

Returns the token count of a given string.

counter.token_count #=> 15

#token_frequency

Returns a sorted (unstable) two-dimensional array where each element is a token and its frequency. The array is sorted by frequency in descending order.

counter.token_frequency

[
  ["the", 2],
  ["are", 2],
  ["we",  1],
  # ...
  ["all", 1]
]

#most_frequent_tokens

Returns a hash where each key-value pair is a token and its frequency.

counter.most_frequent_tokens

{ "are" => 2, "the" => 2 }

#token_lengths

Returns a sorted (unstable) two-dimentional array where each element contains a token and its length. The array is sorted by length in descending order.

counter.token_lengths

[
  ["looking", 7],
  ["gutter",  6],
  ["stars",   5],
  # ...
  ["in",      2]
]

#longest_tokens

Returns a hash where each key-value pair is a token and its length.

counter.longest_tokens

{ "looking" => 7 }

#token_density([ precision: 2 ])

Returns a sorted (unstable) two-dimentional array where each element contains a token and its density as a float, rounded to a precision of two. The array is sorted by density in descending order. It accepts a precision argument, which must be a float.

counter.token_density

[
  ["are",     0.13],
  ["the",     0.13],
  ["but",     0.07 ],
  # ...
  ["we",      0.07 ]
]

#char_count

Returns the char count of tokens.

counter.char_count #=> 76

#average_chars_per_token([ precision: 2 ])

Returns the average char count per token rounded to two decimal places. Accepts a precision argument which defaults to two. Precision must be a float.

counter.average_chars_per_token #=> 4

#uniq_token_count

Returns the number of unique tokens.

counter.uniq_token_count #=> 13

Excluding tokens from the tokeniser

You can exclude anything you want from the input by passing the exclude option. The exclude option accepts a variety of filters and is extremely flexible.

  1. A space-delimited string. The filter will normalise the string.
  2. A regular expression.
  3. A lambda.
  4. A symbol that names a predicate method. For example :odd?.
  5. An array of any combination of the above.
tokeniser =
  WordsCounted::Tokeniser.new(
    "Magnificent! That was magnificent, Trevor."
  )

# Using a string
tokeniser.tokenise(exclude: "was magnificent")
# => ["that", "trevor"]

# Using a regular expression
tokeniser.tokenise(exclude: /trevor/)
# => ["magnificent", "that", "was", "magnificent"]

# Using a lambda
tokeniser.tokenise(exclude: ->(t) { t.length < 4 })
# => ["magnificent", "that", "magnificent", "trevor"]

# Using symbol
tokeniser = WordsCounted::Tokeniser.new("Hello! محمد")
tokeniser.tokenise(exclude: :ascii_only?)
# => ["محمد"]

# Using an array
tokeniser = WordsCounted::Tokeniser.new(
  "Hello! اسماءنا هي محمد، كارولينا، سامي، وداني"
)
tokeniser.tokenise(
  exclude: [:ascii_only?, /محمد/, ->(t) { t.length > 6}, "و"]
)
# => ["هي", "سامي", "وداني"]

Passing in a custom regexp

The default regexp accounts for letters, hyphenated tokens, and apostrophes. This means twenty-one is treated as one token. So is Mohamad's.

/[\p{Alpha}\-']+/

You can pass your own criteria as a Ruby regular expression to split your string as desired.

For example, if you wanted to include numbers, you can override the regular expression:

counter = WordsCounted.count("Numbers 1, 2, and 3", pattern: /[\p{Alnum}\-']+/)
counter.tokens
#=> ["numbers", "1", "2", "and", "3"]

Opening and reading files

Use the from_file method to open files. from_file accepts the same options as .count. The file path can be a URL.

counter = WordsCounted.from_file("url/or/path/to/file.text")

Gotchas

A hyphen used in leu of an em or en dash will form part of the token. This affects the tokeniser algorithm.

counter = WordsCounted.count("How do you do?-you are well, I see.")
counter.token_frequency

[
  ["do",   2],
  ["how",  1],
  ["you",  1],
  ["-you", 1], # WTF, mate!
  ["are",  1],
  # ...
]

In this example -you and you are separate tokens. Also, the tokeniser does not include numbers by default. Remember that you can pass your own regular expression if the default behaviour does not fit your needs.

A note on case sensitivity

The program will normalise (downcase) all incoming strings for consistency and filters.

Roadmap

Ability to open URLs

def self.from_url
  # open url and send string here after removing html
end

Contributors

See contributors.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Author: abitdodgy
Source code: https://github.com/abitdodgy/words_counted
License: MIT license

#ruby  #ruby-on-rails