Skip to content

Instantly share code, notes, and snippets.

View smdmts's full-sized avatar

Masatoshi Shimada smdmts

View GitHub Profile
@smdmts
smdmts / daffie-async-v2.3.js
Created September 7, 2020 12:39 — forked from dsetzer/daffie-async-v2.3.js
bustadice fastbet chase script
/******** SETTINGS ********/
const BASE_WAGER = 100; // Initial lowest possible bet to start with. (Satoshis)
const BASE_TARGET = 200; // Target payout to chase for. (Actual payout format 2.00x = 2.00)
const AUTO_MULTIPLE = false; // Auto calculate and override BET_MULTIPLE for BASE_TARGET.
const BET_MULTIPLE = 1.005; // Multiply bet by this value (1 = no increase) after each loss.
const BET_INCREASE = 0.1; // Increase bet by this flat amount after each loss. (Satoshis)
const TAR_MULTIPLE = 1; // Multiply target by this value (1 = no increase) on each loss.
const TAR_INCREASE = 0; // Increase target by this flat amount after each loss.
const MAX_WAGER = 5000 // Prevents script from placing bets larger than this amount.(Bits)
// Databricks notebook source
// MAGIC %fs
// MAGIC rm -r dbfs:/delta/poc/events
// COMMAND ----------
case class Data(a:Int,b:String)
val first = Seq(Data(1,"a")).toDF
@smdmts
smdmts / spark_add_hash_row.scala
Last active June 29, 2018 01:23
Spark2.0 : how to add hash row
import org.apache.spark.sql.types._
import java.security._
val df = sc.parallelize(Seq(
(1.0, 2.0), (0.0, -1.0),
(3.0, 4.0), (6.0, -2.3))).toDF("x", "y")
def mkMD5(text:String) = MessageDigest.getInstance("MD5").digest(text.getBytes).map("%02x".format(_)).mkString
def transformRow(row: Row): Row = Row.fromSeq(row.toSeq ++ Array[String](mkMD5(row.mkString(","))))
def transformRows(iter: Iterator[Row]): Iterator[Row] = iter.map(transformRow)
@smdmts
smdmts / bootstrap.sh
Last active September 11, 2017 06:40
#!/bin/bash
set -e
sudo wget http://dl.embulk.org/embulk-latest.jar -O /usr/bin/embulk
sudo chmod 755 /usr/bin/embulk
sudo mkdir -p /opt/embulk
sudo chmod 777 /opt/embulk
aws s3 cp s3://foo/secret/gcs_secret.json /opt/embulk/gcs_secret.json
embulk gem install embulk-decoder-remove_nonstandard_utf8_bytes
timezone: Asia/Tokyo
_export:
foo: ${1 + 1}
typeOfFoo: ${typeof foo}
incr: ${parseInt(foo) + 1}
+task:
loop>: ${parseInt(incr)}
_do:
@smdmts
smdmts / StreamFlowWithFuture.scala
Created December 15, 2016 06:58
example flow with future.
import akka.actor.ActorSystem
import akka.stream.{ActorAttributes, ActorMaterializer, FlowShape, Supervision}
import akka.stream.scaladsl.{Flow, GraphDSL, Sink, Source}
import scala.concurrent.Future
/**
* StreamFlowWithFuture.
*/
object StreamFlowWithFuture {
timezone: UTC
_export:
abc : efg
+show1:
sh>: echo ${abc}
+override:
sh>: echo ${this.abc="hij"}
@smdmts
smdmts / fake_digdag.py
Created July 21, 2016 09:26
digdag for testing.
import sys
import imp
import collections
digdag_env_mod = sys.modules['digdag_env'] = imp.new_module('digdag_env')
digdag_env_mod.params = {}
digdag_env_mod.subtask_config = collections.OrderedDict()
digdag_env_mod.export_params = {}
digdag_env_mod.store_params = {}
_export:
path_prefix: ['abc' , 'efg' , 'hig']
+echo:
sh>: echo ${this}
_export:
path_prefix: ['abc' , 'efg' , 'hig']
+repeat:
loop>: ${path_prefix.length}
_do:
+step:
sh>: echo ${path_prefix[i]}