2017 m. spalio 23 d., pirmadienis

Crypto svetainės ir resursai

Naujienos:

https://www.ccn.com/
https://www.reddit.com/r/CryptoCurrency/

ICO:

https://www.icoalert.com/

Kriptovaliutų kainos:

 CoinMarketCap: https://coinmarketcap.com/
 BitScreener: https://bitscreener.com/
 BTC > USD/EUR skaičiuoklė: http://www.btcsatoshi.com/

Grafikai:

https://rollercoasterguy.github.io/
TradingView [Coinbase (GDAX), Bitstamp, Bitfinex, Poloniex, Bittrex]: https://www.tradingview.com/
Coinigy [Dauguma Exchanges, taip pat "Shitcoin Exchanges" kaip Cryptopia, YoBit]: https://www.coinigy.com/
CryptoWatch: https://cryptowat.ch/

Forumai:

Bitcointalk: https://bitcointalk.org/
Bitcointalk Altcoins temos: https://bitcointalk.org/index.php?board=159.0
Traders.Lt BTC Diskusijos: http://www.traders.lt/forums.php?m=posts&q=1945
BitcoinMarkets Subreddit: https://reddit.com/r/bitcoinmarkets/

Keityklos:

Bittrex: https://bittrex.com/ (Populiariausias ir šiuo metu geriausias altcoins exchange, BTC/USDT)
Poloniex: https://poloniex.com/ (Altcoins exchange, BTC/USDT)
Bitfinex: https://www.bitfinex.com/ (Didžiausias BTC/USD Volume)
Bitstamp: https://www.bitstamp.net/ (Yra BTC/EUR, SEPA pervedimai)
Kraken: https://www.kraken.com/ (Yra BTC/EUR, SEPA pervedimai)


Telefoniniai Appsai:

Blockfolio (iOS/Android) - Sekti portfolio/kainas
Tradingview (iOS) - Sekti kainas/grafikus
TabTrader (iOS/Android) - Exchange API trading(edited)

Kur galima tiesiogiai pirkti bitcoin/ltc
http://bittybot.co/uk/ - GBP
https://www.bitstamp.net/ - paypal
https://blockchain.info/ - kreditinės kortelės

Kiti:
Kripto žemėlapis - http://cryptomaps.org/
Bitcoin resursai - https://lopp.net/bitcoin.html
Tumblebit - Anonimizuotas bitcoin siuntimas.
xapo.com - Bitcoin kreditinė mokėjimo kortelė

Heroku

prerequisites 

$ pip install pipenv

$ git clone https://github.com/heroku/python-getting-started.git && cd python-getting-started

$ heroku create

$ git push heroku master

$ heroku ps:scale web=1

$ heroku open

Logs:

$ heroku logs --tail

Cloning existing app:


$ heroku apps
$ heroku git:clone -a myapp



Create a new Git repository

Initialize a git repository in a new or existing directory

$ cd my-project/
$ git init
$ heroku git:remote -a repository-name

$ git add .
$ git commit -am "make it better"
$ git push heroku master
Existing Git repository

For existing repositories, simply add the heroku remote
$ heroku git:remote -a flask-de


Heroku remote example:
https://git.heroku.com/flask-app.git 

Required files

Heroku app requires Procfile:
web: gunicorn app:app

Requirements.txt
gunicorn==19.6.0

Access website from:
https://flask-app.herokuapp.com/

2017 m. spalio 21 d., šeštadienis

python decorators

1. Simple decorator:

def decorator_function(passed_method):
    def returns_method():
        print("Decorating function: {}".format(passed_method.__name__))
        return passed_method()

    return returns_method


def speak():
    print("01101")


speak = decorator_function(speak)
speak()


Is same as:

def decorator_function(passed_method):
    def returns_method():
        print("Decorating function: {}".format(passed_method.__name__))
        return passed_method()

    return returns_method


@decorator_function
def speak():
    print("01101")

speak()


Output:
Decorating function: speak 
01101

1.2 Decoration with arguments:

def decorator_function(passed_method):
    def returns_method(*args, **kwargs):
        print("Decorating function: {}".format(passed_method.__name__))
        return passed_method(*args, **kwargs)

    return returns_method


@decorator_function
def speak(word):
    print(word)


@decorator_function
def say(argument):
    print(argument)


speak("Hello")
say("World is round")

Output:
Hello
Decorating function: say
World is round

2. Example: get function time decorator:

def function_time(passed_method):
    import time

    def returns_method(*args, **kwargs):
        t1 = time.time()
        result = passed_method(*args, **kwargs)
        time_span = time.time() - t1
        print("Function: {}, Time: {}".format(passed_method.__name__, time_span))

        return result

    return returns_method


@function_time
def process():
    return [x for x in range(10000)]


process()
Output:
Function: process, Time: 0.0006840229034423828

2017 m. spalio 19 d., ketvirtadienis

