Rectangle 27 8

There is one major benefit to curly braces - many editors have a MUCH easier time of matching them, making certain types of debugging much easier. Meanwhile, the keyword "do...end" is quite a bit harder to match, especially since "end"s also match "if"s.

do ... end

While I do prefer braces, I see no reason that an editor would have trouble finding a 2/3 character string versus a single character. Though there is the argument that most editors already match braces, whereas do ... end is a special case which requires language specific logic.

do..end vs curly braces for blocks in Ruby - Stack Overflow

ruby-on-rails ruby ruby-on-rails-3 coding-style
Rectangle 27 8

I think it depends on what OS you are using, Vista is much harder to attach to Services, because of the separation between sessions.

The two options I've used in the past are:

  • Use GFlags (in the Debugging Tools for Windows) to setup a permanent debugger for a process. This exists in the "Image File Execution Options" registry key and is incredibly useful. I think you'll need to tweak the Service settings to enable "Interact with Desktop". I use this for all types of debugging, not just services.
  • The other option, is to separate the code a bit, so that the service part is interchangable with a normal app startup. That way, you can use a simple command line flag, and launch as a process (rather than a Service), which makes it much easier to debug.

+1 for GFlags. This is especially useful if you cannot modify the source code (or if you don't have it).

c# - Easier way to debug a Windows service - Stack Overflow

c# debugging windows-services
Rectangle 27 8

I think it depends on what OS you are using, Vista is much harder to attach to Services, because of the separation between sessions.

The two options I've used in the past are:

  • Use GFlags (in the Debugging Tools for Windows) to setup a permanent debugger for a process. This exists in the "Image File Execution Options" registry key and is incredibly useful. I think you'll need to tweak the Service settings to enable "Interact with Desktop". I use this for all types of debugging, not just services.
  • The other option, is to separate the code a bit, so that the service part is interchangable with a normal app startup. That way, you can use a simple command line flag, and launch as a process (rather than a Service), which makes it much easier to debug.

+1 for GFlags. This is especially useful if you cannot modify the source code (or if you don't have it).

c# - Easier way to debug a Windows service - Stack Overflow

c# debugging windows-services
Rectangle 27 4

I had the same problem, even my debugging options are the same as @John Koerner. I found that not all exception types are enabled to break the solution by default. You can choose which are enabled from the Exception Setting window.

I enabled the whole CLR Exceptions set.

c# - debugger does not stop on error - Stack Overflow

c# asp.net asp.net-mvc debugging
Rectangle 27 1

Not sure if this would fix your issue or not, but if you click on the WCF project in solution explorer, see if it has a "Always Start When Debugging" property. If it does, set it to false. That property only shows up for some project types though, so it depends on exactly what type of project template you used.

.net - How to prevent Visual Studio from launching WcfSvcHost.exe whil...

.net wcf visual-studio visual-studio-debugging
Rectangle 27 28

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript. You can use BeanShell interactively for Java experimentation and debugging as well as to extend your applications in new ways. Scripting Java lends itself to a wide variety of applications including rapid prototyping, user scripting extension, rules engines, configuration, testing, dynamic deployment, embedded systems, and even Java education.

There are also Jython and JRuby interactive shells for less verbose syntaxes.

BeanShell is actively maintained as beanshell 2 - code.google.com/p/beanshell2

A simple example of running beanshell from the command line can be found here

@hshib: It's now at Github and the last commit is from 2013. That's not "actively maintained".

read eval print loop - Is there something like python's interactive RE...

java read-eval-print-loop
Rectangle 27 27

First of all, stop using alert to do your debugging! Grab a copy of Firebug and FireQuery and use those with console.log() instead. Even if you're working with alert(), you really should be using $("input[type='date']").length to find the if the selector returned anything - object [object] isn't telling you anything useful here.

A far superior method for detecting supported input types is to simply create an input element and loop through all of the different input types available and check if the type change sticks:

var supported = {date: false, number: false, time: false, month: false, week: false},
    tester = document.createElement('input');

for(var i in supported){
    tester.type = i;
    if(tester.type === i){
        supported[i] = true;
    }
}

This actually makes use of the fact that browsers which do not support that particular input type will fall back to using text, thereby allowing you to test if they're supported or not.

You can then use supported['week'], for instance, to check for the availability of the week input type, and do your fallbacks through this. See a simple demo of this here: http://www.jsfiddle.net/yijiang/r5Wsa/2/. You might also consider using Modernizr for more robust HTML5 feature detection.

And finally, a better way to get outerHTML is to, believe it or not, use outerHTML. Instead of

var inputAttr = $('<div>').append($(this).clone()).remove().html().toLowerCase();

Why not just use:

var inputAttr = this.outerHTML || new XMLSerializer().serializeToString(this);

(Yes, as you can see, there is a caveat - outerHTML isn't supported by Firefox, so we're going to need a simple workaround, from this Stack Overflow question).

Edit: Found a method to do testing for native form UI support, from this page: http://miketaylr.com/code/html5-forms-ui-support.html. Browsers that support the UI for these types in some way should also prevent invalid values from been entered into these fields, so the logical extension to the test we're doing above would be this:

var supported = {date: false, number: false, time: false, month: false, week: false},
    tester = document.createElement('input');

for(var i in supported){
    tester.type = i;
    tester.value = ':(';

    if(tester.type === i && tester.value === ''){
        supported[i] = true;
    }
}

Again, not 100% reliable - this is only good for types that have certain restrictions on their values, and definitely not very good, but it's a step in the right direction, and certainly would solve your problem now.

Thanks for your detailed reply! It has provided very useful information to help me make the script more efficient by using more JS in place of jQuery. Exactly the type of info I was looking for. Could you provide me with some clarifications on a couple items? How does your input type detection code sample allow legacy browsers to unsupported HTML5 type attribute values? That is my goal. efficient detection of unsupported values.... not just detect support (like Modernizr does). Perhaps I am misinterpreting that samples purpose. Thanks Again!

@Joel It doesn't try to emulate the behavior for older browser, because you've got that part done correctly. It's the feature detection part which I think is problematic - I know you're trying to use the attribute selector for this, but in reality generally speaking there's a better identifier for these form elements - for instance, id which is required for label s to work. Parsing the HTML of the input element is a very dirty workaround here.

javascript - HTML5 Type Detection and Plugin Initialization - Stack Ov...

javascript jquery html5 fallback
Rectangle 27 2

Redis stores keys pointing to values. Keys can be any binary value up to a reasonable size (using short ASCII strings is recommended for readability and debugging purposes). Values are one of five native Redis data types.

1.strings a sequence of binary safe bytes up to 512 MB

2.hashes a collection of key value pairs

3.lists an in-insertion-order collection of strings

4.sets a collection of unique strings with no ordering

5.sorted sets a collection of unique strings ordered by user defined scoring

A Redis string is a sequence of bytes.

Strings in Redis are binary safe (meaning they have a known length not determined by any special terminating characters), so you can store anything up to 512 megabytes in one string.

Strings are the cannonical "key value store" concept. You have a key pointing to a value, where both key and value are text or binary strings.

A Redis hash is a collection of key value pairs.

A Redis hash holds many key value pairs, where each key and value is a string. Redis hashes do not support complex values directly (meaning, you can't have a hash field have a value of a list or set or another hash), but you can use hash fields to point to other top level complex values. The only special operation you can perform on hash field values is atomic increment/decrement of numeric contents.

You can think of a Redis hashes in two ways: as a direct object representation and as a way to store many small values compactly.

Direct object representations are simple to understand. Objects have a name (the key of the hash) and a collection of internal keys with values. See the example below for, well, an example.

Storing many small values using a hash is a clever Redis massive data storage technique. When a hash has a small number of fields (~100), Redis optimizes the storage and access efficency of the entire hash. Redis's small hash storage optimization raises an interesting behavior: it's more efficient to have 100 hashes each with 100 internal keys and values rather than having 10,000 top level keys pointing to string values. Using Redis hashes to optimize your data storage this way does require additional programming overhead for tracking where data ends up, but if your data storage is primarly string based, you can save a lot of memory overhead using this one weird trick.

You can insert to, delete from, and traverse lists from either the head or tail of a list.

Use lists when you need to maintain values in the order they were inserted. (Redis does give you the option to insert into any arbitrary list position if you need to, but your insertion performance will degrade if you insert far from your start position.)

Redis lists are often used as producer/consumer queues. Insert items into a list then pop items from the list. What happens if your consumers try to pop from a list with no elements? You can ask Redis to wait for an element to appear and return it to you immediately when it gets added. This turns Redis into a real time message queue/event/job/task/notification system.

You can atomically remove elements off either end of a list, enabling any list to be treated as a stack or a queue.

You can also maintain fixed-length lists (capped collections) by trimming your list to a specific size after every insertion.

A Redis set contains unique unordered Redis strings where each string only exists once per set. If you add the same element ten times to a set, it will only show up once. Sets are great for lazily ensuring something exists at least once without worrying about duplicate elements accumulating and wasting space. You can add the same string as many times as you like without needing to check if it already exists.

Sets are fast for membership checking, insertion, and deletion of members in the set.

Sets have efficient set operations, as you would expect. You can take the union, intersection, and difference of multiple sets at once. Results can either be returned to the caller or results can be stored in a new set for later usage.

Sets have constant time access for membership checks (unlike lists), and Redis even has convenient random member removal and returning ("pop a random element from the set") or random member returning without replacement ("give me 30 random-ish unique users") or with replacement ("give me 7 cards, but after each selection, put the card back so it can potentially be sampled again").

Redis sorted sets are sets with a user-defined ordering.

For simplicity, you can think of a sorted set as a binary tree with unique elements. (Redis sorted sets are actually skip lists.) The sort order of elements is defined by each element's score.

Sorted sets are still sets. Elements may only appear once in a set. An element, for uniqueness purposes, is defined by its string contents. Inserting element "apple" with sorting score 3, then inserting element "apple" with sorting score 500 results in one element "apple" with sorting score 500 in your sorted set. Sets are only unique based on Data, not based on (Score, Data) pairs.

Make sure your data model relies on the string contents and not the element's score for uniqueness. Scores are allowed to be repeated (or even zero), but, one last time, set elements can only exist once per sorted set. For example, if you try to store the history of every user login as a sorted set by making the score the epoch of the login and the value the user id, you will end up storing only the last login epoch for all your users. Your set would grow to size of your userbase and not your desired size of userbase * logins.

Elements are added to your set with scores. You can update the score of any element at any time, just add the element again with a new score. Scores are represented by floating point doubles, so you can specify granularity of high precision timestamps if needed. Multiple elements may have the same score.

You can retrieve elements in a few different ways. Since everything is sorted, you can ask for elements starting at the lowest scores. You can ask for elements starting at the highest scores ("in reverse"). You can ask for elements by their sort score either in natural or reverse order.

For all possible operations on sorted sets, see the sorted sets docs.

algorithm - What are the underlying data structures used for Redis? - ...

algorithm data-structures redis
Rectangle 27 1

Let me comment on your code though. My personal opinion, but I think that - API-wise - it would be far better to return an HTTP code (like Reponse.Status.CREATED) rather than some incorrect xml ("success" is not a well-formed xml) sent as application/xml.

that was a prototype and while the input consumes xml, I am not sure the output was consumed at all...I think 200ok was enough and I just never removed that code.

jax rs - JAXRS / CXF why is this simple post example not working - Sta...

cxf jax-rs
Rectangle 27 1

I had the same issue, and the above answer helped for debugging my soltution - in that it identified it was a config issue, however using angular2@2.1.0 i had to update {root}/e2e/tscconfig.json (by adding:

"types": [
       "d3"
     ]

as follows:

{
    "compileOnSave": false,
    "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc-e2e",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ],
    "types": [
      "d3"
     ]
   }
}

Keep in mind that there is a tscconfig.json in {root}/src/ as well. I updated in this and I still had a dependency issue with:

import * as D3 from 'd3';

Thank you for the up-vote. I opened a RFC for the typings to update their typings for d3, I got a response and submitted my changes, which they accepted - but I never built the test file they required.... so Im not sure if it is updated.

d3.js - Angular2-Seed + Typings + D3: Import error, 'Cannot find modul...

d3.js typescript angular typescript-typings
Rectangle 27 1

I'm not really familiar with the PE format that Windows uses, but I'm pretty sure there is no real easy way to do this. If the symbol table has not been stripped you may be able to find some information (not sure how Windows stores debugging information in PE) but it almost certainly wouldn't help you with parameter types. The best thing to do is load the DLL into a debugger and experiment with it... monitor the raw memory on the stack frames, send various variable types, etc.

Even if you find a good resource on the debugging information in a PE file, there almost certainly won't be any information for a private function.

Finding Dll Function Parameters - Stack Overflow

function dll parameters name-decoration
Rectangle 27 1

I'm not really familiar with the PE format that Windows uses, but I'm pretty sure there is no real easy way to do this. If the symbol table has not been stripped you may be able to find some information (not sure how Windows stores debugging information in PE) but it almost certainly wouldn't help you with parameter types. The best thing to do is load the DLL into a debugger and experiment with it... monitor the raw memory on the stack frames, send various variable types, etc.

Even if you find a good resource on the debugging information in a PE file, there almost certainly won't be any information for a private function.

Finding Dll Function Parameters - Stack Overflow

function dll parameters name-decoration
Rectangle 27 79

DWARF4 is now the default when generating DWARF debug information. When -g is used on a platform that uses DWARF debugging information, GCC will now default to -gdwarf-4 -fno-debug-types-section. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 debug information consumers support DWARF4 by default. Before GCC 4.8 the default version used was DWARF2. To make GCC 4.8 generate an older DWARF version use -g together with -gdwarf-2 or -gdwarf-3. The default for Darwin and VxWorks is still -gdwarf-2 -gstrict-dwarf.

So you need to use GDB 7.5 or compile with -g -gdwarf-2

Solved my woes with GCC 4.9.2 (built from source) and GDB 7.2-83.el6 (from CentOS 6.7).

still did not fix it for me. I suppose the answer might be out of date? Is there a similar solution for today?

@lotolmencre, the answer is not out of date

c++ - Debugging with gdb on a program with no optimization but still t...

c++ debugging gcc gdb
Rectangle 27 15

One thing to note is that the Swift type inference engine can be very slow with nested types. You can get a general idea about what is causing the slowness by watching the build log for individual compilation units that are taking a long time and then copying & pasting the full Xcode-spawned command into a Terminal window and then hitting CTRL-\ to get some diagnostics. Take a look at http://blog.impathic.com/post/99647568844/debugging-slow-swift-compile-times for a full example.

That's for me the best answer (see the link). I could EASILY find the two different lines that were a problem and solved it by decomposing my lines into smaller lines.

That is a very useful answer because it shows how to find where compiler went crazy. In my case it was the following: 'curScore[curPlayer%2]+curScore[2+curPlayer%2]==3 && maker%2==curPlayer%2' As soon as I moved it from 'if' to 'let', it resulted in "expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions"

compilation - Why is Swift compile time so slow? - Stack Overflow

compilation swift
Rectangle 27 15

One thing to note is that the Swift type inference engine can be very slow with nested types. You can get a general idea about what is causing the slowness by watching the build log for individual compilation units that are taking a long time and then copying & pasting the full Xcode-spawned command into a Terminal window and then hitting CTRL-\ to get some diagnostics. Take a look at http://blog.impathic.com/post/99647568844/debugging-slow-swift-compile-times for a full example.

That's for me the best answer (see the link). I could EASILY find the two different lines that were a problem and solved it by decomposing my lines into smaller lines.

That is a very useful answer because it shows how to find where compiler went crazy. In my case it was the following: 'curScore[curPlayer%2]+curScore[2+curPlayer%2]==3 && maker%2==curPlayer%2' As soon as I moved it from 'if' to 'let', it resulted in "expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions"

compilation - Why is Swift compile time so slow? - Stack Overflow

compilation swift
Rectangle 27 15

One thing to note is that the Swift type inference engine can be very slow with nested types. You can get a general idea about what is causing the slowness by watching the build log for individual compilation units that are taking a long time and then copying & pasting the full Xcode-spawned command into a Terminal window and then hitting CTRL-\ to get some diagnostics. Take a look at http://blog.impathic.com/post/99647568844/debugging-slow-swift-compile-times for a full example.

That's for me the best answer (see the link). I could EASILY find the two different lines that were a problem and solved it by decomposing my lines into smaller lines.

That is a very useful answer because it shows how to find where compiler went crazy. In my case it was the following: 'curScore[curPlayer%2]+curScore[2+curPlayer%2]==3 && maker%2==curPlayer%2' As soon as I moved it from 'if' to 'let', it resulted in "expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions"

compilation - Why is Swift compile time so slow? - Stack Overflow

compilation swift
Rectangle 27 0

I have an iOS 8.4 enterprise signed app that would only work on certain device types when I tried to install it from our internal app store, and it was inconsistent. I wasn't getting any helpful error messages, even from the device console, until I tried to deploy it using the XCode Devices to a 5th gen iPod. It said "This application does not support this device type" which led me to here. I was debugging on a 6th gen iPod/iPhone 6.

I was archiving from a different scheme than I usually release from and I was only building the current architecture which meant that it would only work on a certain type of device depending on what was plugged in when I archived.

So make sure that "build active architecture only" is NO when you are archiving an app to sign as an Enterprise app.

iphone - Why am I seeing "This application does not support this devic...

iphone ios
Rectangle 27 0

These two types of outputs has different purposes. Console Output is intended for the application itself (customer) and one Output Window is intended for debugging purposes. You don't want to release debug messages to customer. Right? But you don't want to delete or comment out debug messages every time you release the software.

c++ - Redirect command prompt output to output window in Visual studio...

c++ visual-c++ visual-studio-2012
Rectangle 27 0

I got a solution from this discussion and now I am able to post the Json data using angular2 Http request method instead of post.The controller action shows the object values while debugging. I have tested with the different types of objects and list of objects and everything is working fine.

protected ExecutePost(action: string, data: any) {
        let _body = JSON.stringify(data);
        let headers = new Headers({ 'Content-Type': 'application/json;charset=utf-8' });

        let requestoptions: RequestOptions = new RequestOptions({
            method: RequestMethod.Post,
            url: this._baseUrl + action,
            headers: headers,
            body: _body
        })

        return this.http.request(new Request(requestoptions))
            .map((res: Response) => { return res.json(); });
    }

You forgot a semicolon, lol

angular - Angular2 http post not passing the json object to MVC 6 cont...

http-post angular asp.net-core-mvc
Rectangle 27 0

This is the failing code which fails in View::preRenderViewElement (View.php file):

/**
   * View element pre render callback.
   */
  public static function preRenderViewElement($element) {
    // Allow specific Views displays to explicitly perform pre-rendering, for
    // those displays that need to be able to know the fully built render array.
    if (!empty($element['#pre_rendered'])) {
      return $element;
    }

    if (!isset($element['#view'])) {
      $view = Views::getView($element['#name']);
    }
    else {
      $view = $element['#view'];
    }

    $element += $view->element; // PHP Fatal error: Unsupported operand types.
    $view->element = &$element;

The above shows that the problem is related to pre rendering your view element which failed to load the view from your element (either from $element['#name'] or $element['#view']). This may suggest that one of your views could be broken.

First of all, try clearing your Drupal caches and memory caches (Memcached/Redis).

  • try re-saving the failing element (node or view),
  • your PHP matches the environment where it works,
/update.php
drush updb

If above won't help, ideally you should reproduce the same problem on your local (pulling the code and db, making sure the PHP is the same). Then you can install PHP XDebug extension, configure and enable it temporary, then you can generate the trace for specific page, or use xdebug_start_trace() and xdebug_stop_trace() functions to debug specific parts of your code. Or use a standard var_dump(debug_backtrace()); exit; code (on $view->element being empty) before the failing line in preRenderViewElement(), to track down which element or view it relates to and start from there.

8 migration debugging settings.php