How do I (recursively) search ALL file contents in Windows 7?

“user3245549” is right: All of the above answers with “for loops” and nested bat files are mumbo jumbo. All you need is to just use “findstr” – example: C:\temp> findstr /S /C:”/work” * | more <– this will find the string “/work” in any file or C:\temp> findstr /S /C:”/work” “*.*” | more or C:\temp> … Read more

How to prevent user to enter text in textarea after reaching max character limit

The keyup event fires after the default behaviour (populating text area) has occurred. It’s better to use the keypress event, and filter non-printable characters. Demo: http://jsfiddle.net/3uhNP/1/ (with max length 4) jQuery(document).ready(function($) { var max = 400; $(‘textarea.max’).keypress(function(e) { if (e.which < 0x20) { // e.which < 0x20, then it’s not a printable character // e.which … Read more

Sorting a double value of an object within an arrayList

To use a Comparator: Collections.sort(myList, new Comparator<Chromosome>() { @Override public int compare(Chromosome c1, Chromosome c2) { return Double.compare(c1.getScore(), c2.getScore()); } }); If you plan on sorting numerous Lists in this way I would suggest having Chromosome implement the Comparable interface (in which case you could simply call Collections.sort(myList), without the need of specifying an explicit … Read more

How to get my machine’s IP address from Ruby without leveraging from other IP address?

Isn’t the solution you are looking for just: require ‘socket’ addr_infos = Socket.ip_address_list Since a machine can have multiple interfaces and multiple IP Addresses, this method returns an array of Addrinfo. You can fetch the exact IP addresses like this: addr_infos.each do |addr_info| puts addr_info.ip_address end You can further filter the list by rejecting loopback … Read more

CSS selector for element within element with inline style?

A bit late to the tea party but thought I would share the solution I found & use. @simone’s answer is perfect if you can match the style attribute exactly. However, if you need to target an inline style attribute that may have other inline styles associated with it you can use: p[style*=”text-align:center;”] “*=” means … Read more

Custom response header Jersey/Java

I think using javax.ws.rs.core.Response is more elegant and it is a part of Jersey. Just to extend previous answer, here is a simple example: @GET @Produces({ MediaType.APPLICATION_JSON }) @Path(“/values”) public Response getValues(String body) { //Prepare your entity Response response = Response.status(200). entity(yourEntity). header(“yourHeaderName”, “yourHeaderValue”).build(); return response; }

SharePoint 2013 get current user using JavaScript

Here is the code that worked for me: <script src=”https://stackoverflow.com/SiteAssets/jquery.SPServices-2013.02a.js” type=”text/javascript”></script> <script src=”/SiteAssets/jquery.js” type=”text/javascript”></script> <script type=”text/javascript”> var userid= _spPageContextInfo.userId; var requestUri = _spPageContextInfo.webAbsoluteUrl + “/_api/web/getuserbyid(” + userid + “)”; var requestHeaders = { “accept” : “application/json;odata=verbose” }; $.ajax({ url : requestUri, contentType : “application/json;odata=verbose”, headers : requestHeaders, success : onSuccess, error : onError }); function … Read more