2017 m. spalio 18 d., trečiadienis

apt failed to fetch sources or download failed

Problem:
E: Failed to fetch http://repo.steampowered.com/steam/dists/precise/InRelease Unable to find expected entry 'steam/source/Sources' in Release file (Wrong sources.list entry or malformed file)

E: Some index files failed to download. They have been ignored, or old ones used instead.


Solution:

Go to:
$ cd /etc/apt/sources.list.d

And remove:
$ sudo rm steam.list

Problem:
Oracle JDK 6 is NOT installed.
dpkg: error processing package oracle-java6-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 oracle-java6-installer

E: Sub-process /usr/bin/dpkg returned an error code (1)

Solution:

$ sudo apt-get remove --purge  oracle-java6-installer

2017 m. spalio 15 d., sekmadienis

Microsoft SQL Server + pymssql

The default SQL port is 1433.

Linux install Microsoft SQL Server and tools here:
$ sqlcmd -S localhost -U SA -P password

Script location

/opt/mssql-tools/bin/sqlcmd
/opt/mssql-tools/bin/bcp

Some interesting SQL commands:

SELECT GETDATE()
2017-10-21 22:36:52.08

System catalog tables

SYSUSERS -  Database users
SYS.DATABASES  - All database segments
SYS.DATABASE_PERMISSIONS - All database permissions
SYS.DATABASE_FILES - All database files
SYSINDEXES - All indexes
SYSCONSTRAINTS - All constraints
SYS.TABLES - All database tables
SYS.VIEWS - All database views

Query's:

# Show all database
Select * from Sys.Databases

# Delete database from database
DROP DATABASE Database_name;

Python lib to connect to Microsoft SQL Server pymssql.

Connecting to database:

import pymssql
server = "localhost"
user = "SA"
password = "password"

conn = pymssql.connect(server, user, password, "TestDB")
cursor = conn.cursor()

Show all tables:
cursor.execute("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'")
for row in cursor:
    print("{}".format(row))

Get all table Inventory values:

cursor.execute("SELECT * FROM Inventory")
for row in cursor:
    print("{}".format(row))
conn.close()


Create table:

cursor.execute("""CREATE TABLE books (
               id INT NOT NULL,
               book_name VARCHAR(100),
               year VARCHAR(100),
               PRIMARY KEY(id)
               )
               """)
conn.commit()

Add entry to  to table:

cursor.execute("INSERT INTO books VALUES (1,'Freedom from known', 1955)")
con.commit()

2017 m. spalio 14 d., šeštadienis

SOAP and WSDL

SOAP originally stood for Simple Object Access Protocol, but it is no longer restricted in any way to object access or object-oriented use. Starting with version 1.2, the acronym is no longer officially spelled out; that is, "SOAP" is just a name. Although it originated from an industrial consortium, the XML Protocol Working Group of the W3C now has change control for new versions of SOAP. Here we give an overview of the features that SOAP includes and excludes, examine its relationship to XML, and list the basic SOAP namespaces.


The SOAP 1.1 specification required all services to use a SOAPAction header.

SOAP Faults
SOAP nodes return error or status information to a node from which they have received a message. They send back a SOAP message with a Body Block consisting of the Fault element in the soap-envelope namespace. Fault has two mandatory child elements, "faultcode" and "faultstring," and two optional child elements, "faultactor" and "detail."
  • The "faultstring" element has text content that is intended to be a human-readable explanation.
  • The "faultactor" element (fault actor) has a URI as its content to identify the actor at which the Fault occurred. It is optional only for ultimate receivers. All intermediate nodes generating a Fault element must provide a "faultactor" in any such Fault.
  • The "detail" element provides application-dependent additional information on a Fault generated by processing a message Body. You should not include this element for Header Block errors. Rather, the application must include it if the Body contents could not be processed successfully. Its presence indicates that the ultimate receiver at least processed some of the Body. The content and attributes of the "detail" element are application dependent. It can have an "encodingStyle" attribute. All element children of a "detail" element are called detail entries.
  • The "faultcode" element contains a namespace-qualified name.

Header:
The Header element namespace serves as a container for extensions to SOAP.
No extensions are defined by the specification, but user-defined extension ser-
vices such as transaction support, locale information, authentication, digital sig-
natures, and so forth could all be implemented by placing some information inside
the Header element. Children of the Header element may be annotated with the
mustUnderstand and/or actor attributes.

SOAP HTTP binding
SOAP defines a binding to the HTTP protocol. This binding describes the relation-
ship between parts of the SOAP request message and various HTTP headers. All
SOAP requests use the HTTP POST method and specify at least three HTTP head-
ers: Content-Type, Content-Length, and a custom header SOAPAction.
The actual SOAP message is passed as the body of the request or response.

