text:
Q: Rails & Heroku: We're sorry, but something went wrong I am getting the infamous "We're sorry, but something went wrong." error. Googling it it points to Omniauth problem - but I havent changed much (if any) of the omniauth stuff, and had it working last time I deployed it to heroku.
I have it deployed on a cedar stack btw.
Any ideas what the problem could be?
Heroku logs:
2012-04-28T18:26:06+00:00 heroku[router]: GET myapp.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=13ms status=500 bytes=643
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal.rb:203:in `dispatch'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:67:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:30:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.3/lib/journey/router.rb:68:in `block in call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.3/lib/journey/router.rb:56:in `each'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.3/lib/journey/router.rb:56:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/omniauth-1.0.3/lib/omniauth/strategy.rb:168:in `call!'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:594:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/omniauth-1.0.3/lib/omniauth/strategy.rb:148:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:35:in `block in call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:34:in `catch'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:34:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/head.rb:14:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/flash.rb:242:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/cookies.rb:338:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/query_cache.rb:64:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `_run__2587592208680042819__call__3254396045512618553__callbacks'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/rack/logger.rb:26:in `call_app'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/rack/logger.rb:16:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_dispatch/middleware/static.rb:61:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/engine.rb:479:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/application.rb:220:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/rack/log_tailer.rb:14:in `call'
2012-04-28T18:26:06+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-04-28T18:26:06+00:00 app[web.1]:
2012-04-28T18:26:06+00:00 app[web.1]:
2012-04-28T18:26:06+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
2012-04-28T18:26:06+00:00 app[web.1]: cache: [GET /] miss

I also noticed the following:
2012-04-28T18:26:06+00:00 app[web.1]:   * "/app/app/views"
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_view/renderer/renderer.rb:36:in `render_template'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_view/renderer/template_renderer.rb:10:in `render'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_view/renderer/template_renderer.rb:29:in `determine_template'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/abstract_controller/rendering.rb:109:in `_render_template'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_view/renderer/renderer.rb:17:in `render'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/streaming.rb:225:in `_render_template'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/abstract_controller/rendering.rb:103:in `render_to_body'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/rendering.rb:16:in `render'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/abstract_controller/rendering.rb:88:in `render'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
2012-04-28T18:26:06+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/core_ext/benchmark.rb:5:in `ms'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/instrumentation.rb:39:in `render'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/abstract_controller/base.rb:167:in `process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/rendering.rb:10:in `process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:414:in `_run__3927484994384413162__process_action__1065190525946390676__callbacks'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/abstract_controller/callbacks.rb:17:in `process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/rescue.rb:29:in `process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/notifications.rb:123:in `block in instrument'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/notifications.rb:123:in `instrument'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/abstract_controller/rendering.rb:45:in `process'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/abstract_controller/base.rb:121:in `process'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
2012-04-28T18:26:06+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/action_controller/metal.rb:246:in `block in action'

A: This seems really out of the blue, but what fixed my problem was having the haml gem within the assets group. I took it out from that particular group, and it fixed my problem. Not sure why.


text:
Q: Unarchiving data with new NSKeyedUnarchiver APIs while failed to satisfied unarchivedObjectOfClass it required Firstly, I wanted to thank every of you have read the message and giving me feedback in any form.
Here it's what I'm trying to do. To replace deprecated API [NSKeyedUnarchiver unarchiveObjectWithData:myProfileData]; in objective-c to iOS 12 new API unarchivedObject<DecodedObjectType>(ofClass: DecodedObjectType.Type, from: Data) -> DecodedObjectType?
I unarchived data with old NSKeyedUnarchived APIs, printed it out and here is what I get:
assets =     {
        "albums" =         {
            "more_Album" = 0;
            photos =             (
            );
        };
    "shared_connections" = "<null>";
}

My first attempt was the blow, because I knew I archived data as dictionary, so I must unarchive it with the same class type:
NSError *error = nil;
NSDictionary *dictionary = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSDictionary class] fromData:myData error:&error];

However the error message showed:
Error Domain=NSCocoaErrorDomain Code=4864 "value for key 'NS.objects' was of unexpected class 'NSNull (0x11c39fe80).
Allowed classes are '{(
    "NSDictionary (0x11c39fa48)
)}

I thought maybe it's because I didn't include [NSNull class] in unarchivedObjectOfClass which caused the failure. I continued to make a set of unarchivedObject of classes in order to satisfy the complain:
NSError *error = nil;
NSSet *classSet = [NSSet setWithObjects:[NSDictionary class], [NSNull class], nil];
NSDictionary *dictionary = [NSKeyedUnarchiver unarchivedObjectOfClasses:classSet fromData:myData error:&error];

Unfortunately, it failed again.
Error Domain=NSCocoaErrorDomain Code=4864 "value for key 'NS.objects' was of unexpected class 'NSArray (0x11e79f778)

 Allowed classes are '{(
    "NSDictionary (0x11e79fa48) ,
    "NSNull (0x11e79fe80) )}'

I am not sure what is the right way to handle those Null value in dictionary while using new NSKeyedUnarchiver APIs.

A: I got this all wrong and I realized I didn't include NSArray class in the NSSet and this is where complain came from.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Angularjs deferred log-running timer task(s) Building an Ionic app and have suddenly come across an issue that I am finding really difficult to debug where the browser is 'deferring' long running timer tasks causing my views to execute the code in their controllers only once (even when the controller is explicitly reloaded).
Warning is:

Deferred long-running timer task(s) to improve scrolling smoothness. See crbug.com/574343.

What I'm after:

*

*An understanding of the warning and why it occurs

*Any guidance as to how to go about debugging such a warning.

Thanks in advance.
Update
I felt it was important to note that while never receiving errors and only warnings as the cause for my problems, I have since rolled back to a working version.
This working version still has warnings appearing but does not affect the running of my application.

A: well in case when you are doing tasks using $timeout , you have got to stop and destroy them else they would create the error you stated
for eg:
var timer = $timeout(
                        function() {
                            console.log( "Timeout executed", Date.now() );
                        },
                        2000
                    );

if you start a timeout as above then you got to destroy the timer as follows :
                    // When the DOM element is removed from the page,
                    // AngularJS will trigger the $destroy event on
                    // the scope. This gives us a chance to cancel any
                    // pending timer that we may have.
$scope.$on(
                        "$destroy",
                        function( event ) {
                            $timeout.cancel( timer );
                        }
                    );

A: I faced this issue when function was called only first time the view was loaded. Noticed this warning in the console but not sure if this is related to function getting called only once.
In the controller, I moved my function call inside "$ionicView.enter" and it gets called every time view is loaded.
$scope.$on('$ionicView.enter', function () {
            callMyFunction();
        });

Hope this helps.

A: Sounds like you may have max number of connections in your browser. You may want to decrease your http requests to a single request that contains something which would be 10 requests vs 10 separate http requests.
The answer in regards to your question is something along the lines of maximum http request per browser.

"Max Number of default simultaneous persistent connections per
  server/proxy:"

Also answered here if I am correctly assuming - Max parallel http connections in a browser?


