Skip to content

Instantly share code, notes, and snippets.

from aws_xray_sdk.core import xray_recorder
##HIDE @xray_recorder.capture('transfer_funds')
def money_transfer(from_acc_id, to_acc_id, value):
##HIDE xray_recorder.begin_subsegment('lock_funds')
money_locked = enough_and_lock(from_acc_id, value)
##HIDE xray_recorder.end_subsegment()
if money_locked:
##HIDE xray_recorder.begin_subsegment('transfer funds via ' + money_locked.payment_gateway)
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture('transfer_funds')
def money_transfer(from_acc_id, to_acc_id, value):
xray_recorder.begin_subsegment('lock_funds')
money_locked = enough_and_lock(from_acc_id, value)
xray_recorder.end_subsegment()
if money_locked:
xray_recorder.begin_subsegment('transfer funds via ' + money_locked.payment_gateway)
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture("get_balance")
def get_balance(user_acc_id):
""" ... """
...
@mwacc
mwacc / MyFirstTF.py
Last active March 27, 2019 22:02
fourth-degree polynomial using Halley's Method.
import tensorflow as tf
import numpy as np
print(tf.__version__)
def calc_fx1(fx, x):
return tf.gradients(fx, x)[0]
def calc_fx2(fx, x):
return tf.gradients(tf.gradients(fx, x)[0], x)[0]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
import random
import datetime
TNX_NUM = int(sys.argv[1])
ACCOUNT_NUM = int(sys.argv[2])
RATES_NUM = int(sys.argv[3])
PAR_ID = int(sys.argv[4])
def get_random(top_limit):
@mwacc
mwacc / gist:c04636a1b25409db9257
Created October 7, 2015 16:16
create maven project
# Spark scala project
mvn archetype:generate -B -DarchetypeGroupId=net.alchim31.maven -DarchetypeArtifactId=scala-archetype-simple -DarchetypeVersion=1.5 -DgroupId=org.apache.spark -DartifactId=<Project name> -Dversion=0.1-SNAPSHOT -Dpackage=org.apache.spark
# flink project
mvn archetype:generate \
-DarchetypeGroupId=org.apache.flink \
-DarchetypeArtifactId=flink-quickstart-scala \
-DarchetypeVersion=0.9.1 \
-DgroupId=org.apache.flink.quickstart \
-DartifactId=flink-scala-project \
@mwacc
mwacc / hug_rhadoop.R
Created June 18, 2014 11:16
rhadoop demo for Lviv HUG
library(rmr2)
rmr.options(backend = "local")
#hdfs.init()
lm.map =
function(., line) {
keyval( line[[1]], paste(line[[2]], line[[3]], sep="|"))
}
@mwacc
mwacc / car-analysis.groovy
Created June 13, 2014 17:46
example of groovy script + selenium webdriver (maven artefact is loaded by anotation)
@Grab(group="org.seleniumhq.selenium", module="selenium-java", version="2.42.2")
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.*;
System.setProperty("webdriver.chrome.driver", "/Users/kostya/Downloads/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--verbose", "--ignore-certificate-errors");
WebDriver driver = new ChromeDriver();
@mwacc
mwacc / abalone.r
Created January 14, 2014 15:40
linear regression and automatic formula building and best result pick up
library(ggplot2)
# read dataset from local file
abalone <- read.csv("/Users/kostya/Downloads/abalone.data.csv", header=F)
# set names for dataframe columns
colnames(abalone) <- c('Sex', 'Length', 'Diameter', 'Height', 'WholeWeight', 'ShuckedWeight',
'VisceraWeight', 'ShellWeight', 'Rings')
# plot histogram