PHPStorm / IntelliJ IDEA Live Template string "$" concatenation - laravel

Does anyone know how to prefix a "$" next to a $STRING$ entry? $$STRING$ seems to remove the ability for the template system to recognise this as an input variable.
While we are on the topic, is it possible to concatenate/edit a previously declared variable in the variable editor? So setting:
$STRING$'s default to: $VAR$ . "suffix"
Both of these would be very useful!!
Cheers

Short answer: Just use $$ (therefore $$$STRING$).
To clarify the OP's problem with an example:
Imagine that you wanted to have an n live template (macro) that creates a new instance of a class and stores it in a variable of the same name (Netbeans users will know :) ).
So if you used the n macro and typed Person, the output would be $person = new Person();
And since you want to autocomplete the $person variable based on Person class, you need to have $<variable> = new <Class>();, which translates to $$$VAR$ = new $CLASS$(); $END$ in PhpStorm.
For anyone interested in the full n live template:
My answer is indirectly based on this answer.

Related

Get extract value from fact

Im pretty new to prolog, and got stuck.
I need to store a variable with some string during calculations, I decided to do this by adding a "single fact" to the class I'm working with. Everything works well, the string is being stored, but when I try to add the code to access it later on, compiler returns an error "The expression has type 'dataBL::dataBL#objectDB', which is incompatible with the type '::symbol'".
I dont think it is the valid way to store a variable, so, can anyone help me with that? I tried searching online for the answers, and found nothing.
I'm trying to access the fact like this:
getString(U) :-
U = stringStorage(_).
If I get you right you need to store a value associated with some variable ID (key) as a fact. The (abstract) solution for your task canas the storing your values as a facts:
bind( Key, Value ).
Example of implementation (SWI Prolog)
Storing
recordz('var1', "String value1"),
recordz('var2', "String value2")
Querying value of var2
current_key(-Key),
Key = 'var2'
recorded(Key, Value)

Reference Variable as a value - VB6

Is it possible to use a variable value as a name for a reference variable? For example:
Dim PersonName As String
PersonName = recordset("PersonName")
Instead of the value of PersonName being a person name e.g. JoeBloggs; the reference variable itself would be JoeBloggs i.e. joebloggs = whatever.
I have looked around for the answer as I thought it would be a common question; but I was unable to find one.
#w0051977 dont worry, your need (if i understand it correctly) does make sense, ive wanted to do this once as well. If you understand it, you want to be able to define your variables name using a string? Like, if you have a "JohnDoe" in your database then you want to set the name of your variable as a string named JohnDoe, am i right? if that is right, you can't directly do this in VB6, however, in vb.net we have reflection so there is some way you can read the name of the variable and have it returned as a string (though i understand you want to do the opposite). So, best way to do this in vb6 is the following...
Dim c As Collection ' where c is our collection to make it short-hand/less typing.
Set c = New Collection ' you could have done As New Collection instead but this is better, trust me.
c.Add "MyValue1", "JohnDoe" ' sets a variable named JohnDoe with value "MyValue1"
c.Add "MyValue2", "JessKay" ' remember, these are stored as Variants, but can use as string.
Now to call it...
MsgBox c("JohnDoe") ' this simple.
so c("JohnDoe") will return whatever is in the value you've set for this variable name.
same story for the chick, say you wanna set another variable with the girls value in it...
Dim abc As String
abc = c("JessKay") ' thats all :) abc will equal "MyValue2"
Also, remember anything stored in a VB6 collection will always be stored as a Variant, so takes more memory than a String. However, you can still use it as a string or a number or anything else you want.
Cool?
Let me know if your needs were actually different and i've misunderstood your question. thanks.

FreeMarker interpolation results used inline with a second interpolation

Let me start with I'm not a programmer by trade, but I'm learning the best I can. I'm trying to build a template to take the result of one FreeMarker interpolation result and use that as a variable for another. I hope I'm using the terms correctly.
For example, I want the result of (entity.customer.organization.name) to be used in:
${blurb["organizationXXXAttire"]!}
Where XXX is the result of (entity.customer.organization.name)
If it was just a blurb with out a variable company name it would look like:
${blurb["organizationCompanyAttire"]!}
I thought the following would work but it did not:
<#assign organization = (entity.customer.organization.name)>
${blurb["organization<#organization?interpret>Attire"]!}
Thanks in advance for any suggestions.
It's simply ${blurb["organization${entity.customer.organization.name}Attire"]!}.
?interpret is only needed if you have a string that contains a piece of template. Besides you can't call directives (<#...>, <#...>) inside an expression.

VS2010 save array/collection data to a file while debugging

