Thursday, April 26, 2018

Python Beyond the Basics

Python tricks for Data Science
  • Alphanumeric fancy word for char.lower() in "0123456789abcdefghijklmnopqrstuvwxyz". Fun fact, "6".lower() is still "6"
  • You can get the size of your heap queue aka priority queue by taking the len() of the heapq variable. Example: heap = [] hq.heappush(heap, 3) len(heap) is now 1.
  • import random random.random() returns a number between 0 and 1, want it bigger? multiply by an integer: random.random()*5 or 5*random.random()
  • Python science, data, linear algebra library landscape: numpy for vectors matrices high level math functions. SciPy math classes and functions useful for scientists. PyLab combines other libraries to provide MATLAB like interface.

Monday, April 9, 2018

Sunday, April 1, 2018

Beginners' Glossary for Blockchain, Smart Contract and Bitcoin

Blockchain: defined by a distributed, decentralized public ledger, made of blocks, chained together using advanced mathematical computation (the crypto part) that is difficult to decode. Each transaction is validated by consensus and voting by existing records - maintained and worked by miners and distributed to all stakeholders within the decentralized network. Basically the transaction never disappears. Each contract is considered a smart contract, which can happen without the help of a centralized agency such as a bank or a central bank etc. Blockchain is not equal to Bitcoin. Bitcoin does utilize blockchain technology and cryptography to validate and maintain its blockchain, a public ledger, hence the name cryptocurrency.
While Bitcoin is the most popular cryptocurrency, there are other tokens exist in different ecosystems. Some startups have made Initial Coin Offering (ICO) offering consumers and investors to buy their tokens, which is usually seen as highly risky!

The Winklevoss twins, in the movie Social Network and previously co-founders / investors of Facebook, hold a sizable share of bitcoin. Bitcoin price recently oscillated violently after congress started to have hearing and IRS decided to pursue capital gain tax on Bitcoin sales. 50 Cents found out, years after filing bankruptcy, he once collected bitcoins from fans for his music album sales and now those coins are worth millions.

Some key players in the industry are: Etherum (platform for blockchain technology and smart contracts), its foundation, Ripple (a payment protocol), Coinbase (bitcoin wallet and bitcoin trading). Surprisingly Iceland, China and NVDIA because bitcoin miners in China have been mining bitcoins in mass and some of these powerhouses are located in Iceland, where a sizable of electricity is consumed by bitcoin mining. NVDIA because it manufactures the GPU and chips needed for these high power machines - especially those in transaction and hosted, bitcoin mining machines can be homemade.

However, remember bitcoin is a cryptocurrency and a very different concept from blockchain, a mathematical protocol and distributed data store. Bitcoin can be highly speculative. Blockchain technology can be applied in non-financial transactions. You can read more about innovative blockchain smart contract startups here

Saturday, March 31, 2018

Command Line Essentials Cheat Sheet

  • echo $PATH
  • changing the $PATH to optimize for basic unix commands can help save time. Very important for server maintenance.
  • // print current working directory
  • grep -n showing line number
  • less slash search
    wc word count
  • If need to approximate find or remember a command:
    apropos keyword
     apropos copy
  • PHP Command line: error log (have to turn the error log on first)
  • >tail -100f error.log
  • Generally heroku and phonegap may require commandline tools, in heroku it is known as the heroku command line toolbelt
  • Show and hide hidden files on mac


Just follow the steps below and your finder will show hidden files:-

Start your “Terminal”
type “defaults write AppleShowAllFiles TRUE” and enter (without the quote)
type “killall Finder” and enter (without quote)
Done. You have just enable your show hidden files in Finder
To disable the show hidden files in Finder, follow the steps below:-

Start your “Terminal”
type “defaults write AppleShowAllFiles FALSE” and enter (without the quote)
type “killall Finder” and enter (without quote)
Done. You have just disable your show hidden files in Finder

Testing Toolbox

Record clicks
insert blank line
s put an arrow on the line, play will handle it

Trie - Insert and Search | GeeksforGeeks

Implement Trie.