Cannot read property 'fromWIF' of undefined error - bitcoinjs-lib

Im trying create and sign a raw transaction with bitcoinjs-lib.
const assert = require('assert');
const ecpair = require('ecpair');
const bitcoin = require('bitcoinjs-lib');
var keys =new bitcoin.ecpair.fromWIF('cMvPQZiG5mLARSjxbBwMxKwzhTHaxgpTsXB6ymx7SGAeYUqF8HAT', bitcoin.networks.testnet);
this is my code and i get error "Cannot read property 'fromWIF' of undefined error" message.
i think i am making a mistake while adding the libraries.
bitcoinjs-lib version is 6 and using nodejs.
thank you.

Related

How to use SuppressGetDecimalInvalidCastException in vb.net

With some vb.net code I try to retrieve data from an Oracle database (simplified example):
strQuery = "Select 2.3, 2.3/1, 2.3/3.1 From Owner.TableName Where ROWNUM < 10"
Dim da As OracleDataAdapter
da = New OracleDataAdapter(strQuery, ConnectionString)
da.Fill(GetData)
This results in an "Specified cast is invalid" error.
The 2.3/3.1 is the problem.
I learned from "Specified cast is not valid" when populating DataTable from OracleDataAdapter.Fill() that Oracle works with a higher precision than dot net can handle and that I should use SuppressGetDecimalInvalidCastException in the OracleDataAdapter. But I don't know how to code it in VB.net. Can anyone help me?
Automatic translation from the C# code did not work.
The C# code itself did not work for me (probably due to the fact that I don't know how to handle the async stuff) and if I simplify it to
string queryString = "Select 2.3, 3.1 From owner.table";
string connectionString = "Data Source=Data.plant.be/database;User ID=****;Password=****";
var table = new DataTable();
var connection = new OracleConnection(connectionString);
var command = new OracleCommand(queryString, connection);
var adapter = new OracleDataAdapter(command) {
SuppressGetDecimalInvalidCastException = true
};
adapter.Fill(table);
I get error CS0117: OracleDataAdaptor does not contain a definition for SuppressGetDecimalInvalidCastException.
Extra info:
As proposed by #Andrew-Morton - thank you Andrew - I wrote:
Dim table = New DataTable()
Dim connection = New OracleConnection(ConnectionString)
Dim cmd = New OracleCommand(strQuery, connection)
Dim adapter = New OracleDataAdapter(cmd) With {.SuppressGetDecimalInvalidCastException = True}
adapter.Fill(GetData)
But I get BC30456: SuppressGetDecimalInvalidCastException is not a member of 'OracleDataAdapter'.
Remark: I have version 19.6 of Oracle.ManagedDataAccess.
I could not install package 'Oracle.ManagedDataAccess 21.9.0'. I Get: You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Account Summary Report Google Ads Script not sending emails after I added new metrics

I added conversion and revenue columns to the script which can be found here.
This is the error I'm getting in the logs (the spreadsheet is updating fine with no issues):
TypeError: newValue.indexOf is not a function
at formatChangeString (Code:366:33)
at emailRow (Code:314:11)
at Code:285:15
at Array.forEach (<anonymous>)
at sendEmail (Code:284:17)
at main (Code:106:7)
formatChangeString(newValue,oldValue) expects newValue to be a string (so that newValue.indexOf('%') can be called.
It seems that one of the metrics you added is returned by the AdsApp.report call as a different type (most likely Number).
If you want a quick workaround, just change the line
const isPercentage = newValue.indexOf('%') >= 0;
to
const isPercentage = String(newValue).indexOf('%') >= 0;

Simple observable/observer in rxjs

I've tried 2 different ways to setup an observer/observable to make this code work:
Setup #1:
var xObserver;
var xObservable = Rx.Observable
.create(observer => xObserver = observer)
.publish()
.refCount();
Setup #2:
var xObserver = Rx.Subject.create();
var xObservable = x;
Usage
xObserver.next('foo'); // no subscription yet, so nothing should happen
xObservable.subscribe(v => console.log(v)); // pipe values to console
xObserver.next('bar'); // push another value, should go to console
My expectation is for nothing to happen when "foo" is pushed to the observer, and for only "bar" to be shown on the console.
With "Setup #1" I get an error "TypeError: Cannot read property 'next' of undefined" which makes sense because no observer has subscribed yet so the xObserver is not initialized yet.
With "Setup #2" I get an error "TypeError: xObserver.next is not a function".
What am I doing wrong?
Use:
let xObs = new Rx.Subject();
When you use .create you have to supply an Observer, see the docs for details.
Another pitfall might be the version, in version < 5 there is only .onNext():
xObs.onNext("myData");
https://jsfiddle.net/mzkmuewf/
In version > 5, there is only .next():
xObs.next("myData");
https://jsfiddle.net/j1sksg7q/

IONotificationPortCreate function call generates compiler error

I am having an issue with the IONotificationCreatePort function in IOKit:
var NotificationPort = IONotificationPortCreate(MasterPort)
IONotificationPortSetDispatchQueue(NotificationPort, DispatchQueue)
gives the following compiler error when NotificationPort is used in the function call in the second line
'Unmanaged IONotificationPort' is not identical to
'IONotificationPort'
if I use the following code based on the information in the Using Swift with Cocoa and Objective-C document, it compiles but generates a runtime error
var NotificationPort = IONotificationPortCreate(MasterPort).takeRetainedValue()
IONotificationPortSetDispatchQueue(NotificationPort, DispatchQueue)
Thread 1: EXC_BAD_ACCESS(code=1, address=0xwhatever)
So I think I have the run time error figured out, the IONotificationPort object does not have takeRetainedValue method
The crux of the problem as I see it, is that the IONotificationPortCreate function creates an IONotificationPort object and returns the reference to it.
I have looked all over the place and there is lots of information about and ways to pass references into a function call from Swift but nowhere can I find how to deal with references as a return value.
Can Swift call an object by reference?
Or am I way off the mark here????
Here is the objective C code that I am trying to convert to swift:
_notificationPort = IONotificationPortCreate(masterPort);
IONotificationPortSetDispatchQueue(_notificationPort, _controllerQueue);
Here is the complete code snippet from my swift file:
//Get IOKit Master Port
var MasterPort: mach_port_t = 0
let BootstrapPort: mach_port_t = 0
var MasterPortReturnCode: kern_return_t = 0
MasterPortReturnCode = IOMasterPort(BootstrapPort, &MasterPort)
println("Master port returned as \(MasterPort) with return code of \(MasterPortReturnCode)")
//Set up notification port and send queue
let DispatchQueue = dispatch_queue_create("com.apparata.AVB_Browser", DISPATCH_QUEUE_SERIAL)
var NotificationPort = IONotificationPortCreate(MasterPort)
IONotificationPortSetDispatchQueue(NotificationPort, DispatchQueue)

Jython, ImageInfo

I trying to use ImageInfo and Jython to get information from a image on my harddrive.
I have imported the module fine but keep getting this error:
TypeError: setInput(): expected 2 args; got 1
And this is the code I am trying to use:
filename = "C:\\image.jpg"
img = ImageInfo.setInput(filename)
Could anyone point out what I am doing wrong.
Cheers
Eef
The missing argument Jython complains about is the ImageInfo object itself, which doesn't exist yet. You must construct it first. So:
filename = "C:\\image.jpg"
ii = ImageInfo()
img = ii.setInput(filename)
or
filename = "C:\\image.jpg"
img = ImageInfo().setInput(filename)
may work also.

Resources