text:
Q: Regex Operator in Validating HTML Tags I am following Regular Expression.info and see on their samples page an expression to match agains HTML tags, as follows:
([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>

What is the semantic effect of the part \b[^]?  I get its a word boundary but given what follows it what is the purpose?

A: It matches anything extra (if it exists) up until the next occurrence of a ">" (closing HTML tag). This would capture stuff like class="classname" id="idname". However, it would also capture any character you could think of, such as •·°ÁÓ, which may or may not be what you want. As always, a proper HTML parser is the way to go for parsing HTML.


text:
Q: As a PS+ subscriber, I have already purchased many games using the PSN for my PS3, why can I not find the games listed on my PS4? I am a PlayStation Plus subscriber and have made many game purchases when using my PS3. Why can I not find any of my already purchased games on my PS4?
I have tried searching the PSN for my list of purchases but I am unable to find any transaction history, nor can I find my games downloaded list! I would like to know why? As I'm not prepared to purchase games I already own.
If this is the case, then why do I need to subscribe to the PlayStation Plus because I was under the impression that in doing so, all of my transaction history and game data would be saved for my individual account regardless of console? I have an example: Assassins Creed Black Flag, a game I'd pre-ordered, and bought the season pass, which totaled over £80 pounds. May not seem that much to some people, but if I'm expected to do it all over again and every time a new console becomes available, then they are going to lose my custom.

A: First to check to see if you're actually using the same account on both consoles. The fact that you can't see your transaction history makes me suspect that you might have created a new account for your PlayStation 4 instead of reusing you existing account.
Otherwise in order for a game that you bought from the PlayStation Store for the PlayStation 3 to be playable on your PlayStation 4 two things need to be true. The first that there must be a PS4 version of the game. The PS4 isn't backwards compatible with the the PS3, so any game would need ported to the PS4 for you to play it on you new console. The second thing is that the particular "product" you bought needs to include both the PS3 and PS4 versions of the game. Most games aren't sold with both versions bundled together like this, so you need to buy separate versions for each console. Most developers will want to be paid for the work they had to do to port the game to the PS4, so this shouldn't be too surprising.
For example, Assassin's Creed IV Black Flag is available on the PlayStation Store in both a PlayStation 3 version and a PlayStation 4 version. These are separate products you need to buy separately. An example of one of the few games that you can pay one price and get the PS3 and PS4 versions, along with the PS Vita version too, is OlliOlli.
If you look at where it says "Playable On:" on the store page you can see the difference between the games:

There also the PlayStation Now service you may have heard of. This service lets you play games on your PS4 (and other Sony devices) by streaming them to you console. This works by running the games on Sony's servers (modified PS3s) and streaming the video output to your console. Unfortunately your purchase of games on the PlayStation Store doesn't entitle you to play these games on PlayStation Now. You have to pay a rental fee if you want to play them using this service on your PS4 or other device.

A: A more specific answer to your question is that PS3 games are are not shown on the PS4 because the PS4 storefront only shows PS4 and PS Now games available to play. The PS4 is NOT backwards compatible.
On games or DLC that you might have purchased on the PS3 that provided you cross-play availability (note some games have gained this after the fact), these do not show up automatically in your Library. You must go to the store to License them where they will normally be marked "FREE" or "Download" when you find them. They also do not come up in a list of "free" games as they are cross-play free if you already own the game on another platform (PS3/Vita/etc).
Personally I use the Sony PlayStation store website to do all of my game management, you can push downloads out to your PS4 from there as well.
You can also view all of your past transactions, search for cross-play games that may be free, etc...


text:
Q: Android sticky service is beeing killed loosing all information I have service which is basically timer. It receives object with location data, start time, user id etc, and every seconds it increments stop value. I'd like to have this service running non-stop until stopped in application. I've read that i need to start this service as sticky, so i did that. But I've noticed that after my main application is beeing killed by system or user, service restarts and lose all information (about current timers running etc - I have there array with list of objects).
Idea of  that service was that:
user clicks button in app -> service is starting and counting time changing information in notification bar and sending broadcast to main application -> I wish to continue updating notification bar even if app is killed by user or system.
My class below:
public class TimerService extends Service{
    private NotificationCompat.Builder builder;
    private static JsonHistoryList activities;
    private Intent intent;
    private Handler handler;

    private Runnable sendUpdateToUi = new Runnable() {
        @Override
        public void run() {
            sendBroadcast();
            handler.postDelayed(this, 1000);
        }
    };

    private NotificationManager mNotificationManager;

    private BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if(action.equals(ACTION_ADD)){
                JsonHistory item = (JsonHistory) intent.getSerializableExtra(HISTORY_ARG);
                new NetworkAsyncTask().execute(ACTION_ADD_ID, item);
            }else if(action.equals(ACTION_DELETE)){
                int id = intent.getIntExtra(CATEGORY_ID_ARG, -1);
                if(id > 0){
                    new NetworkAsyncTask().execute(ACTION_DELETE_ID, id);
                }
            }else if(action.equals(ACTION_CLEAR)){
                activities.clear();
            }
        }
    };

    public TimerService() {
        handler = new Handler();
    }

    private void sendBroadcast() {
        Long time = new Date().getTime();

        for(JsonHistory item: activities){
            ContentValues values = new ContentValues();
            values.put(History.C_STOP, time);
            String[] selectionArgs = {String.valueOf(item.id)};
            getContentResolver().update(History.URI, values, History.C_ID + "=?", selectionArgs);
            item.stop = time;
        }

        intent.putExtra(ACTIVITY_LIST_ARG, activities);

        Intent bIntent = new Intent(this, MainActivity.class);
        bIntent.putExtra(CATEGORY_ARG, activities);
        builder.setContentText(String.format(getString(R.string.notification_bar_message), activities.size()));
        Notification barNotif = builder.build();
        mNotificationManager.notify(SERVICE_ID, barNotif);

        sendBroadcast(intent);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        IntentFilter filter = new IntentFilter();
        filter.addAction(ACTION_ADD);
        filter.addAction(ACTION_DELETE);
        filter.addAction(ACTION_CLEAR);
        registerReceiver(receiver, filter);
        intent = new Intent(ACTION);
        handler.removeCallbacks(sendUpdateToUi);
        handler.postDelayed(sendUpdateToUi, 1000);
        activities = new JsonHistoryList();

    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        super.onStartCommand(intent, flags, startId);
        if(intent != null && intent.hasExtra(TimerService.ACTIVITY_LIST_ARG)){
            ArrayList<JsonHistory> temp = (ArrayList<JsonHistory>) intent.getSerializableExtra(TimerService.ACTIVITY_LIST_ARG);
            if(temp != nu;; && temp.size() > 0)activities.addAll(temp);
        }

        mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        Intent bIntent = new Intent(this, MainActivity.class);
        PendingIntent pbIntent = PendingIntent.getActivity(this, 0, bIntent, 0);
        builder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.notification_icon)
                        .setContentTitle(getString(R.string.app_name))
                        .setContentText(String.format(getString(R.string.notification_bar_message), activities.size()))
                        .setAutoCancel(true)
                        .setOngoing(true)
                        .setContentIntent(pbIntent);
        Notification barNotif = builder.build();
        this.startForeground(SERVICE_ID, barNotif);
        return START_STICKY;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unregisterReceiver(receiver);
        handler.removeCallbacks(sendUpdateToUi);
        stopForeground(true);
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    private class NetworkAsyncTask extends AsyncTask<Object, Void, String>{
        Gson gson;

        public NetworkAsyncTask() {
            super();
            gson = new Gson();
        }

        @Override
        protected String doInBackground(Object... params) {
            Integer actionId = (Integer) params[0];
            String result = null;
            switch (actionId){
                case ACTION_ADD_ID:
                    break;
                case  ACTION_DELETE_ID:
                    break;
                default:
                    result = null;
                    break;
            }
            return result;
        }
    }
}

Thanks for any replies

A: When you stop the service it is true it loses its information if the application is destroyed. That is because that instance of the service is tied to that particular instance of the application.
In my opinion, an easy fix would be to store the information you still need in some type of persistent storage (SQLite, Internal/External Memory, Shared Preferences)
Then, every time you start your service with a new application launch just be sure to reload the information you want from whichever persistent storage method you choose.
Also, assuming you don't want this service to continue if the application is killed by the user, be sure to send an intent to the service to stop it like this:
    intent = new Intent(this, BackgroundLocationService.class);
    stopService(intent);


text:
Q: Java Alpha-Beta Pruning in Tic Tac Toe I have a game of Tic Tac Toe that uses the Minimax Algorithm. I want to improve that by adding alpha-beta pruning. However the alpha-beta method does not seem to be able to calculate moves effectively. It just puts its piece in the next available space whether it is the optimal move or not. I do not have this issue with the minimax method. I sure it's something simple that I keep overlooking, so forgive me. I used this tutorial for minimax and this tutorial for alpha-beta pruning.
This is the Minimax class. It includes the alpha-beta method:
public class Minimax {

    private Token playerToken;
    private EndStates endStates;
    private Token opponentToken;

    public Minimax(Token playerToken, EndStates endStates) {
        this.playerToken = playerToken;
        this.endStates = endStates;
        opponentToken = makeOpponentToken();
    }

    public Token makeOpponentToken() {
        if (playerToken == Token.O) {
            return Token.X;
        }
        else {
            return Token.O;
        }
    }

    public Token getOpponentToken() {
        return opponentToken;
    }

    public int evaluate(Cell[] board) {
        //rows across
        if (endStates.checkWinByRow(board, playerToken) || endStates.checkWinByColumn(board, playerToken) || endStates.checkWinByDiagonal(board, playerToken)) {
            return 10;
        }
        else if (endStates.checkWinByRow(board, opponentToken) || endStates.checkWinByColumn(board, opponentToken) || endStates.checkWinByDiagonal(board, opponentToken)) {
            return -10;
        }

        return 0;
    }

    public boolean hasCellsLeft(Cell[] board) {
        for (int i=0; i<board.length; i++) {
            if (board[i].getToken() == Token.EMPTY) {
                return true;
            }
        }
        return false;
    }

    int MAX = 1000;
    int MIN = -1000;

    public int alphaBeta(Cell[] board, int depth, boolean isMax, int alpha, int beta) {
        int score = evaluate(board);
        if (score == 10) {
            return score;
        }

        if (score == -10) {
            return score;
        }
        if (hasCellsLeft(board) == false) {
            return 0;
        }
        if (isMax) {
            int best = MIN;
            for (int i=0; i<board.length; i++) {
                if (board[i].getToken() == Token.EMPTY) {
                    board[i].setToken(playerToken);
                    int val = alphaBeta(board,depth+1, !isMax, alpha, beta);
                    best = Math.max(best, val);
                    alpha = Math.max(alpha, best);
                    board[i].resetMarker();
                }
                 if (best <= alpha) {
                    break;
                }
            }
            return best;
        }
        else {
            int best = MAX;
            for (int i=0; i<board.length; i++) {
                if (board[i].getToken() == Token.EMPTY) {
                    board[i].setToken(playerToken);
                    int val = alphaBeta(board, depth+1, isMax, alpha, beta);
                    best = Math.min(best, val);
                    beta = Math.min(beta, best);
                    board[i].resetMarker();
                }
                if (beta <= alpha) {
                    break;
                }
            }
            return best;
        }
    }

