Fiddlers Jscript JSON.JsonDecode - fiddler

This is what I have:
public static var users=Fiddler.WebFormats.JSON.JsonDecode('[{key:"20048039", value:"Some Name"}, {key:"204130"...);
This is what I want:
users.JSONObject[0].key or users.JSONObject[0].value
This what I use for investigation:
FiddlerApplication.Log.LogFormat('output: {0}', users.JSONObject[0]);
output: System.Collections.Hashtable
I know c#, but in FiddlerScript I need some help to read these values inside users.
What shall I do here ?
thanks.

ok, I found the solution by myself(ArrayList,Hashtable):
users.JSONObject[0]["key"])

Related

Casting with Single<> on RxJava

I would like to know if there is a way to do a cast from Single<Object> to Single<CustomClass>.
I have a class that implements a method that should return a Single<Customer>, I implemented the search like here
Single.create(single -> {
CustomerServiceDto customer = mapper.map(customerRepository.findById(id).get(), CustomerServiceDto.class);
single.onSuccess(customer);
});
There isn't any problem. It's what I need. This create returns me a Single<Customer> but when I implement another function to handling an exception
Single.create(single -> {
CustomerServiceDto customer = mapper.map(customerRepository.findById(id).get(), CustomerServiceDto.class);
single.onSuccess(customer);
}).onErrorReturn(error -> new CustomerServiceDto());
It returns me a Single<Object>. Can I do a casting here? To avoid change the method's signature. I tried with the classic (Single<Customer>) Single<Object> instance, but it isn't work. Thanks for your advice.
The answer was the #dano's comment. Thanks, #dano.

Swifty way of naming a boolean property

1.
According to the swift API design guidelines, a boolean property should read as assertions

> Uses of Boolean methods and properties should read as assertions about
the receiver when the use is nonmutating,
e.g. x.isEmpty, line1.intersects(line2).
2.
I would like to make a computed property of which type is Boolean to the existing data type.
Here is a simplified version of my code:
struct State {
var authorID: String
var myID: String
var `XXX`: Bool {
return myID == authorID
}
}
I want the property XXX to stand for whether I am author or not.
I firstly came up with the names like authorIsMe, iAmAuthor, isAuthorMe, etc. but realized that it didn’t read as assertions about the receiver.
So, what name do you think fit best for XXX? Any idea will be appreciated.
Thank you
(Please do not consider inlining the expression myID == authorID because in the original code, it is not short as above so I need the computed property)
amITheAuthor is the best property name according to me as it will clearly throw the answer & its means of use , its a suggestion you can use this as well.

How to get Model Object using its name from a variable in Laravel 5?

I am trying to get information from a model using its name which is sent as parameter from blade using ajax call.
$.get("{{ url('auditInformation')}}", {modelName: modelName,versions:versions,currentData:currentData[index]});
Now i need to retrieve information using modelName from a model.
So when i tried this:
$auditInfo=Input::all();
$modelName=$auditInfo['modelName'];
$values=$modelName::find(1);
I got this response Class 'Designation' not found
But if i use
$modelName=new Designation();
$values=$modelName::find(1);
then it shows data exactly what i want.
So i understand that this is all about model ( class ) object.
Is there any way to assign object to $modelName using $auditInfo['modelName'] .
Thanks
If you want to do that way, you should use the model's namespace.
For example, if the 'Destination' model's namespace is app\Destination, you should use like this :
$auditInfo=Input::all();
$appPrefix = 'app';
$modelName=$appPrefix . '\' . $auditInfo['modelName'];
$values=$modelName::find(1);
This seems to be working
$table_name = "App\Models\PeopleYouMayLikeModel";
$obj = $table_name::where($column_name_identifier_1, '=', $row_identifier_1)
->where($column_name_identifier_2, '=', $row_identifier_2)->first();
The single backslash between the singe quote is considered as an escape sequence so use double backslash is 100% work. For example
public function index(Request $request) {
$model_prefix="App\Models";
$modal = $model_prefix.'\\'.$request->type;
$modal::updateOrcreate(['users_id'=>session("user")->users_id],$request->all())->save();
dd(Profile::all());
}
//Laravel 7.0

A query where the entity name is a variable

In Entity Framework 6 , is there any possibility to create a query where the entity name is a variable ?
For example :
Dim Ename as string
.....
....
Dim query= From t in context.[Ename] where "condition" select t
Is this possible ?
Thank you !
Another option would be to use this third-party library where you could write queries like this:
myDbContext.Set(Type.GetType("Ename"))
.Where("condition");
See
https://dynamiclinq.codeplex.com/
http://weblogs.asp.net/scottgu/dynamic-linq-part-1-using-the-linq-dynamic-query-library
It's probably not the way it's usually done, but you could use
myDbContext.Set(Type.GetType("Ename"))
.SqlQuery("SELECT * FROM dbo.Enames WHERE property = #p0", propertyValue");
See
https://msdn.microsoft.com/en-us/library/gg679544%28v=vs.113%29.aspx
https://msdn.microsoft.com/en-us/library/w3f99sx1.aspx
https://msdn.microsoft.com/en-us/library/system.data.entity.dbset.sqlquery(v=vs.113).aspx

PowerShell: Add Reference to COM Interface ID directly

Is there by any chance a posibility to create a reference to an Interface ID Directly.
I tried something in a syntax form like but didnt work ...
$CO = new-object -ComObject "System.__ComObject#{fafa4e17-1ee2-4905-a10e-fe7c18bf5554}"
This Interface id is from Virtualbox.VirtualBox itself
I know that I can reference it with VirtualBox.VirtualBox naturally.
Can you refernce interface ids directly .... ??
As long the Interface is Public I Think you can but i cant find any example . ??
Thanks:)
I found the solution to my own problem by accessing it through:
[System.Runtime.InteropServices.Marshal]::GetTypeFromCLSID('fafa4e17-1ee2-4905-a10e-fe7c18bf5554')
OR:
$Type = [Type]::GetTypeFromCLSID('fafa4e17-1ee2-4905-a10e-fe7c18bf5554')
$Vbox = [System.Activator]::CreateInstance($Type)
$Vbox.APIVersion
This answered my question; case closed :)