« first day (4122 days earlier)      last day (809 days later) » 

mr5
2:41 AM
@Wietlol I need your help please
Say, on Kotlin's interface, I have this:
private inline fun <reified TActivity: Activity> getImpl(): TActivity?
the body is omitted
On the implementing class, I have this workaround:
override fun <TActivity: Activity> get(): TActivity? {
    val instance = this as IActivityInstanceProvider
    return instance.get()
}
how, do I beautify the code to avoid the casting here?
also, on the interface, I am forced to declare some vars due to inline + reified limitation
 
that casting looks unnecessary
the get will still be the overridden function
so this should be 100% self recursive
 
mr5
ohhh
right
I'm trying to use the super<IActivityInstanceProvider>.get() but it's saying some error
Basically, I just want to store something by its type and I chose Set<T> as its container.
 
is the super get implemented?
 
mr5
so that's my approach
yes.
private inline fun <reified TActivity: Activity> getImpl(): TActivity? {
    return activityInstance.filterIsInstance(TActivity::class.java).firstOrNull()
}
 
just super.get() will do
 
mr5
2:47 AM
ah, no. the super.get() does not exist sorry
it's super.getImpl()
I'm going full circle here
 
if the getImpl is private, you cant call it
 
mr5
yeah
I tried the suggestion to convert to extension, now the issue is about reified
 
why?
 
mr5
it says, I have to convert the ConreteClass::get to inline + reified
when I converted the Inteface::get to an extension
is there a way to filter a type in Kotlin without using the javaClass?
 
can you give a snippet to show your actual code?
you can use the KType
but it all depends on what you want
and I am not even sure you actually want reified generics
 
mr5
2:56 AM
okay, I'll write a gist
KType?
 
where is the getImpl?
where is the reified?
 
mr5
I deleted it sorry
that was the previous versions
 
in any case, Class<*> is just like Type in C#
 
mr5
but I would like to avoid the inline + reified if possible
 
KType is a bit more detailed
for example, a KType can be a nullable type
KType also retains generic information
inline+reified is something you dont want to avoid
but something you want to introduce as wrapper for ease of use
 
mr5
3:07 AM
but if I use the inline + reified, I would be forced to declare variable in the interface
I was thinking, maybe the interface is not worth it
 
interface IActivityInstanceProvider
{
	fun updateInstance(activity: Activity)
	fun <TActivity : Activity> get(type: Class<TActivity>): TActivity?
}
inline fun <reified T : Activity> IActivityInstanceProvider.get(): T? =
	get(T::class.java)
your normal function uses just a parameter, while the inline function is a wrapper to have that parameter be inferred from the generic type
im still not sure what kind of variable you want in your interface
 
mr5
This is what I'm referring private val activityInstance: HashSet<WeakReference<Activity?>> = hashSetOf()
so if I inlined it in interface, I need to reference the container?
 
no
if you inlined it in the interface, you would just call the other get function
but you cant use inline in interfaces
only if it is private
but then it is probably useless
 
mr5
only if this is C#
override fun <TActivity : Activity> get(type: Class<TActivity>): TActivity? {
    val ref = activityInstance.firstOrNull { it.get()?.javaClass == type }
    return ref?.get() as? TActivity
}
Like this?
 
3:27 AM
what?
no
get() is a direct overload of get(type), one calls the other directly
the other doesnt call the first again
 
mr5
ref.get() is WeakReference
 
ah
then yes
although, you can probably refactor it a bit to only use a single get call on the weakreference
also, maybe use the cast function on type
 
mr5
how to use that case function?
 
generally speaking, type.cast(it)
but in your case, you also have a nullable value, so you probably want to avoid type.cast(null)
so you chain it using let
return ref?.get()?.let { type.cast(it) }
 
lol c# is better
 
3:33 AM
val activity = activityInstance
	.map { it.get() }
	.firstOrNull { it?.javaClass == type }
return activity?.let { type.cast(it) }
 
mr5
yeah lol
 
nah, C# is quite horrible at this stuff
 
mr5
@Wietlol good stuff!
thanks!
 
 
2 hours later…
mr5
@Wietlol but I would argue that it's efficient to map out the reference first before checking if that is what I really want.
 
 
1 hour later…
7:05 AM
@Wietlol Hi, could I really help Captian Obvious? Or you made a joke? I just have enough time and could do something useful.
 
7:36 AM
Morning all
Trained for 3 hours yesterday, boxing and Muai Thai straight after. No water... my brain was 😵‍💫
Feel like I've lost 5kg
 
but actually gained 1kg
 
Pure muscle baby
Now I am work - waiting to get home, get some fish & chips :D
with some vinegar :p
 
 
1 hour later…
8:54 AM
@kame he did have some powershell script shenanigans going on about adding records to the csproj file
2 days ago, by Botler
[Captain Obvious] I've made somthing truly terrible today boys
@mr5 you probably want to use an asSequence() first though
then you should have the most performant variant
or you might just be able to convert it to a HashMap<Class<in Activity>, WeakReference<in Activity>>
unless you want to change the == to isAssignableFrom
at which point, you could in theory ask for a supertype of the type you want and you would just get the first result
 
 
2 hours later…
10:51 AM
@Wietlol I know en.wikipedia.org/wiki/Pronunciation_of_"www"; dub-dub-dub as alternative
 
 
3 hours later…
2:07 PM
Hello All,

Does anyone know where to find a list of Oracle.EntityFramework packages and the Oracle database versions they are compatible with?

I'm trying to find the correct version for Oracle 10g.
 
I'm slightly confused that there are multiple packages
 
Sorry, poorly explained.