    public int minimax(Cell[] board,  int depth, boolean isMax) {
        int score = evaluate(board);
        int best;

        if (score == 10) {
            return score;
        }

        if (score == -10) {
            return score;
        }
        if (hasCellsLeft(board) == false) {
            return 0;
        }
        if (isMax) {
            best = -1000;
            for (int i=0; i<board.length; i++) {
                if (board[i].getToken() == Token.EMPTY) {
                    board[i].setToken(playerToken);
                    best = Math.max(best, minimax(board, depth+1, !isMax));
                    board[i].resetMarker();
                }
            }
            return best;
        }
        else {
            best = 1000;
            for (int i=0; i<board.length; i++) {
                if (board[i].getToken() == Token.EMPTY) {
                    board[i].setToken(opponentToken);
                    best = Math.min(best, minimax(board, depth+1, !isMax));
                    board[i].resetMarker();
                }
            }
            return best;
        }
    }

    public int findBestMove(Cell[] board) {
        int bestValue = -1000;
        int bestMove = -1;
        for (int i=0; i<board.length; i++) {
            if (board[i].getToken() == Token.EMPTY) {
                board[i].setToken(playerToken);
                //int moveValue = minimax(board, 0, false);
                int moveValue = alphaBeta(board, 0, true, -1000, 1000);
                board[i].resetMarker();
                if (moveValue > bestValue) {
                    bestMove = i;
                    bestValue = moveValue;
                }
            }
        }
        return bestMove;
    }
}

The board is an array of 9 that contains an enum value of Token.Empty but can be replaced with Token.X or Token.O respectively.
This is the class that calls uses the algorithm:
public class ComputerPlayer(Token token, Algorithm minimax ) {
   private Token playerToken;
   private Algorithm minimax;

    public ComputerPlayer(Token playerToken, Algorithm minimax) {
        this.playerToken = playerToken;
        this.minimax = minimax;
    }

    public Token getPlayerToken() {
        return playerToken;
    }

   public void makeMove(Cell[] board) {
        int chosenCell;
        chosenCell = minimax.findBestMove(board);
        board[chosenCell].setToken(playerToken);
        System.out.println("Player " + playerToken + " has chosen cell " + (chosenCell+1));
    }
}

A: Alpha-Beta Pruning requires a good evaluation function for unfinished game states to be effective. It should be able to evaluate when one player is "more likely" to win accurately. It will use the evaluation to prune variations that do not look promising.
Right now your evaluation function only differentiates between game over and game in progress, so you will not be able to do better than min-max.
However, if you are doing worse than min-max, you must also have a bug somewhere else. I recommend stepping through the code and trying to see where it goes wrong.


text:
Q: bootstrapping code in R doesn't work? So I am ready to jump off a building because I cannot figure out this code for my LIFE. Everytime I run it, I get the standard error of 0 (bias=0 too) so obviously I'm doing something wrong because it's using the same sample when I want 1000 iterations.
I want the AIC of the model for all these samples. I've created a data frame and named it "d."
Here is my code:
bootaic<-function(d, idx){
d2<-d[idx,]
fit<-coxph(Surv(time,infection) ~ X48FL + X55FL, method="efron", data=d)
return(AIC(fit))
}

bootf<-boot(data=d,statistic=bootaic,R=1000)

WHAT IS WRONG. I appreciate any and all help, I am a novice to bootstrapping and I suck at coding.


text:
Q: I am receiving the downstream message which contains more than one processed data In event hub a receiving more than 1 processed message ,the message is not coming as individual events.the message contains more than 1 item.
if you see the message it has more than one item of device info,I should receive one item per event.
    //Processing the message
    With ProcessedPayload As
    (SELECT
    udf.Device(
    Event.meta.DeviceId,
    Event.meta,
    Event.Data_in,
    Event.channels,
    pcmsqlazure.ConfigIOPayload) As device

    FROM
        localINputsignal As Event
    join
        pcmsqlazure
    ON
     Event.meta.DeviceId=pcmsqlazure.SerialNumber)
//output data to event bus
    select device.deviceId,device.productFilter,device.data into Custom from ProcessedPayload

Edit:
The data coming like below as a single string
{"Ts":"2019-08-28T04:08:23.3884855Z","DeviceId":"DJT3COE4","count":1}
{"Ts":"2019-08-28T04:08:23.0584507Z","DeviceId":"DJT3COE4","count":1}
{"Ts":"2019-08-28T04:08:21.8236859Z","DeviceId":"DJT3COE4","count":1}
{"Ts":"2019-08-28T04:08:21.8236859Z","DeviceId":"DJT3COE4","count":1}

but for me the result should come as single event like below
{"Ts":"2019-08-28T04:08:21.8236859Z","DeviceId":"DJT3COE4","count":1}

Q: the processed downstream message which is the message pusblished to Eventhub,and this message should be received one by one,is anything i need to do in the query?

A:
In event hub a receiving more than 1 processed message ,the message is
  not coming as individual events.the message contains more than 1 item.

I'm afraid that you need to parse such coming string into JsonArray with User Defined Function in ASA.
Since split function is not supported by ASA yet so far,you could refer to this case to use CHARINDEX and SUBSTRING functions.


text:
Q: Why does this function works? with this function you can calculate the fibonacci sequence with a recursive function, but i am not sure why this works, i marked at which position i struggled, can someone explain me this code?
fib <- function(n){
  if (n == 0) return(0)
  if (n == 1) return(1)
  seq <- integer(n)  # at this point i didnt understand much at all
  seq[1:2] <- 1
  calc <- function(n) {
    if (seq[n] != 0) return(seq[n])
    seq[n] <<- calc(n-1) + calc(n-2)
    seq[n]
  }
  calc(n)
}

A: In the course of the recursive function evaluation, fib() ends up getting called many times with the same n. One way to make this computation faster is to use memoization, which saves a record of values for which the function has previously been called, and the return values. Using @AnoushArivanR's fib function:
system.time(fib(30))
##    user  system elapsed
##   3.987   0.000   3.987
library(memoise)
fib <- memoise(fib)
system.time(fib(30))
##    user  system elapsed
##   0.004   0.000   0.004