Is there some way to save array/list/collection data to a file while debugging in VS2010?
For example, in this code:
var addressGraphs = from a in context.Addresses
where a.CountryRegion == "Canada"
select new { a, a.Contact };
foreach(var ag in addressGraphs) {
Console.WriteLine("LastName: {0}, Addresses: {1}", ag.Contact.LastName.Trim(),
ag.Contact.Addresses.Count());
foreach(var Address in ag.Contact.Addresses) {
Console.WriteLine("...{0} {1}", Address.Street1, Address.City);
}
}
I'd like to set a breakpoint on the first 'foreach' line and then save the data in 'addressGraph' to a file.
where 'a' contains fields such as:
int addressID
string Street1
string City
<Ect.>
and 'Contact' contains fields such as:
string FirstName
string LastName
int contactID
<Ect.>
I'd like the file to contain the values of each of the fields for each item in the collection.
I don't see an obvious way to do this. Is it possible?
When your breakpoint is hit, open up the Immediate window and use Tools.LogCommandWindowOutput to dump the output to a file:
>Tools.LogCommandWindowOutput c:\temp\temp.log
?addressGraphs
>Tools.LogCommandWindowOutput /off
Note: You can use Log which is an alias for Tools.LogCommandWindowOutput
Update:
The > character is important. Also, the log alias is case sensitive.
See screenshot:
I also encoutered such a question, but in VS2013. I have to save a content of array while debugging.
For example, I need to save a content of double array named "trimmedInput". I do so:
Open QuickWatch Window from Debug menu (Ctrl+D, Q).
Put your variable in Expression and push Recalculate Button
You'll see all the values. Now you could select them all (Ctrl+A) and copy (Ctrl+C).
Paste (Ctrl+V) them in your favorite editor. Notepad, for example. And use them.
That's the simples way that I know. Without additional efforts. Hope that my description helps you!
P.S. Sorry for non English interface on screenshots. All necessary information are written in the text.
Something similar is possible with this method:
I built an extension method that I use in all of my projects that is a general and more powerful ToString() method that shows the content of any object.
I included the source code in this link:
https://rapidshare.com/files/1791655092/FormatExtensions.cs
UPDATE:
You just have to put FormatExtensions.cs in your project and change the Namespace of FormatExtensions to coincide to the base Namespace of your project. So when you are in your breakpoint you can type in your watch window:
myCustomCollection.ToStringExtended()
And copy the output wherever you want
On Visual studio Gallery search for: Object Exporter Extension.
be aware: as far as I worked with, it has a bug that block you from exporting object once in a while.
You can also call methods in the Immediate Window, and so I think your best bet would be to use an ObjectDumper object, like the one in the LINQ samples or this one, and then write something like this in the Immediate Window:
File.WriteAllText("myFileName.txt", ObjectDumper.Dump(addressGraph));
Depending on which ObjectDumper you decide to use, you may be able to customize it to suit your needs, and to be able to tell it how many levels deep you want it to dig into your object when it's dumping it.
Here's a solution that takes care of collections. It's a VS visualizer that will display the collection values in a grid while debugging as well as save to the clipboard and csv, xml and text files. I'm using it in VS2010 Ultimate. While I haven't tested it extensively, I have tried it on List and Dictionary.
http://tinyurl.com/87sf6l7
It handles the following collections:
•System.Collections classes
◦System.Collections.ArrayList
◦System.Collections.BitArray
◦System.Collections.HashTable
◦System.Collections.Queue
◦System.Collections.SortedList
◦System.Collections.Stack
◦All classes derived from System.Collections.CollectionBase
•System.Collections.Specialized classes
◦System.Collections.Specialized.HybridDictionary
◦System.Collections.Specialized.ListDictionary
◦System.Collections.Specialized.NameValueCollection
◦System.Collections.Specialized.OrderedDictionary
◦System.Collections.Specialized.StringCollection
◦System.Collections.Specialized.StringDictionary
◦All classes derived from System.Collections.Specialized.NameObjectCollectionBase
•System.Collections.Generic classes
◦System.Collections.Generic.Dictionary
◦System.Collections.Generic.List
◦System.Collections.Generic.LinkedList
◦System.Collections.Generic.Queue
◦System.Collections.Generic.SortedDictionary
◦System.Collections.Generic.SortedList
◦System.Collections.Generic.Stack
•IIS classes, as used by
◦System.Web.HttpRequest.Cookies
◦System.Web.HttpRequest.Files
◦System.Web.HttpRequest.Form
◦System.Web.HttpRequest.Headers
◦System.Web.HttpRequest.Params
◦System.Web.HttpRequest.QueryString
◦System.Web.HttpRequest.ServerVariables
◦System.Web.HttpResponse.Cookies
As well as a couple of VB6-compatible collections
In "Immediate Window" print following to get the binary dump:
byte[] myArray = { 02,01,81,00,05,F6,05,02,01,01,00,BA };
myArray
.Select(b => string.Format("{0:X2}", b))
.Aggregate((s1, s2) => s1 + s2)
This will print something like:
0201810005F60502010100BA
Change the '.Aggregate(...)' call to add blanks between bytes, or what ever you like.

change subvariable in FreeMarker

Is there a way to change a subvariable within a hash or a container in a FreeMarker template? For example, suppose I had:
{"name":"Bob", "city":"Detroit", "state":"OH"}
and I want to change the state to "MI". How would I go about doing that? I know about the assign tag, but the documentation says "Note that only top-level variables can be created/replaced". I am unsure as to whether this means subvariables can't be replaced with the assign tag, or subvariables can't be replaced by any means.
I figured out a simple way to do it:
<#assign hash = hash + {"state":"MI"}>

Resources