Content-Type
Content-Type: text/xml; charset=character encoding
The Content-Type header for SOAP requests and responses specifies the
MIME type for the message and is always text/xml. It may also specify the
character encoding used for the XML body of the HTTP request or response. This
follows the text/xml part of the header values.


WSDL

 WSDL - Web Services Description Language .

WSDL provides a way of describing how to make request to SOAP service.

 A programmer would use WSDL to figure out what procedures are available from the SOAP server and what format of XML is expected by that procedure, and then write the code to call it.


The first task in a WSDL file is to define the information that will be sent to and from the service. A WSDL file builds the service up in levels. First, it defines the data to be sent and received, and then it uses that data to define messages.



SQL - Structured Query Language

The main categories are:
  • Data Definition Language (DDL) 
  • Data Manipulation Language (DML) - INSERT, UPDATE, DELETE 
  • Data Query Language (DQL) - SELECT 
  • Data Control Language (DCL) 
  • Data administration commands 
    • Transactional control commands 
    • COMMIT—Saves database transactions 
    • ROLLBACK—Undoes database transactions 
    • SAVEPOINT—Creates points within groups of transactions in which to 
    • ROLLBACK 
    • SET TRANSACTION—Places a name on a transaction

Very basic data types:
  • String types
  • Numeric types
    • BIT
    • DECIMAL
    • INTEGER
    • SMALLINT
    • BIGINT
    • FLOAT
    • DOABLE PRECISION
    • REAL
  • Date and time types
    •  DATE
    •  TIME
    •  DATETIME
    •  TIMESTAMP
  • Literal Strings
  • NULL

When using the NULL data type, it is important to realize that data is not required in a particular field. If data is always required for a given field,


Definitions
Acronyms:

Database Management system (DBMS)
Relational database management system (RDBMS)
Structured Query Language (SQL) 
American National Standards Institute (ANSI)

Open Database Connectivity (ODBC) 
JDBC is Java Database Connectivity (DBC)
Definitions:

Database is a collection of data.
Data is a collection of information stored in a database as one of several different data types.


A relational database is a database divided into logical units called tables, where tables are related to one another within the database.


A database object is any defined object in a database that is used to store or reference data.(tables, views, clusters, sequences, indexes, and synonyms)

A schema is a collection of database objects normally associated with one particular database username.

A transaction is a unit of work that is performed against a database accomplished using the Data Manipulation Language (DML) commands.
the transaction.

Three commands are used to control transactions:
  • COMMIT
  • ROLLBACK
  • SAVEPOINT

An aggregate
Function provides summarization information for an SQL statement, such as counts, totals, and averages.
  • COUNT
  • SUM
  • MAX/MIN
  • AVG
Character functions are functions that represent strings in SQL in formats different from the way they are stored in the table. 

Concatenation is the process of combining two strings into one. 

A subquery, also known as a nested query, is a query embedded within the WHERE clause of another query to further restrict data returned by the query.

Single query is one SELECT statement
Compound query includes two or more SELECT statements.

Index is a pointer to data in a table. (Like book index).

  • Single-Column Indexes
  • Unique Indexes
  • Composite Indexes
  • Implicit Indexes

SQL statement tuning is the process of optimally building SQL statements to achieve results in the most effective and efficient manner.

A trigger is a compiled SQL procedure in the database that performs actions based on other actions occurring within the database. 
Dynamic SQL allows a programmer or end user to create an SQL statement’s specifics at runtime and pass the statement to the database. 


2017 m. spalio 5 d., ketvirtadienis

xpath

XPath defines two terms—context node-set and context node— to help describe
how the location path evaluation process works. The context node-set is
defined as the current set of nodes that has been identified up to a given point in
the expression. The context node is defined as the current node being processed.


XPath defines several abbreviations 


XPath supports standard and/or boolean expressions. Each operand is evalu-
ated and coerced to a boolean (as if by calling the boolean function) before
evaluation.
To select an attribute using unabbreviated syntax, we can write the following:
attribute:: attributename
Or, in the abbreviated form, simply write the following:
@attributename


xpath="author"
Selects the child elements named author that do not belong to any namespace.

xpath="author|character"
Selects the child elements named author or character that do not belong to any
namespace.
xpath="lib:author"
Selects the child elements named author that belong to the namespace whose
prefix is "lib".
xpath="*"
Selects all the child elements.
xpath="lib:*"
Selects all the child elements that belong to the namespace whose prefix is "lib".
xpath="authors/author"
Selects all the authors/author child elements.
xpath=".//author"
Selects all the elements that are descendants of the current node, named author,
and don't belong to any namespace.
xpath="author/@id"
Selects the id attribute of the author child element (allowed only for xs:field,
and not for xs:selector).
xpath="@id|@name"
Selects @id or @name (valid only in xs:field, since attributes are forbidden in
xs:selector).
The following are forbidden:
xpath="/library/author"
Absolute paths are not allowed.
xpath="../author"
The parent axis is not allowed.