In fact, now that I look at your code above, I believe it's doing exactly this — but it's definitely hard to understand! (Your question might have been better received if you explained that this was what you're trying to do ...)

A: Note
This implementation of fib function has been cited from Mastering Software Development in R by Dr. Roger D. Peng who taught me so much and I am forever grateful to him.
As mentioned above this code is poorly written and has been unnecessarily complicated. Here is a more simpler version. We first check that the n value is not less than 0, then as the first two elements of the sequence are necessary for the series calculation to start (each element being the sum of two previous elements in the series) we set them as 0 and 1 for n == 1 and n == 2 respectively. Then we use recursion which is a technique that a function calls itself from its body creating a series of repetitive computations until the maximum number of n is reached. So for example for n == 3 the function calls it self by calling fib(1) and fib(2) both of which have already been set and so on. Then for fib(4) the function calls both fib(3) and fib(2). fib(2) is already set and fib(3) will be calculated by summing fib(2) and fib(1) and ...
I hope this explanation has helped you get your mind around the idea.
fib <- function(n){
  stopifnot(n > 0)
  if(n == 1) {
    return(0)
  } else if(n == 2) {
    return(1)
  } else {
    fib(n - 1) + fib(n - 2)
  }
}

fib(7)
8

But as some of the calculations are computed more than once for example both fib(6) and fib(5) calculate fib(4) the execution of the function gets slower. For the sake of optimization your code has saved every fib(n) output into and empty vector called seq so before any computation takes place it checks whether the value for seq[n] has already been computed or not. If so, it will be used and if not it will be computed again. This technique is called memoization and whenver a new seq[n] is calculated it will be the nth element of the seq vector and for this purpose we make use of <<- called complex assignment operator as we are modifying an object in the parent environment of the function.


text:
Q: Equivalence between tree of parameters and dividing sequences I have been stuck with an equivalence for a few days now and would like some pointers on how to resolve my issues.
Proposition : Let $(\phi_i(x,y_i) : i < \alpha)$ be a sequence of L-formulas and let $(k_i : i < \alpha)$ be a sequence of natural numbers. For any partial type $\pi(x)$ over A the following are equivalent :

*

*There is a sequence $(b_i : i < \alpha)$ such that $\pi(x) \cup \{\phi_i(x,b_i): i < \alpha\}$ is consistent and for each $i < \alpha, \phi_i(x,b_i), k_i$-divides over $Ab_{<i}$.

*There is a tree $(a_s : s \in \omega^{\leq \alpha})$ such that for each $f \in \omega^\alpha$ $$ \pi(x) \cup \{\phi_i(x,a_{f|i+1}) : i < \alpha\}$$ is consistent and for each $i < \alpha$, for each $s \in \omega^i$, $\{\phi_i(x,a_{sj}) : j < \omega\}$ is $k_i$ inconsistent.

The beginning of the suggested proof for $1 \Rightarrow 2 $ says :
Observe that $a_s$ plays no role if the length of s is $0$ or a limit ordinal. We construct $a_s$ for $s \in \omega^i$ by induction in $i \leq \alpha$ with the addition property that $(a_{s|j+1} : j < i) \equiv_A (b_j : j < i)$.
Assume $s \in \omega^i$ and that $a_s$ has already been obtained. Choose c such that $$ (a_{s|j+1} : j < i)c \equiv_A (b_j : j < i)b_i$$. Then $\phi_i(x,c), k_i$-divides over $A' = A\{(a_{s|j+1} : j < i)\}$[...]
Now I have multiple questions :

*

*When defining a tree for instance $(a_s : s \in \omega^{\leq \omega})$ what is exactly the root ? Since $\omega^{\leq \omega}$ represent finite strings of natural numbers it seems that s $s \in \omega$ gives us child of a root node, but what is it exactly ? Is this what is meant by "Observe that $a_s$ plays no role when the length of s is $0$" ?

*Now for the proof itself, I tried to reduce the induction to the case $i = 1$ by choosing $s \in \omega$ such that $s = 1$ for instance. We assume $a_1$ has been defined such that $a_1 \equiv_A b_0$ (is it the correct interpretation of $(a_{s|j+1} : j < i) \equiv_A (b_j : j < i)$ ? Now we choose $c$ such that $$a_1c \equiv_A b_0b_1$$, I think this is possible by homogeneity of the monster model. Now I do not understand why in this case $\phi_1(x,c)$ divides over $Aa_1$.

What I have tried :
Since $\phi_1(x,b_1)$ divides over $Ab_0$ we can find $(b'_k : k < \omega)$ such that $b_1 \equiv_{Ab_0} b'_k$ and $\{\phi_1(x,b'_k) : k < \omega\}$ is $k_1-$ inconsistent.
We want to show ideally that $c \equiv_{Aa_1} b'_k$ for all $k$ since in this case $\phi_1(x,c)$ would divide.
To this end let $\theta(x) \in tp(c,Aa_1)$. This means that $\models \theta(c,\bar aa_1)$ for some $\bar a \in A$. We would like to show that $\models \theta(b'_k,\bar aa_1)$.
Since $a_1c \equiv_A b_0b_1$  we have $\models \theta(b_1, \bar ab_0)$.
Since $b_1 \equiv_{Ab_0} b'_k$ we have $\models \theta(b'_k, \bar ab_0)$.
At this point I don't know how to introduce $a_1$ and eliminate $b_0$. I am tempted to use the fact that $a_1 \equiv_A b_0$ but this is insufficient since $\theta(b'_k, \bar ab_0)$ involves $b'_k$ and any automorphism of the monster model that fixes $A$ will not fix $b'_k$necessarily.
Thank you for any advice or pointer on how to resolve this.
in the previous text $\equiv_A$ means the types are the same over $A$.

A: Matching the numbering of your two subquestions.
Subquestion 1. The elements of $\omega^{\leq \alpha}$ are sequences of natural numbers of length $\leq \alpha$. The root is the empty sequence, i.e. the sequence of length $0$. If you look carefully at point 2 in the proposition, then you will see that the only $a_s$ that are actually used are of the form $a_{f|i+1}$ or $a_{sj}$. Here "$sj$" stands for "the sequence $s$ with $j$ added to the end". So we only use $a_s$ where the length of $s$ is a successor ordinal. Hence $a_0$ and $a_\ell$ for $\ell$ a limit are not used.
Subquestion 2. You essentially already answered this yourself, but you were trying something too difficult after that. Let's just look at the general case, I do not think working with specific values gives any more insight.  By induction we have $(a_{s|j+1} : j < i) \equiv_A (b_j : j < i)$. So there is an automorphism $f$ of the monster model that fixes $A$ pointwise and such that $a_{s|j+1} = f(b_j)$ for all $j < i$. Then we can define $c = f(b_i)$ and so we get
$$
(a_{s|j+1} : j < i)c \equiv_A (b_j : j < i)b_i.
$$
By assumption $\phi_i(x, b_i)$ $k_i$-divides over $Ab_{<i}$, so $\phi(x, f(b_j))$ $k_i$-divides over $f(Ab_{<i})$. The latter is by construction precisely saying that $\phi(x, c)$ $k_i$-divides over $A\{a_{s|j+1} : j < i\}$.


text:
Q: Subfunctor of a sheaf which is not a sheaf The following is proposition 1 from Maclane & Moerdijk's Sheaves in Geometry and Logic, part II, section 1.
Proposition 1. If $F$ is a sheaf on $X$, then a subfunctor $S\subset F$ is a subsheaf if and only if, for every open set $U$ and every element $f\in FU$, and every open covering $U=\bigcup U_i$, one has $f\in SU$ if and only iff $f|_{U_i}\in SU_i$ for all $i$.
I really feel i'm missing the story here. Why, generally speaking, isn't the condition [$f\in SU$ if and only iff $f|_{U_i}\in SU_i$ for all $i$] enough for a general presheaf, not necessarily a subfunctor of a sheaf, $S$ to be a sheaf?


text:
Q: How to to make sure that the API only processes one request at a time Background: I need to write a REST api wrapper for a 3rd party client dll. However, they're saying that the dlls are not thread safe and we should make sure that our REST api only process one request at a time.
Question: How should we do it? It's my first time dealing with this kind of scenario so I'm currently exploring how possible this is.

A: You can allow a single request at API using the locking mechanisms. Here is the code snippet:
public class Test
{
  private static readonly object _lockObject = new object();
  [HttpGet]
  public IActionResult MethodName
  {
       lock (_lockObject)
        {
          //TODO: your code here.
        }
  }
 }


text:
Q: Space Complexity: Array of Linked List Nodes (Heads) Given an array of head nodes to individual linked lists, what is the space complexity of the array? I would conclude that the space complexity would be o(n) given that each node only contains a pointer to the next. However, when I console.log / print the individual node, the entire list is displayed. Is it possible that the space complexity would be o(n * m) where m is the length of each linked list in the array? Here is a small example:
// JavaScript (ES6)

class Node {
  constructor(value) {
    this.value = value
    this.next = null
  }

  const A = new Node('a')
  const B = new Node('b')
  const C = new Node('c')
  const D = new Node('d')

  A.next = B
  B.next = C
  C.next = D

  console.log(a)

This is the result of the console.log:
{
    value: "a",
    next: {
        value: "b",
        next: {
            value: "c",
            next: {
                value: "d",
                next: null
            }
        }
    }
}

Therefore, when placing Node A in an array: [A] , would the space complexity rise or stay constant?

A: The space complexity is O(n).
What you are seeing from console.log() is that it chases through a few layers of pointers while printing it because that data tends to be really helpful while debugging.  But if you walk through keys/values yourself you'll see that it has a fixed size.


text:
Q: How to redirect SVN stderrs to /dev/null using perl I have a script to check if any data is available on svn repo path but not added into svn. It works fine for me but this gives stderr for adding and sending files like below;
Adding         1/a
Sending        1/a
Transmitting file data ...........
Committed revision 529.

Code:
use strict;
use warnings;

sub notAdded {
        my @svnstatus = `svn st`;
        foreach my $status (@svnstatus) {
                chomp($status);
                if ($status =~ m/^?/) {
                        my ($symble, $left) = split(' ', $status);
                        system("svn add $left");
                }
        }
}

&notAdded();
system("svn commit -m 'comment'");

Can anyone please suggest me how can I redirect this error to /dev/null within the script.

A: The normal way to hide unwanted output with SVN is to use the -q (quiet) flag:
svn -q add nothere

displays nothing.

A: Or the really easy way:
system("svn add $left 2>/dev/null");


text:
Q: Json object through Ajax to Html Datatable I have a PHP code that returns a JSON object which is actually an array of data , and i want to display the JSON content on a datatable but i have been getting this error :
DataTables warning: table id=example - Invalid JSON response
PHP , HTML and JS are below , any help is appreciated , thank you.
PHP :
<?php
include "../config.php";
    $db = config::getConnexion();
    $sql = "SELECT * FROM  produits";
    $req = $db->prepare($sql);
    $req->execute();
    $liste = $req->fetchAll();

    //Convert Array to JSON Obj
    $someJSON = json_encode($liste);
    echo $someJSON;
    //var_dump($someJSON);

    ?>

HTML :

        nom
        num
        prix
        qte
        cat
        desc

        nom
        num
        prix
        qte
        cat
        desc

Javascript :

JSON data :
[{"nom":"chaise1236","0":"chaise1236","num":"1231564658","1":"1231564658","prix":"800","2":"800","qte":"80","3":"80","descr":"description","4":"description","cat":"Interieur","5":"Interieur"},{"nom":"lilyouss","0":"lilyouss","num":"1231564672","1":"1231564672","prix":"5000","2":"5000","qte":"500","3":"500","descr":"youss","4":"youss","cat":"Exterieur","5":"Exterieur"},{"nom":"chaise125","0":"chaise125","num":"1231564660","1":"1231564660","prix":"500","2":"500","qte":"125","3":"125","descr":"descrchaise125","4":"descrchaise125","cat":"Exterieur","5":"Exterieur"},{"nom":"chaise3","0":"chaise3","num":"1231564661","1":"1231564661","prix":"125","2":"125","qte":"500","3":"500","descr":"descr3","4":"descr3","cat":"Interieur","5":"Interieur"},{"nom":"chaise5","0":"chaise5","num":"1231564662","1":"1231564662","prix":"1256","2":"1256","qte":"500","3":"500","descr":"descr55","4":"descr55","cat":"Exterieur","5":"Exterieur"},{"nom":"Fauteuil","0":"Fauteuil","num":"1231564663","1":"1231564663","prix":"550","2":"550","qte":"0","3":"0","descr":"Fauteuil Comfort","4":"Fauteuil Comfort","cat":"Interieur","5":"Interieur"},{"nom":"Fauteuil 2 Places","0":"Fauteuil 2 Places","num":"1231564664","1":"1231564664","prix":"2500","2":"2500","qte":"32","3":"32","descr":"faut Comfortable","4":"faut Comfortable","cat":"Interieur","5":"Interieur"},{"nom":"Tableau Artistique","0":"Tableau Artistique","num":"1231564665","1":"1231564665","prix":"5000","2":"5000","qte":"0","3":"0","descr":"tableau","4":"tableau","cat":"Interieur","5":"Interieur"},{"nom":"Table","0":"Table","num":"1231564667","1":"1231564667","prix":"230","2":"230","qte":"200","3":"200","descr":"Tbmx","4":"Tbmx","cat":"Interieur","5":"Interieur"},{"nom":"AspirateurAS","0":"AspirateurAS","num":"1231564668","1":"1231564668","prix":"125","2":"125","qte":"500","3":"500","descr":"Aspirateur Samsung","4":"Aspirateur Samsung","cat":"Interieur","5":"Interieur"},{"nom":"TableTs","0":"TableTs","num":"1231564669","1":"1231564669","prix":"500","2":"500","qte":"250","3":"250","descr":"Descr","4":"Descr","cat":"Interieur","5":"Interieur"},{"nom":"Prodtest","0":"Prodtest","num":"1231564671","1":"1231564671","prix":"500","2":"500","qte":"500","3":"500","descr":"description test","4":"description test","cat":"Interieur","5":"Interieur"}]


text:
Q: Check Canvas Segment For Transparency I have a canvas. The canvas is w pixels wide and h pixels high.
There is an image on the canvas.
Is there a pixel (or more) with an opacity of less than 1.0 between the two points (a,b) and (c,d)?
It doesn't matter whether there is one (semi-)transparent pixel or whether there are a hundred. A simple true or false value will suffice.
Performance does not matter too much (since this will only be ran once every time the page is loaded, for about 500k pixels).
How does one find out?

A: based on Bresenham algorithm in Javascript
https://jsfiddle.net/f5b8o3hn/
function line(x0, y0, x1, y1){
   var dx = Math.abs(x1-x0);
   var dy = Math.abs(y1-y0);
   var sx = (x0 < x1) ? 1 : -1;
   var sy = (y0 < y1) ? 1 : -1;
   var err = dx-dy;

   while(x0!=x1 || y0!=y1){

     var pixeldata = context.getImageData(x0, y0, 1, 1);
     var data = pixeldata.data;
     for (var i = 0, n = data.length; i < n; i += 4) {
        if (data[i + 3] < 255) {
          console.log(true); //true
          break;
        }
        console.log(data[i + 3]);
     }

     var e2 = 2*err;
     if (e2 >-dy){ err -= dy; x0  += sx; }
     if (e2 < dx){ err += dx; y0  += sy; }
   }
}

//pixeldata[0]   Value of red in decimal (int between 0 and 255)
//pixeldata[i+1] Value of green in decimal (int between 0 and 255)
//pixeldata[i+2] Value of blue in decimal (int between 0 and 255)
//pixeldata[i+3] Alpha Value (int between 0 and 255)


text:
Q: why is 'fast inverse square root' slower than 1/sqrt() at extremely large float? The following full code could compare speed of fast inverse square root with 1/sqrt(). According to this sentence in wikipedia, (i.e. The algorithm was approximately four times faster than computing the square root with another method and calculating the reciprocal via floating point division.)
But here is why I am here: it is slower than 1/sqrt(). something wrong in my code? please.
    #include <stdio.h>
    #include <time.h>
    #include <math.h>

    float FastInvSqrt (float number);

    int
    main ()
    {
      float x = 1.0e+100;

      int N = 100000000;
      int i = 0;

      clock_t start2 = clock ();
      do
        {
          float z = 1.0 / sqrt (x);
          i++;
        }
      while (i < N);
      clock_t end2 = clock ();

      double time2 = (end2 - start2) / (double) CLOCKS_PER_SEC;

      printf ("1/sqrt() spends %13f sec.\n\n", time2);

      i = 0;
      clock_t start1 = clock ();
      do
        {
          float y = FastInvSqrt (x);
          i++;
        }
      while (i < N);
      clock_t end1 = clock ();

      double time1 = (end1 - start1) / (double) CLOCKS_PER_SEC;

      printf ("FastInvSqrt() spends %f sec.\n\n", time1);

      printf ("fast inverse square root is faster %f times than 1/sqrt().\n", time2/time1);

      return 0;
}

float
FastInvSqrt (float x)
{
  float xhalf = 0.5F * x;
  int i = *(int *) &x;  // store floating-point bits in integer
  i = 0x5f3759df - (i >> 1);    // initial guess for Newton's method
  x = *(float *) &i;            // convert new bits into float
  x = x * (1.5 - xhalf * x * x);        // One round of Newton's method
  //x = x * (1.5 - xhalf * x * x);      // One round of Newton's method
  //x = x * (1.5 - xhalf * x * x);      // One round of Newton's method
  //x = x * (1.5 - xhalf * x * x);      // One round of Newton's method
  return x;
}

The result is as follows:
1/sqrt() spends      0.850000 sec.

FastInvSqrt() spends 0.960000 sec.

fast inverse square root is faster 0.885417 times than 1/sqrt().

A: A function that reduces the domain in which it computes with precision will have less computational complexity (meaning that it can be computed faster). This can be thought of as optimizing the computation of a function's shape for a subset of its definition, or like search algorithms which each are best for a particular kind of input (No Free Lunch theorem).
As such, using this function for inputs outside the interval [0, 1] (which I suppose it was optimized / designed for) means using it in the subset of inputs where its complexity is worse (higher) than other possibly specialized variants of functions that compute square roots.
The sqrt() function you are using from the library was itself (likely) also optimized, as it has pre-computed values in a sort of LUT (which act as initial guesses for further approximations); using such a more "general function" (meaning that it covers more of the domain and tries to efficientize it by precomputation, for example; or eliminating redundant computation, but that is limited; or maximizing data reuse at run-time) has its complexity limitations, because the more choices between which precomputation to use for an interval, the more decision overhead there is; so knowing at compile-time that all your inputs to sqrt are in the interval [0, 1] would help reduce the run-time decision overhead, as you would know ahead of time which specialized approximation function to use (or you could generate specialized functions for each interval of interest, at compile-time -> see meta-programming for this).

A: I correct my code as follows:
1. compute random number, instead of a fixed number.
2. count time consumption inside while loop and sum of it.
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>

float FastInvSqrt (float number);

int
main ()
{
  float x=0;
  time_t t;

  srand((unsigned) time(&t));

  int N = 1000000;
  int i = 0;

  double sum_time2=0.0;

  do
    {
      x=(float)(rand() % 10000)*0.22158;
  clock_t start2 = clock ();
      float z = 1.0 / sqrt (x);
  clock_t end2 = clock ();
        sum_time2=sum_time2+(end2-start2);
      i++;
    }
  while (i < N);

  printf ("1/sqrt() spends %13f sec.\n\n", sum_time2/(double)CLOCKS_PER_SEC);

  double sum_time1=0.0;

  i = 0;
  do

    {
      x=(float)(rand() % 10000)*0.22158;
  clock_t start1 = clock ();
      float y = FastInvSqrt (x);
  clock_t end1 = clock ();
        sum_time1=sum_time1+(end1-start1);
      i++;
    }
  while (i < N);

  printf ("FastInvSqrt() spends %f sec.\n\n", sum_time1/(double)CLOCKS_PER_SEC);

  printf ("fast inverse square root is faster %f times than 1/sqrt().\n", sum_time2/sum_time1);

  return 0;
}

float
FastInvSqrt (float x)
{
  float xhalf = 0.5F * x;
  int i = *(int *) &x;  // store floating-point bits in integer
  i = 0x5f3759df - (i >> 1);    // initial guess for Newton's method
  x = *(float *) &i;            // convert new bits into float
  x = x * (1.5 - xhalf * x * x);        // One round of Newton's method
  //x = x * (1.5 - xhalf * x * x);      // One round of Newton's method
  //x = x * (1.5 - xhalf * x * x);      // One round of Newton's method
  //x = x * (1.5 - xhalf * x * x);      // One round of Newton's method
  return x;
}

but fast inverse square root still slower that 1/sqrt().
1/sqrt() spends      0.530000 sec.

FastInvSqrt() spends 0.540000 sec.

fast inverse square root is faster 0.981481 times than 1/sqrt().


text:
Q: Unable to render OneNote image resource after appending preAuthenticated=true option in OneNote api call https://github.com/microsoftgraph/microsoft-graph-docs/issues/2624
I am experience the issue as the above.
I am trying to save the content of a page with a reference to an image by calling https://graph.microsoft.com/v1.0/users/{userId}/onenote/pages/{pageId}/content?preAuthenticated=true
Per this - Downloading one note page with image content as HTML
By appending "?preAuthenticated=true" when you do the fetch, it will make the image public.
But when I tried to render the html, it's giving me "Failed to load resource: the server responded with a status of 401 (Unauthorized)".

A: It appears that something is wrong with the official document: Get OneNote content and structure with Microsoft Graph.
We can see that the service root URL is https://graph.microsoft.com/{version}/{location}/onenote/.
But in any of the samples on this page, the URL is still https://www.onenote.com/api/v1.0/me/notes.
Currently, when you add ?preAuthenticated=true you will get such a URL for a image on this page:
https://graph.microsoft.com/v1.0/users('{userID}')/onenote/resources/{resourceID}/content?publicAuth=true&mimeType=image/png

But when you try to access it in a browser, you will get 401 error Access token is empty.
A workaround is to modify the URL to:
https://www.onenote.com/api/v1.0/resources/{resourceID}/content?publicAuth=true&mimeType=image/png

Then you will get the image.

A: https://github.com/microsoftgraph/microsoft-graph-docs/pull/4339/files
I think they removed the support for it.

A: Bit of off topic, but I figured out how to get the image to render.
https://learn.microsoft.com/en-us/graph/api/resource-get?view=graph-rest-1.0&tabs=http
When you call /onenote/pages/{id}/content, the image has a reference to a source like this
src="https://graph.microsoft.com/v1.0/users({userId})/onenote/resources/{resourceId}/$value"  along with data-src-type="image/jpeg"
do a get request to this endpoint and you'll the image binary, convert the binary to base64, and then just render the html by replacing the src with base64.


text:
Q: Build systray application in VB.Net? I'm using Visual Studio Express 2013 to write a formless VB.Net application that will start and remain iconized in the systray section.
I googled for infos on how to get started but didn't find much.
Would anyone have pointers to get started?
Thank you.

Edit: If you need to add support for a single left click, add the following code to the NotifyIcon1 object so that the application doesn't also open the pop-up menu:
Private Sub LeftClick(sender As Object, e As EventArgs) Handles NotifyIcon1.Click
    'Work-around to prevent Windows from triggering Click then right-click
    Dim MyButton As System.Windows.Forms.MouseEventArgs = e
    If MyButton.Button = MouseButtons.Left Then
        'Find how to put focus on msgbox
        MessageBox.Show("Left click")
    End If
End Sub

A: Creating an application that lives in the system tray is easy, but it is not entirely obvious how to do so in Visual Studio.
1) First, create a new Windows Application project in Visual Studio.NET. This can be either Visual Basic or C#
2) Drag a Notifyicon control and a ContextMenu control from the toolbox onto the form.
3) Click on the NotifyIcon control that you just added, and set the Icon property to whatever icon you want your application to have.
4) Set the ContextMenu property of the Notifyicon to the context menu that you added to your project.
5) Right click on the Context Menu control, and select Edit. Since this menu will be the right-click menu for your tray icon, you will want to add the items that the user will see. Make sure to add an Exit menu item.
6) Double click the Exit menu item, and add the following code:
Me.Close

