Skip to content

Commit

Permalink
Merge branch 'master' of github.com:omidraha/mystack
Browse files Browse the repository at this point in the history
  • Loading branch information
omidraha committed Nov 16, 2018
2 parents 4c26c8e + 9214adb commit 6b86f8c
Show file tree
Hide file tree
Showing 16 changed files with 429 additions and 94 deletions.
2 changes: 2 additions & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ Contents:
src/haproxy/haproxy
src/http/http
src/iptables/iptables
src/ipfs/ipfs
src/irc/irc
src/java/java
src/javascript/javascript
src/linux/linux
src/machine_learning/machine_learning
src/mercurial/mercurial
src/metasploit/metasploit
src/mobile/mobile
Expand Down
2 changes: 1 addition & 1 deletion src/blockchain/ethereum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ https://www.infura.io/register
signed = web3.eth.account.signTransaction(tx, pk)
final = web3.eth.sendRawTransaction(signed.rawTransaction)
print('final', final)
print('fin:', web3.toHex(final))
Expand Down
2 changes: 2 additions & 0 deletions src/deploy/deploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Contents:
etcd
patroni
ignite
faas




Expand Down
23 changes: 23 additions & 0 deletions src/deploy/faas.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Function as a service (FaaS)
============================



faas
----


https://github.com/openfaas/faas


kubeless
--------


https://github.com/kubeless/kubeless


fission
-------

https://github.com/fission/fission
5 changes: 2 additions & 3 deletions src/go/go.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Go
====
Go-Lang
=======


Contents:
Expand All @@ -8,5 +8,4 @@ Contents:
:maxdepth: 2

tips
intro

78 changes: 0 additions & 78 deletions src/go/intro.rst

This file was deleted.

90 changes: 90 additions & 0 deletions src/go/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,94 @@ Tips
====


Builtin function
----------------

http://golang.org/pkg/builtin/


Introduction to go programming language
---------------------------------------


Define slice
++++++++++++


.. code-block:: go
package main
import "fmt"
func main() {
var slice_1 []int
slice_2 := []int {}
slice_3 := make([]int, 0)
var slice_4 = []int {1, 2, 3, 4}
slice_5 := []int {1, 2, 3, 4}
slice_6 := make([]int, 0)
slice_6 = append(slice_6, 1, 2, 3, 4)
slice_7 := slice_4[:]
slice_8 := slice_5[0:4]
slice_9 := make([]int, 4) // [0 0 0 0]
copy(slice_9, slice_4)
fmt.Println(slice_1, slice_2, slice_3, slice_4, slice_5, slice_6, slice_7, slice_8, slice_9)
}
// [] [] [] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4] [1 2 3 4]
Notes:

* The first argument of ``make``, ``append`` and ``copy`` functions must be slice.

* The second argument of ``copy`` function also must be slice. (As a special case, it also will copy bytes from a string to a slice of bytes.)

* The ``copy`` function returns the number of elements copied, which will be the minimum of len(src) and len(dst).


.. code-block:: go
package main
import "fmt"
func main() {
slice_1 := []int {1, 2, 3, 4, 5}
slice_2 := []int {11, 22}
slice_3 := []int {111}
slice_4 := []int {}
count := copy(slice_1, slice_2)
fmt.Println(count, slice_1)
count = copy(slice_3, slice_2)
fmt.Println(count, slice_3)
count = copy(slice_4, slice_2)
fmt.Println(count, slice_4)
}
// 2 [11 22 3 4 5]
// 1 [11]
// 0 []
SET the GOPATH and GOROOT environments
--------------------------------------

.. code-block:: bash
$ export GOROOT=/usr/lib/go
$ export GOPATH=$HOME/go
$ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
https://stackoverflow.com/a/43553857
12 changes: 12 additions & 0 deletions src/ipfs/ipfs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
InterPlanetary File System (IPFS)
=================================



Contents:

.. toctree::
:maxdepth: 2

tips

90 changes: 90 additions & 0 deletions src/ipfs/tips.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Tips
====


Public IPFS Gateways
--------------------

https://ipfs.github.io/public-gateway-checker/


Docker usage
------------



.. code-block:: bash
$ export ipfs_staging=</absolute/path/to/somewhere/>
$ export ipfs_data=</absolute/path/to/somewhere_else/>
$ docker run -d --name ipfs_host -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/go-ipfs:latest
Watch log and Wait for ipfs to start:

.. code-block:: bash
$ docker logs -f ipfs_host
The ipfs is running when you see this on the log:

.. code-block:: bash
Gateway (readonly) server
listening on /ip4/0.0.0.0/tcp/8080
Connect to peers:

.. code-block:: bash
$ docker exec ipfs_host ipfs swarm peers
Add files:

.. code-block:: bash
$ cp -r <something> $ipfs_staging
$ docker exec ipfs_host ipfs add -r /export/<something>
https://github.com/ipfs/go-ipfs#docker-usage




Python usage
------------


.. code-block:: bash
$ pip install ipfsapi
.. code-block:: python
import ipfsapi
api = ipfsapi.connect('127.0.0.1', 5001)
res = api.add('test.txt')
res
{'Hash': 'QmWxS5aNTFEc9XbMX1ASvLET1zrqEaTssqt33rVZQCQb22', 'Name': 'test.txt'}
api.cat(res['Hash'])
'fdsafkljdskafjaksdjf\n'
api.id()
{'Addresses': ['/ip4/127.0.0.1/tcp/4001/ipfs/QmS2C4MjZsv2iP1UDMMLCYqJ4WeJw8n3vXx1VKxW1UbqHS',
'/ip6/::1/tcp/4001/ipfs/QmS2C4MjZsv2iP1UDMMLCYqJ4WeJw8n3vXx1VKxW1UbqHS'],
'AgentVersion': 'go-ipfs/0.4.10',
'ID': 'QmS2C4MjZsv2iP1UDMMLCYqJ4WeJw8n3vXx1VKxW1UbqHS',
'ProtocolVersion': 'ipfs/0.1.0',
'PublicKey': 'CAASpgIwgg ... 3FcjAgMBAAE='}
https://github.com/ipfs/py-ipfs-api#usage

18 changes: 18 additions & 0 deletions src/java/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,21 @@ Apache Maven, Eclipse and IntelliJ IDEA execute the following command:
https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get


Switch between installed java
-----------------------------

Configures the default for the program "java". That's the Java VM

.. code-block:: bash
$ sudo update-alternatives --config java
Configures the default Java compiler

.. code-block:: bash
$ sudo update-alternatives --config javac

0 comments on commit 6b86f8c

Please sign in to comment.