Cname To S3 Bucket

August 10, 2017

The url you get for a S3 hosted web site is a bit long. You might want to set up a subdomain from your domain that points to your S3 hosted site. The trick to do this involves how you name your bucket.

Here is an example.

Suppose your domain is mydomain.com and you want to setup a subdomain myapp.mydomain.com which points to a S3 hosted website.

To make this work the key is to create a bucket called myapp.mydomain.com. This will give you a endpoint of http://myapp.mydomain.com.s3-website-us-west-2.amazonaws.com.

Now, when you setup your CNAME record have your myapp.mydomain.com name point to myapp.mydomain.com.s3-website-us-west-2.amazonaws.com.


Continue reading →

Redirect From S3 Website

August 9, 2017

So after setting up a few S3 hosted sites what happens if you want to move your site to another place. Say, you want to host the site over on an EC2 instance but you've already handed out the long url to your S3 bucket. It may be useful to have a redirect setup on the S3 bucket. Here is how to set that up.

Step 1

Remove all your files except for the index.html. Then edit the index.html and remove all of it's content except the most basic of html. This is just so you don't have anything left of your site in the bucket.

Step 2

Click on the index.html file and then click on Properties and follow that with a click on the Metadata box.

Here you want to add a key. Select Add Key and then select Website-Redirect-Location. For the value enter the url you'd like to redirect o.


Continue reading →

S3 Website Hosting

August 8, 2017

You can host a static web site simply using a S3 bucket. To do so create your bucket and select it in the AWS console.

Properties

Select properties tab and then click on the 'Static website hosting' box. When prompted note the end point as this will be the url to your site. Then select 'Use this bucket to host a website'. Enter the appropriate index document. Typically, it will be index.html but if you have a different default page enter it here and save the prompt.

Permissions