7) Now for the important settings. Click on the form, and go to the Properties window. Set the following settings:
FormBorderSize: Fixed Tool Window
WindowState: Minimized
Opacity: 0%
ShowInTaskbar: False

The key thing to remember is that the default form is not to be used for application functionality, it is only used as the hidden background window. If you want to create a new window, you can just add another form to your application.


text:
Q: importance of freeing memory?
Possible Duplicate:
What REALLY happens when you don't free after malloc?

When ending a program in C/C++, you have to clean up by freeing pointers. What happens if you doesn't free the memory, like if you have a pointer to an int and doesn't delete it when ending the program? Is the memory still used and can only be freed by restart, or is it automatically freed when the program ends? And in the last case, why free it, if the operating system does it for you?

A: When the program ends, all memory (freed or not) is reclaimed by the operating system. It is still good practice to free everything you allocate, though - mainly just to be in the habit of it, or in case you extend your program so that it doesn't end where it used to.

A: When your program ends all of the memory will be freed by the operating system.
The reason you should free it yourself is that memory is a finite resource within your running program.  Sure in very short running simple programs, failing to free memory won't have a noticable effect.  However on long running programs, failing to free memory means you will be consuming a finite resource without replenishing it.  Eventually it will run out and your program will rudely crash.  This is why you must free memory.

