Skip to content

Instantly share code, notes, and snippets.

View horeaporutiu's full-sized avatar
🎾
Ballin

Horea Porutiu horeaporutiu

🎾
Ballin
View GitHub Profile
import flask
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
return "<h1>Distant Reading Archive</h1><p>This site is a prototype API for distant reading of science fiction novels.</p>"
{
"issuer": "MagnetoCorp",
"paperNumber": "123",
"issueDateTime": "2020-05-31",
"maturityDateTime": "2020-11-30",
"faceValue": "2000"
}
{
"issuer": "MagnetoCorp",
./byfn.sh down
./byfn.sh up
docker exec -it cli bash
**next commands are run from the peer cli**
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051
@horeaporutiu
horeaporutiu / hyperledger.txt
Created January 26, 2019 02:53
Commands / sites needed for Hyperledger contributions
$ git commit -s -m "[FAB-13903] typo...etc" // this is so gerrit connects back to jira issue: https://jira.hyperledger.org/browse/FAB-13903
$ git push origin HEAD:refs/for/master
@horeaporutiu
horeaporutiu / demoContract.js
Last active July 9, 2023 11:40
a Hyperleger Smart Contract that is able to retrieve the history of updates for a certain key
'use strict';
const { Contract } = require('fabric-contract-api');
class MyContract extends Contract {
//add a member along with their email, name, address, and number
async addMember(ctx, email, name, address, phoneNumber) {
let member = {
name: name,
address: address,
@horeaporutiu
horeaporutiu / introToAPI.py
Created January 4, 2019 21:23
make your first api call in python
# this is the module that helps us make API calls (requests)
import requests
# this module helps us print all aspects of the data returned from API call
from pprint import pprint
# to make a different API call, just change the url below to a API endpoint. Two examples, one pokemon, one for longitude and latitude
# response = requests.get("http://api.open-notify.org/iss-now.json")
response = requests.get("https://pokeapi.co/api/v2/pokemon/ditto")
pprint(vars(response))
@horeaporutiu
horeaporutiu / Deploy Hyperledger Composer business network
Last active March 4, 2019 03:47
Deploy Hyperledger Composer blockchain network to IBM Cloud - YouTube tutorial
--------------------------------------------------------------------------------------------------------------
--------------------------commands for Part 1 in YouTube tutorial starts here---------------------------------
--------------------------------------------------------------------------------------------------------------
//first need to clone directory to get all the needed files to deploy our blockchain network. All smart contract files are in contract directory
$ git clone https://github.com/IBM/blockchainbean.git
//install dependencies that we will use later
$ npm install -g [email protected]
$ npm install -g @ampretia/composer-wallet-cloudant
@horeaporutiu
horeaporutiu / conversation.js
Last active January 3, 2022 16:05
Call external API (Watson Translate) and return a promise
var request = require("request");
function translate(userInput) {
return new Promise((resolve, reject) => {
var data = {};
//Translate from en -> es (English to Spanish)
data.source = "en";
data.target = "es";
@horeaporutiu
horeaporutiu / conversation.js
Last active October 10, 2017 18:08
Trigger our 'translate' intent and call external API
var context = {};
conversation.message({
workspace_id: "your workspace id",
input: {"text": "translate this phrase."},
context: context
}, function(err, response) {
if (err)
console.log("error:", err);
else {
@horeaporutiu
horeaporutiu / conversation.js
Last active October 10, 2017 21:54
Watson Conversation instance
var watson = require("watson-developer-cloud");
var conversation = watson.conversation({
username: "Watson conversation username here",
password: "Watson conversation password here",
version: "v1",
version_date: "2017-05-26"
});