I'm trying to find which versions of Oracle.EntityFramework support Oracle 10g.

It would be good to fing a list of package versions vs database versions.
 
Hello everyone,

In order to learn the names of the songs playing on the radio, I try to send data to shazam api using the signalR library.

it can play song but i couldn't send it to shazam correctly. What should I do to get the right results? Which way should I go? Thanks for the helps.
 
G K
2:28 PM
Hi everyone,
Good evening here,
Does anyone have used Rhino mocks here? I have 1 small situation to handle.
 
Is Rhino a mocking framework?
I only know that as a JS engine.
 
G K
Yep
like NSubstitue, MoQ
Rhino mocks are also one of the mocking framework providers.
But my question is general and does need to be specific to any 1 framework.
Let me type.
I have an interface IABC and class that implements the interface ABC : IABC
I have a method which takes an interface as a parameter like below,

public void Method1(IABC abc)
{
var result = ((ABC)abc).SomeMethod();
}

In my unit test, I am mocking the IABC interface and injecting to that method. All fine.
But my test fails at that type casting line says that cannot able to cast.

I wanted the mock object should be castable to the concrete class. I am searching using Rhino mocks, but not getting any solutions.
 
Wow that is...amazingly stupid lol.
Like, why even accept an interface when you just go and depend on it being that specific class again
There are however mocking frameworks that let you make a mock of a specific class, not just an interface.
Which probably works by extending that class
 
G K
2:43 PM
Correct
A long back old code. Can't blame anyone now.
and its hard to touch that now.
Someone has posted this https://stackoverflow.com/q/19795112/1966993

It has an answer but that does not help.
 
If you don't find something for this particular framework, you can always extend the class yourself using a stub class.
 
G K
Yeah, I considered that as my last option. But giving a try here and there asking if someone has any sort of solutions for these kind .
 
 
2 hours later…
4:18 PM
Using WPF..
How can I create number of textboxes depending on the numeric value?
I know I can do something like ...
private void button1_Click(object sender, RoutedEventArgs e)
{
  var newTextBox = new TextBox();
  int enteredNum = (int)numValueFromTextBox;

     for (int i = 0; i < enteredNum; i++)
   {
       tbPanel.Children.Add(newTextBox);
   }
}
but using MVVM pattern.. it's going to be slightly more difficult.
ah got it
 
 
2 hours later…
6:17 PM
@learner Sorry was distracted. What shazam API are you using? Maybe I can take a look at it.
 
6:49 PM
Thank you so much for replying.I tried with rapid api.
1
Q: Shazam Api Data Processing

learnersite.js file "use strict"; var connection = new signalR.HubConnectionBuilder().withUrl("/radioHub").build(); function processData( ) { fetch("https://shazam.p.rapidapi.com/songs/detect", { "method": "POST", "headers": { "content-type

You can see what I've tried here.
 
Question, does anyone know of data analysis visualization software that will integrate into a SPA? What some of the best tools are?
 
@learner Right now you send an example string as the body. You have to record a part of the song, encode that in base64, and send that as the body.
@Greg If you only need something to visualize the data, I guess github.com/Blazor-Diagrams/Blazor.Diagrams might be a good one.
If you also need to actually analyse the data...the only tool I know that could do that is rapidminer AI hub.
 
@Squirrelkiller Was hoping to be more in line with HTML5 / JS / Canvas style.
Blazor might be a bit overboard.
I was hoping something like ChartJS but a bit more capability, or a tool that you can integrate on the backend to do some analysis for a chart.
 
do i need to use it with signalR?
 
@learner Looks like a simple REST API, no signalr required.
 
7:02 PM
I have to use signalR
 
1) record part of song (3-5 seconds)
2) make it 44100Hz, 1 channel (Mono), signed 16 bit PCM little endian
3) encode into a base64 string
4) Send with that fetch you already have in your code as `body`
Where does it say you have to use signalr?
You said rapidapi, so I went to rapidapi.com/apidojo/api/shazam and clicked on the detect v2 endpoint
Just a rest api, no signalr mentioned
 
it's not written anywhere
for learning
 
If you want to use signalr, don't try to use it on a rest api.
Same as you don't use a race car to move a container across the ocean.
race car just can't work on water
signalr doesn't do rest requests
your current signalr setup works well as it is right now
Except not for a connection to rapidapi, but as a connection between your browser and your server
 
radio channel servers
 
7:10 PM
I'm a little confused
Can't I send the radioUrl directly shazam api?
I can also use a different api.
alright,I will try as you said. Thank you very much for your helps.
 
8:05 PM
No you can't send a url to shazam, you have to send it an actual recording.
 
8:21 PM
I did understand.
 
So what's the plan? Use another API? Because I guess you won't find a signalr API you can use for this, as signalr is not usually used for public APIs.
REST APIs are just easier to secure and rate-limit.
Also the .NET SignalR client can also be used from Blazor, enabling C# frontend :)
 
should i continue with signalR?
using a different shazam api
 
It's definitely good to know SignalR, it's a nice and fast way for real time communication. But I think you won't find a way of directly connecting to shazam servers using SignalR.
 
8:37 PM
I thought of it as client server architecture.
server -> radio channels
client -> shazam (for the signalR library)
 
I don't really understand where exactly you want to connect the SignalR client to?
Right now, you have it connected to your own server:
Client <-SignalR-> Server
 
9:10 PM
I couldn't find examples on this topic and I trying to do it by trial and error method.
 
9:36 PM
What are you trying though? Do you still want to directly communicate with a shazam API using SignalR?
 
9:51 PM
yes, but you said is not possible to use signalR for this app
 

« first day (4122 days earlier)      last day (809 days later) »