A: On a desktop OS like Windows, Linux or MacOS, your memory will be cleaned up for you.
On some real-time or embedded operating systems, it won't be cleaned up for you.
But it's a good idea to always free memory when you've finished with it - bear in mind that while your program is running, all that memory is still in use.  If you don't free it, the memory usage of the machine will increase.
You have to be careful about refactoring as well - say you start off writing a main() function that allocates some memory, and you don't bother freeing it because the OS will do it for you.  But then you move that code into a function that gets called lots of times, over a long period of time - suddenly you have a huge memory leak.

A: The memory is freed by the OS at program termination, but if all you have is a minor memory leak, that is the least of your worries.
More problematic is: 1) if it happens in a loop, your program balloons in size, and 2) in C++, if your "new"ed objects aren't "delete"d, your destructors aren't run, and this can lead to much more serious problems (mutex leaking, or leaking of resources NOT cleaned up by the OS, data integrity issues, the list goes on)

A: It is important to free memory properly so that tools that help you find memory leaks will have meaningful output when and if you need to track down issues.  Allowing the OS to free the memory for you will add additional noise to any analytical tools that you may use later on.  Even if the OS returns the memory to the system you should have a rock solid design that uses memory in a proper way and allows you the best use of tools.


text:
Q: Content rendering in tabbed content area Good day all.  I'm having an issue getting content to render correctly in one panel of my tabbed content area.  It looks fine in my fiddle: http://jsfiddle.net/Del087/9yptj2nj/ however, it is not rendering correctly on my site.  If you look here http://www.realtimehockey.net/canlan.html and check out the second tab "Youth Classic" you should see what I mean.  Ideally I am trying to get the top two elements to align horizontally with the 3rd element below the two.  I'm sure this is a fairly easy fix but, I just can't seem to figure it out.  Any help would be greatly appreciated.  Thanks.
The CSS

The HTML

    <input type="radio" checked name="tabs" id="tab1">
    Tournaments

    <input type="radio" name="tabs" id="tab2">
    Youth Classic

    <input type="radio" name="tabs" id="tab3">
    Niagara Falls Youth Challenge

    <input type="radio" name="tabs" id="tab4">
    King/Rings I

    <input type="radio" name="tabs" id="tab5">
    King/Rings II

    <input type="radio" name="tabs" id="tab6">
    CANADA O to Y

A: Your table on realtimehockey on tab2 is embedded in extra

....

element (right after first iframe) in table-wrapper. Browser inserts line break before and after div element by the default. Remove this extra div element and it'll work like on jsfiddle. You can apply styl="display: inline;" to this div and it'll also work.


text:
Q: the differences between Jboss Fuse and MuleSoft for System Integration What are the deference between JBoss Fuse and MuleSoft ESB? which one recommended to use for System Integration?

A: JBoss Fuse's all functionalities are opensource, but at the same time the integration stack is quite large to comprehend, IMHO.
MuleSoft's some of their components need to be paid for. They are a bit away from the opensource world, but their offering seems to be more comprehensible, again IMHO. May be, it is because MuleSoft does only 1 thing that is integrations.
  Few interesting articles to read on JBoss vs Mule:
From MuleSoft perspective: https://www.mulesoft.com/resources/esb/understanding-integration-needs-based-perspective-mule-vs-jboss-esb
From RedHat perspective:
https://www.redhat.com/en/resources/red-hat-jboss-fuse-service-works-6-compared-mule-esb-enterprise-34
Have fun !


text:
Q: How do I protect my C# app from memory dump attack? Dumping the memory allows an attacker to read the RAM of the entire OS, or more specifically of a single process. The attacker may save the dump and analyze it "offline" in order to search for sensitive data.
I am trying to understand how exactly this works and if there is a way to prevent it.
Now, let us suppose we have an app which uses AES to protect sensitive data. This is achieved by setting up the key in the aes.Key variable.
public static AesCryptoServiceProvider AESFunction()
    {
        AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
        try
        {
            aes.GenerateIV;
            aes.GenerateKey; //key is stored in aes.Key variable in the AesCryptoServiceProvider class
            aes.Mode = CipherMode.CBC;
            aes.Padding = PaddingMode.PKCS7;
            return aes;
        }
        catch (Exception e)
        {
            throw;
        }
    }

If we debug the aes object data structure in Visual Studio we can cleary see the array of bytes representing the key. If we dispose the object after using it, not anymore.
The question is: is the memory dump attack able to read this value despite disposing it after the usage?
If yes, is there an approach to prevent this from happening?

A: On mainstream devices, the short answer is "no". If someone has admin or physical access to the box, they can grab the entire machine's memory - as a process dump, or an OS dump, and analyze it at their leisure. There is nothing you can do to prevent this except stop access from happening.


text:
Q: list ALL jenkins jobs I try to use a groovy script to list all Jenkins jobs on a server but it fails to get the jobs that are inside multibranch pipelines. I am only able to get the "freestyle projects".
I use Jenkins.instance.getAllItems(AbstractProject.class) but what I understand from the documentation is that, it will list all jobs implementing the AbstractProject class, which is not the case for the multibranch pipelines. Is there another way to proceed to get those jobs?
The ultimate goal is that sometimes, I want to launch all jobs in a folder. That folder contains over 100 multibranch pipeline with a few branches each. I don't want to trigger each one individually as it would be very time consuming.
Thank you.