Select the permissions tab and then click on the 'Bucket Policy' button. Here you will want to add a new policy. Use the following template and replace <YOUR BUCKET HERE> with the name of your bucket.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<YOUR BUCKET NAME HERE>/*"
        }
    ]
}

Review

At this point you should be able to try the end point your noted above.


Continue reading →

Emacs And Solidity

August 7, 2017

After working with Solidity for a while and using javascript-mode it finally dawned on me to look for a Solidity mode and viola one exists.

Try package-list in Emacs and look for `solidity-mode'

solidity-mode      20170712.1442 installed             Major mode for ethereum's solidity language

If you don't see it you will need to point to MELPA so package.el can find it. See the repo link below for more details.


Continue reading →

Creating a private Ethereum testnet

August 6, 2017

Working against a local private testnet is very useful when you are developing your own smart contracts for Ethereum. It is faster and you don't have to worry about ether and having enough for gas.

testrpc

One of the simplest methods to run a local testnet is to install testrpc. When done just run the command testrpcs and you'll have a local node with accounts running for you to excercise your code against.

Your own network

At some point you'll want to move up a level and create your own local network. You might simply be curious as to how to do it or you may want to customize things a bit or you need to start a network with multiple machines for testing more real life scenarios.

To do this isn't all that difficult. A good starting point is the Homestead documentation. Here is a link to the section for details using Geth. http://www.ethdocs.org/en/latest/network/test-networks.html#id3

Note: The example genesis file as of today has an issue with the latest Geth (1.6) so feel free to use this example file which I've used successfully.

  {
      "config": { }, "nonce": "0x0000000000000042",     "timestamp": "0x0",
      "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "extraData": "0x00",     "gasLimit": "0x8000000",     "difficulty": "0x400",
      "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "coinbase": "0x3333333333333333333333333333333333333333",     "alloc": {     }
  }

Continue reading →

Installing The Solidity Plugin Into Webstorm And PyCharm

August 5, 2017

The following instructions work for other JetBrains environments. Here I only added the Solidity plugin to WebStorm and PyCharm.

The latest version of the Solidity plugin is available here: https://plugins.jetbrains.com/plugin/9475-intellij-solidity

Procedure

- Download plugin
  - Zip file
  - Do not uncompress
  - Copy to it's own directory

- WebStorm/PyCharm -> Properties
  - Plugins
  - Install Plugin from Disk

- Restart WebStorm/PyCharm

Continue reading →

Cryptop

August 4, 2017

I found an interesting tool which I've been using to show current cryptocurrency values. It is called Cryptop. It is a Python app which shows current values for a cryptocurrency portfolio.

See it's git repo for the detail on how to install and run.

If you want the green screen shown in the instructions edit the config.ini in .crypto directory which is created after you first run the app. Change the default values to the following.

[theme]
text=green
banner=green
banner_text=black
background=black

Continue reading →

Get Hyperlink Value From An Excel Cell

August 3, 2017

I received a spreadsheet with a list of addresses setup so you can click the name in the cell and it would open. I wanted to export the actual url which is inside the cell.

You can do this with a function. Open the VBA editor with Fn/Option F11 on the Mac. Then Open Modules and insert a new module with a name of your choosing.

Paste in the following function, save and exit the VBA editor

Function GetCellURL(cell As Range) As String
     On Error Resume Next
     GetCellURL = cell.Hyperlinks(1).Address
End Function

Then visit your spreadsheet and start a new column and use your function to reference a cell that has a hyperlink.

=GetCellUrl(A1)

Continue reading →

Default ssh usernames for ec2 instances

August 2, 2017

I started a project with many different ec2 instance types and found the following link very useful recently.

https://alestic.com/2014/01/ec2-ssh-username/


Continue reading →

Cleaning Global Installs With Pip

August 1, 2017

I moved to Python3 and looked back and realized I had a ton of things installed globally for Python2. With this realization I wanted to clean everything out.

Here is one method

$ pip freeze > requirements.txt
$ pip uninstall -y -r requirements.txt

Continue reading →

Get Ip Address Of Ec2 Instance

July 31, 2017

A quick command to figure out what your IP address is.

$ curl checkip.amazonaws.com

Continue reading →

Amazon Linux Ami

July 30, 2017

  • Based on CentOS/Redhat and you can use Redhat/Centos repositories
  • Has better integration and has EC2 management tools pre-installed
  • There may be issues at times due to dependency issues
  • One potential issue is you can't run Amazon Linux outside of EC2
  • Local/developer builds may be on their own RHEL/Centos but there may be slight differences

Continue reading →

Rename Group Of File Extensions In Git

July 29, 2017

For this example, I had a collection of text files with embedded mode lines to setup the mode for org-mode. I wanted to do away with the mode line and rename them from txt files to org files.

Build the GLOB before hand and verify with ls. For example ls *.txt would have the GLOB value in the example replaced with *.txt.

The git mv renames the files.

for i in $(find . -iname "GLOB"); do
    git mv "$i" "$(echo $i | rev | cut -d '.' -f 2- | rev).org";
done

Continue reading →

Upgrade To Java 1.8 On Ec2

July 28, 2017

Update to Java 1.8 on EC2

- sudo yum install java-1.8.0
- sudo yum remove java-1.7.0-openjdk

Continue reading →

Ethereum Get Eth Balance Script

July 27, 2017

The site Etherscan allows you retrieve information on accounts and transactions. There is an interface to the Reposten testnet as well. While doing some work on a project I was monitoring the page to view an account balance and ended up creating a script to do the monitoring programmatically.

The repo listed at the bottom of the page contains the python script which simply parses the page and returns the balance.

The main routine after figuring out which chain the user wants to look at and which account is the get_balance routine. It parses the page and finds the balance in the first table's first row, second cell.

def get_balance(url):
    html = requests.get(url, headers={'User-agent': 'Mozilla/5.0'}).text
    soup = BeautifulSoup(html, "html.parser")
    table = soup.find("table", {"class" : "table"})
    value = table.findAll('td')[1].text.split(' ')[0].strip()
    return value


Continue reading →