Jalopy to format return/throw statements - maven-2

I would like Jalopy to format my return and throw statements such that they look like a method call since they are:
return(true);
throw(new IllegalArgumentException("You can't do that, what we you thinking?"));
I have the rest of the code formatted exactly the way I want so this is the icing on the cake.
Also as an aside, I work on a project with a few team members and each have our own preference for looking at code, has anyone setup Jalopy in conjuction with a successful build as well as checkout?
So, when I checkout code, it gets formatted to my liking, and then each time I get a successful build, it gets formatted according to the Java/Sun Standard and then checked in?
Walter

I would like Jalopy to format my return and throw statements such that they look like a method call
I didn't find anything about this in Jalopy's Manual and think this would require extending Jalopy.
(...) when I checkout code, it gets formatted to my liking, and then each time I get a successful build, it gets formatted according to the Java/Sun Standard and then checked in?
If you are using subversion, maybe you could use a client-side hook on checkout and a pre-commit hook on commit.

The commercial Jalopy supports this.
Here are the links for the corresponding user's guide sections:
Insert throws parentheses

Related

Automatically hide LinqPad query

I wrote a simple tool to decode JWT tokens and I'd like to use it in a similar way as the Interactive Regex Evaluator.
Is there a way to either automatically hide a query (e.g., via the Util class) or to even register it to something like Ctrl+Shift+F2?
Unfortunately that functionality doesn't exist.
You'll notice when using the Interactive Regex Evaluator it's opening the sample of the same name but doing extra work to hide the query panel. Looking at LinqPads code using it's own ILSpy, there's a method called LINQPad.UI.MainForm.miRegex_Click and it's calling the method LINQPad.UI.QueryControl.ToggleFullPaneResults which does that functionality but unfortunately the method is internal.
If you'd like to suggest the feature head over to the LinqPad forums over at http://forum.linqpad.net/ and make the suggestion. Joseph is good at getting back to people.

Is there a libfaketime alternative for Golang?

I want to automate some tests where I have to manipulate the system time to check for authentication behaviours of a program that is written in golang. According to this post, libfaketime does not work with golang. Is there another way that I can achieve what I want to do with libfaketime?
Here's a description of what libfaketime does from github.
libfaketime intercepts various system calls that programs use to retrieve the
current date and time. It then reports modified (faked) dates and times (as
specified by you, the user) to these programs. This means you can modify the
system time a program sees without having to change the time system-wide.
No, there is none.
You need to use something like clockwork (see this for more) and explicitly pass "time" implementation around your code.
Update from 2021-03-01 with a more up-to-date list of options:
https://github.com/LopatkinEvgeniy/clock
https://github.com/jonboulle/clockwork
https://github.com/benbjohnson/clock
https://github.com/facebookgo/clock
https://github.com/tkuchiki/faketime
https://github.com/rzajac/clock
There is this repository (tkuchiki/faketime) which claims to be able to fake the time.Now()-function. I don't know how extensively this works and haven't tested it. But it sounds like it might be a solution to your problem.

How does one list the changes via the API from a TeamCity build?

I'm trying to find a way to get all the comments from a particular build in TeamCity via the Rest API. How can one do that?
http://teamcity:port/httpAuth/app/rest/changes?locator=build:(id:77651)&fields=count,change:(version,username,date,href,comment,files)
Via this URL, one can list out in custom fashion exactly the fields they wish to return. I don't think this is documented, i got this from their support folks. Enjoy!
PS - There are other examples out there which iterate over each change, this lists out all the changes for a particular build id in one place, for parsing.

If url ends with ' then show post

I have a website, let's say that my site is example.com.
I would like to show a post if anyone tries to sql injection it. For example if the link is example.com/?portofolio=1 and they type example.com/?portofolio=1' then I would like to show a post/page (refer them to another post) instead of database information (if they get any). Everytime they type ' at the end of every url.
If you are asking how to show that page - that depends on the language and/or framework you are using. This can usually be done with a redirect, though some frameworks allow rendering a different page for the same URL.
If you are asking how to detect SQL injections - that depends on how your code works. Different codes will have different ways to inject SQL. If you are going to go through the trouble of figuring out all the SQL vulnerabilities in your code, and code some rules to try and catch them - wouldn't it be better to remove those vulnerabilities? It'll be easier too - usually the answer is to use SQL parameters instead of concatenating strings.

How to create shopify ScriptTag that would be used without asyncLoad wrapper?

Shopify does wrap all scripts added through ScriptTag API into special asyncLoad function. While it makes sense in many circumstances there still situations when you need script tag inserted directly into the header.
For example Optimizely wouldn't work that smooth if there wasn't other way to insert script tag, i.e. somehow theirs script appears in the store front independently, i.e. without asyncLoad function.
How would I do the same?
One option is to parse and then send back current theme, but it looks weird and not quite reliable, and according my research Optimizely does know another approach.
I was able to get in touch with Optimizely, here is their's response:
We actually partnered with Shopify to get our snippet added to the page in this way by default. I don’t think there is a simple way to work around the async limitation otherwise.
and here is Shopify's response:
Unfortunately this was a one-off hack-y fix, and not something that we're open to doing again at this time.
So, for now the only reliable way to work around the async limitation is to instruct users to place the script into current theme as others applications does.