A: I was looking for the same thing to create an extensible choice parameter listing multibranch jobs. So here's what I came up with based on this answer to a similar question: https://stackoverflow.com/a/50163644
def getBranchNames(project){
    project.getItems().each { job ->
        println(job.getProperty(org.jenkinsci.plugins.workflow.multibranch.BranchJobProperty.class).getBranch().getName())
    }
}
getBranchNames(jenkins.model.Jenkins.instance.getItemByFullName("/multibranch-job-name"))

Hope this helps the next person.


text:
Q: match two exact characters in regex or (pipe) clause I'm trying to parse shorthand notation into an integer representation. This works fine for Hours, Seconds, and Minutes, but not with Milliseconds, where the regex is failing to match.
'50ms'.match(/^(\d+)([MS|S|M|H|ms|s|m|h])$/);
I wasn't sure how to phrase the question correctly, but i did perform several searches prior to asking here.
jsfiddle

A: If you need to match sequences of characters, you need to use alternation groups defiend with (...|...) constructs.
A character class only matches a single character defined in it. See more details on character class here.
Your regex does not work with milliseconds because you require 1 character after digits followed with the end of string immediately. Thus, there is no place for 2 letters "ms".
So, the correct way is to use
'50ms'.match(/^(\d+)(MS|S|M|H|ms|s|m|h)$/);

As Tushar suggests, you can further contract the pattern using /i modifier and reducing the number of alternatives.
/^(\d+)(MS|ms|[SMH])$/i

See this demo


text:
Q: Netlify CMS - Uploadcare - Missing External Media Library My website deploys correctly but whenever I try to access my Netlify CMS admin panel I get this error:
Error loading the CMS configuration

Config Errors:

Error: Missing external media library 'uploadcare'. Please use 'registerMediaLibrary' to register it.

Check your config.yml file.

Here is my config.yml file: https://pastebin.com/raw/gHzhvTGG
Here is my cms.js file: https://pastebin.com/raw/wMGtkKwm
Uploadcare has been registered and it has a valid api key. It was working fine previously.
I am running out of things to try


text:
Q: Do all SATA to USB converters need AC power? I'm shopping for SATA to USB converters. It looks like most need AC power cable as well as the actual converter.
I know that his one leeches the power off the host computer but also has two usb plugs. http://www.newegg.com/Product/Product.aspx?Item=N82E16812123312&cm_re=sata_to_usb--12-123-312--Product
But it is also only for 2.5" drives, I need 3.5"
Now it looks like this cable is supplies only the converter, and you have to buy the power cable separate, correct?http://cgi.ebay.com/USB-2-0-IDE-SATA-5-25-S-ATA-2-5-3-5-Adapter-Cable-/180631892643?pt=LH_DefaultDomain_0&hash=item2a0e7ff2a3
Ideally I'd like a cable that only has one usb and no AC power cable. Is there any like that?

A: There are two issues at play: power consumption (in Watts) and the input voltages to the drive.  As others have mentioned, the total power requirement for any consumer 3.5" desktop drive might be around 13W, which far exceeds what you can get out of a single USB port, which supplies 2.5W (5V * 0.5A).
The second issue is that 3.5" drives require both 12V and 5V DC power, whereas 2.5" drives only require 5V.  USB 2.0 only supplies 5V.
You don't necessarily have to use an external AC adapter to supply the 12V for your 3.5" drive, but since USB only supplies 5V you need to get 12V from somewhere else, such as the following:

*

*an AC adapter that outputs 12V DC - this is what all the manufacturers do

*a desktop computer's power supply - you could wire your own 12V adapter that goes from the 12V DC IN jack on your SATA to USB connector, to the 12V and ground leads on one of the power supply's MOLEX or SATA power connectors (in a desktop computer).  The obvious flaw with this approach is that it wouldn't be very convenient if you want to use the drive on a different computer, and would not work if you wanted to connect the drive to a laptop.

*a battery pack - portable and easy to wire up, but probably not a good idea because you could lose data if the battery died

*stepping up the voltage from several 5V USB headers - technically possible, but completely impractical on USB 2.0 or older ports (and still not very practical on USB 3.0).  As others have noted, any random consumer 3.5" drive might require 13W to initially spin up the hard drive.  A drive on my desk right now is labeled 12V, 0.5A (i.e., 6W).  Assuming perfect power conversion efficiency, that means stepping up the voltage from at least 3 USB 2.0 headers (5V * 0.5A * 3 = 7.5W) or 2 USB 3.0 headers (5V * 0.9A * 2 = 9W).  This particular drive also requires 5V, 0.85A--which could be taken partially from the leftover power supplied by the first few USB headers.  Even if the labeled power consumption refers to the peak power requirements during spinup (rather than typical power requirements), we'll definitely need at least 5 USB 2.0 headers or 3 USB 3.0 headers to fully power the drive.

(NOTE: any modding or custom wiring is done at your own risk)

A: It's not related to either AC or DC power. The drives themselves require DC regulated power.  Some external drives use an AC adaptor, some DC.  Inside the external usb enclosure are electronics that convert AC power to DC.
While it's true that 3.5" drives require a 12V line and USB supplies only 5V, this is not the main limiting factor.  It's possible to boost 5V to 12V using a boost regulator circuit.
e.g.  http://www.circuit-projects.com/converter-circuits/usb-5v-to-12v-dc-dc-step-up-converter-by-lt1618.html
No, the problem is that the USB port cannot supply sufficient current to start spinning the larger drives and maintain that.  And even with a 100% efficient 12V boost circuit it can't supply sufficient power to start the drive spinning and maintain it.  It's obvious that a 2.5" disk being smaller will not require as much power to spin the smaller platters.
USB can only provide 500mA or 2.5W per port. Which is why you see 2.5" drives with 2 USB connectors. That can draw up to 5W.  It may be possible to see a 2.5" drive work with 1 connector.  That would mean that the USB port is supplying enough current.  Not all computers USB ports are in spec and some may give slightly more than the 500mA needed.
Some drives like the new 3TB WD Cavier Green drives claim to have very low power consumption.  However, it's near 13W in total to make it spin up.  Most of that is needed on the 12V rail with only 2W on the 5V rail.  While idle it'll use around 3-4W but when busy near 7W of power.  Well beyond what USB can supply even with 2 connectors.
With 4 USB connectors we could in theory supply 10W of power.  But, it's still not enough for the drive start up.
Now do you get the picture? it's just simpler to have an external power supply.  Although I see that the eSata standard will soon supply drive power too as well as greater speed so I guess all these problems will go away.

A: USB can provide 5V and 0.5A on a single connection, for a total of 2.5W. Consumer 3.5" hard drives draw around 7 or 8 watts while idle, with a little variation around that number depending on the specific drive. That suggests that a single USB port simply cannot power a SATA hard drive on its own, and all available 3.5" hard drive enclosures bear that out.
Some 2.5" drives, however, can be powered out of a single USB port.


text:
Q: Web Services API Versioning I offer a small Web Services API to my clients which I plan to evolve over time. So I need some sort of versioning, but I can't find any information about how you do something like that.
Is there a best practice?
How can I keep adding new functionality without breaking compatibility with the web services consumers?

A: The most common strategy that I've seen is to version the WSDL by adding versioning identification (typically yyyy/MM[/dd]) to the namespace of objects in the wsdl, viz:
targetNamespace="http://schemas.mycompany.com/2010/01/widgets"

This can be done either at a per-type (types/schema) level or at the whole WSDL level - <definitions> in 1.1 or <description> in 2.0.
Somewhat dated, but this link from IBM Developer Works provides the rationale for this approach, and specifically when versions need to be incremented:
Backwards version compatable / non-breaking changes:

*

*Adding new operations

*Adding new types

Breaking changes:

*

*Removing or renaming operations

*Changing parameters to a method

*Changing a complex type

A: I generally add the version string to the web service URL, giving me "versioned endpoints". The code implementing those endpoints can either be shared, if the differences are trivial and can be handled by the same code, or the code can be cloned, or somewhere in between.
The different versioned endpoints could also use versioned XML Schemas, if that's what you need.

A: Versioning is a complex topic, so first, you need to define your goals in a more descriptive manner.  It would be great to say that you have an interface insures you'll never break compatibility, but depending on what the new functionality is, that might not even be possible.  So there are different situations and different trade-offs.
If your intent is to only provide new functionality to new consumers, and all of your consumers are direct consumers (no intermediaries, frameworks, etc.), then a discrete endpoint approach is the best choice.  Each time you add a feature that risks a break, create a new endpoint, give it a new version number and then let the consumers know to validate against it and switch their configurations.  This strategy is pretty tried and true, but it has the drawbacks of putting the burden on consumers to keep up to date.  Also, if there are dependencies between services it can become a chore to track.  The upside being if code breaks it's not (directly) your fault.
The other main strategy is the extensible interface.  There's three different varieties here that I'm aware of.  First, is the type of interface that tries to so well describe the service domain that every possible feature you might add is somehow possible given the existing interface.  If that sounds hard, it is.  You might call this the perfect interface.  Everything is completely described, but the entire domain is also completely described.  The "perfect" is really only on paper though.
The second variety is the type that looks like a normal interface but add generic extension points.  In WSDLs this means xs:any, name-value pairs or something similar.  You might call this the basic extensible interface.  It's not too hard to do, but it's not without it's complications.  The extension points may make the interface harder to work with in certain tooling (xs:any), or explicitly lose some of your ability to validate inputs and outputs (name-value pairs).  It's also pretty easy to abuse those extension points in a way that makes the version 3 or 4 pretty hard to use.
The third variety is the type that converts your interface into a byte-stream.  You might call these god interfaces.  They aren't without their justifications, but if you're using one, you may want to ask why you're using web-services at all.  Maybe you should be thinking about raw TCP/IP, or basic HTTP GET/POST.  But maybe you're fed up with the complexity of WSDLs and XSDs and you just want to start from scratch but you're tied to web-services for some infrastructure reason.  Realize however that once you start down this path, you're going to need a whole new way of describing to your consumers how to/not to use your service, and if you use XSD for that.. well you're basically back where you started.
Your best bet is to know all these options and approach your service design by first trying for the "perfect interface", then giving up and adding generic extensibility points.  Trying to design the perfect interface will force you to learn things which will make your service better, not just your interface, but it will take time, and if you don't limit that time somehow, it'll take forever.
A little bit short of a true god interface, there is the wrapper interface.  If you're system has layers, you want your interface to be in layers too.  When you change layer B, you only want to change layer B, not all the instances in layer C.

A: Add the "API version number" as parameter in all your API's then implement strategy pattern in your web service code where version number dictates what strategy to use.

A: One of the possibilities is to design all web service operations to have only one parameter of a type that inherits from some abstract type that holds version number. This approach is implemented by eBay web services platform.
Something like the following:
<xsd:complexType name="AbstractRequestType">
  <xsd:attribute name="version" type="string" />
  ....

<xsd:complexType name="AddCustomerRequestType">
  <xsd:complexContent>
   <xsd:extension base="AbstractRequestType">
   ....

then use AddCustomerRequestType as a type of only parameter
in addCustomer web service operation.

Additionally if you work over http you may require to add version as a http GET parameter to web service endpoint url, so you'll be able to detect requested version easily
http://server/service?version=1


text:
Q: I have drawn a StickFigure on Blue J with 2 variables. I need to add declaration for further instance variables The StickFigure class only has two instance variables, xPos and yPos, which hold the x- and y-coordinates. I am trying to add declarations for three further instance variables head, body and leg that will reference instances of Circle, Triangle, and Rectangle. this is what I have done so far. I am not sure if it's been done correctly.
Head aHead = new Circle();
Body aBody = new Triangle();
Leg aLeg = new Rectangle();


text:
Q: Making plane parallel to $xy$ axis I want to rotate plane: $2x + 4y + 2z + 4 = 0$ to make it parallel to $xy$ axis by using rotation matrix. In specific, how to calculate angles of rotation? I can't find any good explanation on the web, so if anyone knows how to do it, please help. Thanks.

A: Your plane has normal vector $(2,4,2)$ as read from the coefficients of the equation. You want to rotate that to some multiple of $(0,0,1)$.

how to calculate angles of rotation

You can use the fact that the inner product (dot product) is proportional to the cosine of the angle between the vectors:
$$\langle v,w\rangle=\lVert v\rVert\cdot\lVert w\rVert\cdot\cos\theta$$
which you can rearrange to
$$\theta=\arccos\frac{\langle v,w\rangle}{\lVert v\rVert\cdot\lVert w\rVert}$$
giving you an angle in the range $0°\le\theta\le180°$ as expected. In your case:
$$\theta=\arccos\frac{\left\langle\begin{pmatrix}2\\4\\2\end{pmatrix},\begin{pmatrix}0\\0\\1\end{pmatrix}\right\rangle}{\left\lVert\begin{pmatrix}2\\4\\2\end{pmatrix}\right\rVert\cdot\left\lVert\begin{pmatrix}0\\0\\1\end{pmatrix}\right\rVert}=\arccos\frac{2}{\sqrt{24}\cdot1}=\arccos\frac1{\sqrt6}$$
Usually you'd need to combine this rotation angle with a definition of the axis of rotation. That axis direction would be orthogonal to both the vectors I gave, so you can use the cross product of these vectors to compute the axis.


text:
Q: How to make "git merge --log" stop flattening merge commits I am using a successful git branching model, where you have master branch only consisting from merge commits with version tags, and all the development goes on develop branch.
The develop branch also consists of merge commits (feature branches) and ordinary commits (small individual changes).
When I perform a new version release, I want git to make me a chengelog. git merge develop --log does this, but this "unrolls" merge commits on develop, resulting in a flat history.
I want to make 'git merge --log' use only commits on develop, is this possible?
Examples:
What I atually get now when merging:
Merge branch 'develop' into master

* develop:
  fix 1 on branch develop
  fix 2 on branch develop
  fix 1 on branch b1
  fix 2 on branch b1
  fix 3 on branch b1
  fix 1 on branch b2
  fix 2 on branch b2
  fix 1 on branch b3

What I want it to be:
Merge branch 'develop' into master

* develop:
  fix 1 on branch develop
  fix 2 on branch develop
  Merge branch 'b1' into develop
  Merge branch 'b2' into develop
  Merge branch 'b3' into develop

A: To get the log you want for an inflight merge, use
git log --pretty='  %s' --first-parent ..MERGE_HEAD  # with e.g. `-10` to limit to 10

or to see what that'd get from an existing merge use merge^1..merge^2 as your range.
The quickest way to get to a smoketest is probably git merge --log=1 to generate the right boilerplate, then in vim it'd be
:/^\*/+,+!git log --pretty='  \%s' --first-parent ..MERGE_HEAD

to fill in the log the way you want.  To automate it you'll need to use the prepare-commit-msg hook, something along the lines of
case $2 in
merge)
        git log --pretty='  %s' --first-parent ..MERGE_HEAD >${tempfile=`mktemp`}
        sed -i '/^\*/,/^$/ { //!d }; /^\*/ r '$tempfile  "$1"
        rm $tempfile
        ;;
esac

edit: on GNU/anything, the hook gets simpler because the sed's buffier:
case $2 in
merge)
        git log --pretty='  %s' --first-parent ..MERGE_HEAD \
        | sed -i '/^\*/,/^$/ { //!d }; /^\*/ r /dev/stdin' "$1"
        ;;
esac


text:
Q: VBA Outlook macro for loop error I have written a Outlook macro which is suppose to: Check the subject of unread emails in the inbox, for a PO number. If it finds a PO number, it looks for an associated email adress in an excel file. (Our seller's email), If it finds an email adress, the unread email is forwarded to that address, and the mail marked as read.
The code works fine the first time it encounters an unread email adress with a PO number in the subject. The problem is that the code does not continue with the for loop. Instead I get an error message saying "The element has been moved or deleted". I am 99% sure the problem is that the for loop does not continue the way it should after first encountering a mail that fufills all criterias. Never the less I will post the entire code just to be sure. As always any time used looking at my problems is very greatly appreciated!
Sub ForwardMail()

On Error GoTo eh:

'Initalizing Excel related variables and instances'
Dim xlApp As Object
Dim XlBook As Excel.Workbook

Set xlApp = CreateObject("Excel.Application")
xlApp.Application.Visible = True
Set XlBook = xlApp.Workbooks.Open("My path")

Dim Mailadress As Variant
Dim PoSheet As Excel.Worksheet
Set PoSheet = XlBook.Sheets("SheetName")
'End  Initalizing Excel related variables and instances

'Initalizing Outlook related variables and instances
Dim ns As Outlook.NameSpace
Dim folder As MAPIFolder
Dim item As Object
Dim MailToForward As MailItem

Set ns = Session.Application.GetNamespace("MAPI")
Set folder = ns.Folders("Example@mail.com").Folders("Inbox")
'Slutt initialisering Outlook relatert

Dim PoNumber As Double

'Loop through the items in the inbox folder
For Each item In folder.Items
    DoEvents
    If (item.Class = olMail) And (item.UnRead) Then
        'Find PO number from the subject
        PoNumber = CDbl(FinnPo(item.Subject))

        'If Po number is found, find email adress, using PO number
        If PoNumber <> 0 Then

            'Find email adress in excel file
            Mailadress = xlApp.VLookup(PoNumber, PoSheet.Range("C:D"), 2, False)

            'If mailadress variable is not an error, forward unread email to mailadress.
            If IsError(Mailadress) = False Then
                Set MailToForward = item.Forward
                MailToForward.To = Mailadress
                MailToForward.Send

                'Set mail property as read
                MailToForward.UnRead = False

            Else

            End If

        End If

    End If

Next

XlBook.Close
xlApp.Quit

MsgBox "Macro finished"

Exit Sub

eh:
    MsgBox Err.Description, vbCritical, Err.Number

End Sub

Function FinnPo(Subject As String) As String

    Dim find As String
    Find = "4500"

    Dim Location As Integer
    Location = InStr(Subject, Find)

    If Location <> 0 Then
        FinnPo = Mid(Subject, Location, 10)
    Else
        FinnPo = "0"
    End If

End Function

A: So a lot of googeling finally solved my code problem. The fact that I was sending the mail item MailToForward meant that the item stopped existing. I therefore Had to move the initializing of the variable into the loop. I also had to mark the item.Unread after sending, not the MailItem that had ceased to exist at that point. Hope that helpe anyone else with a similar problem: MailItems stop existing after being sent.