text:
Q: Why can't I get more than 60 FPS in CS:GO? How can I overcome low fps on NVIDIA Geforce 940 MX? I get only 60 fps. This is frustating as this graphics card should be good enough for this light weight game.
Graphics

*

*Driver version : 391.01

*Direct 3D API Version: 12

*Direct 3D Feature Level: 11_0

*CUDA Cores: 384

*Graphics Clock: 1122 Mhz

*Memory data rate: 1800 Mhz

*Memory Interface: 64-bit

*Memory Bandwith: 14.40 GB/s

*Total available Graphics memory: 8134 MB

*Dedicated Video memory: 4096 MB DDR3

*System Video Memory: 0 MB

*Shared System Memory: 4038 MB

*Video BIOS Version: 82.08.59.00.75

*IRQ: Not used

*Bus: PCI Express x4 Gen3

PC

*

*OS: Windows 10 Home, 64-bit

*DirectX Run time version: 12.0

*Processor: Intel i7 7500U @2.70 Ghz

*Memory: 8192 MB RAM

This question isn't certainly a duplicate of "Can my PC run this game?" It obviously can run the game. My question is related to how can I improve the fps? No one else has asked a question with my exact configuration. I have already tried many tweaks and setting video quality to low but still failed to increase
FPS. So I have included my PC's specifications to hope for a solution specific to my problem.
So why has it been marked duplicate?
Steps I had tried:
Setting all video settings to low and everything that radu has recommended in his answer below.

A: Since it is now clear that your computer indeed does support the game with acceptable FPS it is definitely a problem with your VSync settings.
There are now two things left to do:
Since Windows 10 may block/override your VSync settings you should disable that option:

*

*Right-click the CSGO.exe

*Go to Compatibility

*Check the box for Disable fullscreen optimizations

Also make sure you have VSync off in your NVidia Control Panel. It is set to adaptive by default. Change it to off in your 3D Settings if you haven't done that yet. And you probably have done that already, but also make sure VSync is set to off in your in-game settings.
Now your FPS should be fine and you can change it to whatever you like using fps_max <value> in-game or in your config.

A: As others stated you should tweak the in game settings, I have a gtx 980ti and still keep everything on the lowest setting just because the extra detail is not necessary. The only thing that should not be to the lowest setting is shadow quality. At it's lowest settings you do not see them and that is a major issue. Just go one level above lowest.
Also you may have noticed a wierd resolution when you see streamers online. That's because they play on a resolution lower than 1080 and in an aspect ratio that is not 16/9.
It may sound bad at first but this is the way that most pros play and it does have its advantage. What you would want to do is set your resolution to 1024xXXX or even 800x600 and set your aspect ratio to 4:3 (think of the old CRT monitors). once you have these settings you will have black bars on the left and right hand side of your screen (due to the difference in aspect ratio). Some people like to play with black bars some don't. Try out and see what you like.
In order to get rid of the black bars you will have to play in what is considered stretch mode. All you have to do is set the launch option to -fullscreen. Here is a guide that goes more into detail: https://steamcommunity.com/sharedfiles/filedetails/?id=546255142
Here is s1mple's settings, you can see he plays on a Stretched scaling:
http://liquipedia.net/counterstrike/S1mple
Here is pashaBiceps' settings, he is a player who uses black bars:
http://liquipedia.net/counterstrike/Pasha
With your set up you will be able to get over 100 fps, the rest is just tweaking it to whatever you feel comfortable with. This is not a game that is meant to look good, and you really wont care about the level detail when your team beats someone 16-0 in comp.

A: In Video settings, make sure that your FPS isn't capped, which prevents it from going higher than a certain number.

A: This may have been covered in the deleted comments but I think it is worth mentioning for anyone else viewing this question now.
In addition to the answers about the output and performance of your PC, in order to see the extra frames you will need a monitor capable of displaying more than 60fps.
Most standard PC monitors will have a refresh rate of 60hz, this is the maximum number of frames per second the monitor is capable of displaying. Monitors designed for gaming, especially competitive gaming, usually have refresh rates of 120-144hz and sync the GPU output to the monitor refresh rate. Some of the newer ones even go up to 240hz.
It doesn't matter if your PC is capable and set up to run a game at 100fps, if the monitor can only display at 60hz you will still play at 60fps.
Of course you can render the game at 100fps with a 60hz monitor which has benefits like lower input latency and drawbacks like screen tearing but to get the best results you need a capable monitor.

A: Changing the settings to run the game in fullscreen windowed mode worked for me. I got from 60 to 400 FPS


text:
Q: unrecognized selector sent to instance error when switching between pages in objective c I have a windows based iphone application. I have tabs and from one of the tabs I want to switch another page and display facebook in webview in that page. I get unrecognized selector sent to instance error.
Here is my code where I am trying to do switch:
-(IBAction)goFacebookPage:(id)sender
{
    FacebookPage *fbController = [[FacebookPage alloc] initWithNibName:@"FacebookPage" bundle:nil];
    fbController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:fbController animated:YES];
    [fbController release];
}

Traceback is:
2012-03-02 15:29:13.797 TPFApp[2344:b903] -[UIViewController goFacebookPage:]: unrecognized selector sent to instance 0x6818540
2012-03-02 15:29:13.868 TPFApp[2344:b903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController goFacebookPage:]: unrecognized selector sent to instance 0x6818540'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00dc25a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f16313 objc_exception_throw + 44
    2   CoreFoundation                      0x00dc40bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00d33966 ___forwarding___ + 966
    4   CoreFoundation                      0x00d33522 _CF_forwarding_prep_0 + 50
    5   UIKit                               0x000144fd -[UIApplication sendAction:to:from:forEvent:] + 119
    6   UIKit                               0x000a4799 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x000a6c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    8   UIKit                               0x000a57d8 -[UIControl touchesEnded:withEvent:] + 458
    9   UIKit                               0x00038ded -[UIWindow _sendTouchesForEvent:] + 567
    10  UIKit                               0x00019c37 -[UIApplication sendEvent:] + 447
    11  UIKit                               0x0001ef2e _UIApplicationHandleEvent + 7576
    12  GraphicsServices                    0x00ffb992 PurpleEventCallback + 1550
    13  CoreFoundation                      0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    14  CoreFoundation                      0x00d03cf7 __CFRunLoopDoSource1 + 215
    15  CoreFoundation                      0x00d00f83 __CFRunLoopRun + 979
    16  CoreFoundation                      0x00d00840 CFRunLoopRunSpecific + 208
    17  CoreFoundation                      0x00d00761 CFRunLoopRunInMode + 97
    18  GraphicsServices                    0x00ffa1c4 GSEventRunModal + 217
    19  GraphicsServices                    0x00ffa289 GSEventRun + 115
    20  UIKit                               0x00022c93 UIApplicationMain + 1160
    21  TPFApp                              0x00001e19 main + 121
    22  TPFApp                              0x00001d95 start + 53
)
terminate called throwing an exceptionCurrent language:  auto; currently objective-c

The error message:
-[UIViewController goFacebookPage:]: unrecognized selector sent to instance 0x6894210 2012-03-01 21:10:53.218 TPFApp[1750:b903]
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController goFacebookPage:]: unrecognized selector sent to instance 0x6894210'

Thanks

A: The error is telling you that whatever selector (function) is named in the message is being "sent" to the wrong type of object.
Had you even included the barest bit of additional information (such as a copy of the complete message) we'd be able to offer more advice.

A: Find the class you are calling goFacebookPage: and make sure that exists in the same class from which you are calling it from.

A: In Interface Builder you have connected the control (e.g. UIButton?) to the View Controller.  However, you haven't set the type of the View Controller to your custom view controller, and instead have connected it to a default instance of UIViewController.
To fix this, you need to change the type of your View Controller to the class of your Custom View Controller (the class where you define the goFacebookPage: method.  You can do this in the Identity Inspector in Interface Builder - see here:

redpajama_set_name: RedPajamaStackExchange


text:
Q: iOS cocos2d v3 convert openGL code to CCDrawNode I have a visit method for the dot indicator of my Sliding Menu Grid.
- (void) visit
{
    [super visit];//< Will draw after glPopScene.

    BOOL showPagesIndicator = YES;

    ccColor4B pagesIndicatorNormalColor_ = ccc4([sud integerForKey:key_int_r], [sud integerForKey:key_int_g], [sud integerForKey:key_int_b], 255);
    ccColor4B pagesIndicatorSelectedColor_ = ccc4(255, 255, 255, 255);
    if (showPagesIndicator)
    {
        int totalScreens = iPageCount;

        // Prepare Points Array
        CGFloat n = (CGFloat)totalScreens; //< Total points count in CGFloat.
        CGFloat pY = pageIndicatorPosition.y; //< Points y-coord in parent coord sys.
        CGFloat d = may_double(16.0f); //< Distance between points.
        CGPoint points[totalScreens];
        for (int i=0; i < totalScreens; ++i)
        {
            CGFloat pX = pageIndicatorPosition.x + d * ( (CGFloat)i - 0.5f*(n-1.0f) );
            points[i] = ccp (pX, pY);
        }

        // Set GL Values
#if COCOS2D_VERSION >= 0x00020000
//        ccGLEnable(CC_GL_BLEND);
        ccPointSize( may_double(6.0 * CC_CONTENT_SCALE_FACTOR()) );
#define DRAW_4B_FUNC ccDrawColor4B

#else
        glEnable(GL_POINT_SMOOTH);
        GLboolean blendWasEnabled = glIsEnabled( GL_BLEND );
        glEnable(GL_BLEND);

        // save the old blending functions
        int blend_src = 0;
        int blend_dst = 0;
        glGetIntegerv( GL_BLEND_SRC, &blend_src );
        glGetIntegerv( GL_BLEND_DST, &blend_dst );
        glPointSize( may_double(6.0 * CC_CONTENT_SCALE_FACTOR()) );

#define DRAW_4B_FUNC glColor4ub

#endif
        ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

        // Draw Gray Points
        DRAW_4B_FUNC(pagesIndicatorNormalColor_.r,
                     pagesIndicatorNormalColor_.g,
                     pagesIndicatorNormalColor_.b,
                     pagesIndicatorNormalColor_.a);

        ccDrawPoints( points, totalScreens );

        // Draw White Point for Selected Page
        DRAW_4B_FUNC(pagesIndicatorSelectedColor_.r,
                     pagesIndicatorSelectedColor_.g,
                     pagesIndicatorSelectedColor_.b,
                     pagesIndicatorSelectedColor_.a);
        ccDrawPoint(points[iCurrentPage]);

        // Restore GL Values
#if COCOS2D_VERSION >= 0x00020000
        ccPointSize(1.0f);
#else
        glPointSize(1.0f);
        glDisable(GL_POINT_SMOOTH);
        if (! blendWasEnabled)
            glDisable(GL_BLEND);

        // always restore the blending functions too
        ccGLBlendFunc( blend_src, blend_dst);
//        glBlendFunc( blend_src, blend_dst );
#endif
    }
}

It worked fine for my earlier projects but not working for cocos2d v3. I get errors (not valid for C99 etc) for almost every openGL statements, such as glPointSize/ccPointSize and glColor4ub. I have tried to use CCDrawNode (the OOP way) but still it's not one to one translation. (glGetIntegerv etc)
The following link is the test project I created (with errors, notice that the screen is not scrollable, and the dot indicator is not shown (i.e. the visit function is not working)
https://drive.google.com/file/d/0BzH5x38rukpYaVlWdUJPWW9EYWc/edit?usp=sharing
EDIT:
I have tried to use     [renderer enqueueMethod:@selector(drawDotIndicators) target:self]; and put the visit code in drawDotIndicators method. It is not working either
(the end of this tutorial: https://www.makegameswith.us/docs/#!/cocos2d/1.1/customrendering)


text:
Q: MBCalendar kit framework how to add in my project I used MBCalendar kit framework. and successfully added in my project, but problem is that months and dates cant show simulator. only one top bar show in this weeks and year show. I attached my output snap shot please find this and show bellow. I want to successfully calendar show in UI. how it possible please help.
#import "ViewController.h"
#import "CalendarKit/CalendarKit.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  CKCalendarView *calendar = [CKCalendarView new];

  [calendar setDelegate:self];
  [calendar setDataSource:self];

  [[self view] addSubview:calendar];

}

A: Follow my step:
Step 1: remove you are implement all related to MBCalendar.
Step 2: include CKDemoViewController.h & CKDemoViewController.m file in your project.
Step 3: set your view design class to CKDemoViewController.
check some file: https://github.com/BhadreshKathiriya/MBCalendar
 - (IBAction)btnClick:(id)sender {
    [self presentViewController:[[CKDemoViewController alloc] init] animated:YES completion:nil];
    //Or
    [self.navigationController pushViewController:[[CKDemoViewController alloc] init] animated:YES];
 }


text:
Q: refresh a portion of HTML page with jquery Is there a way I could refresh or set to default just a portion of HTML (instead of reloading the whole) page with jquery? For example, I want to reset the following select on some click action. Please help.
Many thanks in advance.
....
<select id="refresh">
   <option value="1" selected>1</option>
   <option value="2">2</option>
   <option value="3">3</option>
   <option value="4">4</option>
</selected>
......

A: I assume you mean using AJAX. The easiest is to use .load.
http://api.jquery.com/load/.  Code would be
$("#refresh").load("page/to/load/content.html #content")

This loads the content within the content.html page that has an id of 'content' into the refresh element.
Of course you could use a server side page to generate the content like a php or ASP.NET page too.


text:
Q: Triggering transparent image layers (.png) on top of a base image using hotspots on base image I don't know where to start. I'm pretty confident there is a solution for what I would like to accomplish but that I may not be using the right terms when searching for help.
On the website that I am building for an Airline I would like to have an image of a map displayed.  The map/image will have several key locations (travel destinations) marked on the map.  The departure point on the map/image for each flight will be the same.  As a user moves the pointer of their mouse over a marked location I would like a track line (dotted line) that represents the flight path of the airplane appear between the departure point and the marked location selected. When the user moves their mouse pointer off the marked location the track line will disappear.
I thought I could use image mapping and have a hot spot behave in such a way that as I rolled over with the mouse a transparent image (containing my track line) would appear on top of my base map/image.  In addition to this effect I would also like a text box unique to the location to appear.  The text box wouldn't be very large but it would have a couple of lines containing some flight information for the location chosen.
I'm not sure where to start with this project.  Any help would be greatly appreciated!!

A: Sorry I forgot to finish it last night. I also didn't get it working with pure css, although there is a way. This way works as well using
document.getElementById(yourid).style.opacity=1;

on hover. Basically it's a couple images stacked on top of each other.
Link to example


text:
Q: Followup questions about the relationship between modular forms and motives It occurs more and more that I ask a question on math stackexchange and then realize that it is more appropriate to mathoverflow. Hopefully this reflects well on myself... In any case, I copy here word for word my question from stackexchange, which received no answers, and I will erase it from there.
In a previous question of mine from a long time ago Matt E gave an excellent exposition to Langlands which has benefited me immensely. Now that I have matured a little bit, I wish to know certain things in more detail.
In the answer to my previous question, Matt E detailed how newforms are related to motives. Newforms are classifies as either classical Atkin Lehner newforms of some weight $k$; and Maass forms of weight $\lambda=\frac14$. Classical Atkin Lehner newforms of weight $k$ should correspond to motives with degree of purity $k-1$, and Maass forms of weight $\lambda=\frac14$ should correspond to degree of purity $0$ motives. (So degree of purity $0$ motives are those that come from classical newforms of weight $1$ and Maass forms.)
A classical Atkin Lehner newform is a cuspform in some $\Gamma_0(N)$ for some $N$, which is a simultaneous eigenvalue of all Hecke operators, such that $N$ is minimal with respect to the associated system of eigenvalues.
My question is: what, if any, is the role played by other congruence and non-congruence subgroups other than $\Gamma_0(N)$? Do they fit into the Langlands philosophy in some way?

A: An automorphic representation $\pi$ in an adelic pircture has an Euler factrozation into $\otimes_v \pi_v$ for all places $v$.
Now at a finite place $v$, the restriction of $\pi_v$ to $GL(2, o_v)$ contains a subrepresentation of $Ind^{GL_2(o)}_{\Gamma_0(p^N)} 1$ for some $N$.
(Actually, more is true, i.e. it differs from $Ind_{B(o)}^{GL_2(o)} 1$ by a finite dimension.)
New forms are in this language the vectors, which occur for some for $p^N$. They will occur for all $p^M$ as well with $M>N$.
This is why it it sufficient to study $\Gamma_0(N)$, which is just the classical analog of the Atkin-Lehner theory.
To study other congruence subgroup seems reasonable and is actually finer. There is a theory of types, which was invented to describe the supercuspidals representations at the finite places. This is one ingredient, if not the ingredient, in the local Langlands correspondance.
For compact non congruence subgroups, Jacquet Langlands is one example.
For a general non compact non congruence subgroups in $SL(2,\mathbb{R})$, one does not even know the existence of cuspforms. But $SL(2,\mathbb{R})$ has a special lattice structure anyway, in the sense that Margulis arithmeticity theorem does not hold.
For higher rank groups, all lattices are commensurable with congruence lattices, but I guess, there are not congruence themself(?)
There is also Beyli's theorem, where the lattices are in general non congruence, but finite index in $SL(2, \mathbb{Z})$.  But there does not exist a connection to the Langlands program, as far as I know.


text:
Q: How to convert the stream generated by wkhmtlopdf in node to base64 string without converting the stream to buffer using AWS Lambda I have a requirement where I need to convert HTML to pdf using wkhtmltopdf using node js and AWS Lambda. So we are using nodejs wrappper for wkhtmltopdf (nodejs-wkhtmltopdf.
So far so good, we are successful in converting the HTML to pdf but the challenges which we are facing is when we have to return the pdf to the client-side.
In express, we are aware that we can pipe the stream to the response object.
stream = wkhtmtopdf(compiledData).pipe(res)

My question is how to do the same in AWS Lambda.
Any help will be highly appreciated.
Thanks,

A: simple.
use express as a layer in lambda and import it in the code of nodejs.
then you can use the same way of pipe the stream to the response.
layers
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html


text:
Q: how to use arrays splice method in ion-list I have a list of data that populates an ionic list with delete function when we swipe the list to left.
I am able to make the delete function to work, however i am stuck how to splice the list when the response if true.
I am using $scope.data.splice($index, 1);
this is my code
HTML
<ion-item ng-repeat="x in data track by $index" href="#/item/{{x.mif_no}}" class="item-remove-animate">
    <ion-option-button class="button-assertive icon ion-trash-a" on-touch="Delete(x.mif_no,x.item_no)"></ion-option-button>
</ion-item>

and this is the js code
JS
$scope.Delete = function(docno,itemno){
$http({
  method: "post",
  url: apiServer + "/fg-in-del.php",
  data: {
    mifno: docno,
    itemno: itemno,
    Dbserver: window.localStorage.getItem("server"),
    Dbuser: window.localStorage.getItem("username"),
    Dbpass: window.localStorage.getItem("password"),
    Dbname: window.localStorage.getItem("dbname"),
  },
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
  }
}).then(function(response) {
  $scope.data=response.data;
  if (response.data == 1){
    var alertPopup = $ionicPopup.alert({
      title: 'Delete',
      template: 'Data has been deleted.'
    });
    $scope.data.splice($index, 1);
  }else {
    var alertPopup = $ionicPopup.alert({
      title: 'Delete',
      template: 'Failed to delete data.'
    });
    console.log(response.data);
  }
}, function(response) {
  $scope.data=response.data;
  var alertPopup = $ionicPopup.alert({
    title: 'Delete',
    template: 'Failed to delete data.'
  });
});
}

A: this code will never work because:
if you set
$scope.data=response.data;

and then check
if (response.data == 1){

$scope.data has to be 1 inside this if condition.
It isn't possible to splice 1? and therefore
$scope.data.splice($index, 1);

won't work.

A: JS
 $scope.Delete = function(docno,itemno,index){
      $http({
        method: "post",
        url: apiServer + "/fg-in-del.php",
        data: {
          mifno: docno,
          itemno: itemno,
          Dbserver: window.localStorage.getItem("server"),
          Dbuser: window.localStorage.getItem("username"),
          Dbpass: window.localStorage.getItem("password"),
          Dbname: window.localStorage.getItem("dbname"),
        },
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
        }
      }).then(function(response) {
        if (response.data == 1){
          var alertPopup = $ionicPopup.alert({
            title: 'Delete',
            template: 'Data has been deleted.'
          });
          $scope.data.splice(index, 1);
        }else {
          var alertPopup = $ionicPopup.alert({
            title: 'Delete',
            template: 'Failed to delete data.'
          });
          console.log(response.data);
        }
      }, function(response) {
        $scope.data=response.data;
        var alertPopup = $ionicPopup.alert({
          title: 'Delete',
          template: 'Failed to delete data.'
        });
      });
    }

HTML
<ion-item ng-repeat="x in data track by $index" ng-hide="x.deleted" href="#/item/{{x.mif_no}}" class="item-remove-animate">
    <ion-option-button class="button-assertive icon ion-trash-a" on-touch="Delete(x.mif_no,x.item_no, $index); x.deleted = true;"></ion-option-button>
</ion-item>


text:
Q: Get last row of parent table I have projects who inside of it have designs. So one project can have multiple designs.
Project table:
+------------+------+
| ProjectKey | Name |
+------------+------+

ProjectDesignTable:
+------------+-----------+
| ProjectKey | DesignKey |
+------------+-----------+

Design Table:
+-----------+------+--------------+----------------+-----------------+
| DesignKey | Name | DesignNumber | DesignTypeGuid | ParentDesignKey |
+-----------+------+--------------+----------------+-----------------+

So I have a select query like this:
SELECT
      *
      FROM [project] AS [p]
          INNER JOIN [ProjectDesign] AS [pd] ON [p].[ProjectKey] = [pd].[ProjectKey]
          INNER JOIN [Design] AS [d] ON [d].[DesignKey] = [pd].[DesignKey]
      WHERE [d].[DesignTypeGuid] = '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D'

There I get all designs in each project who have this DesignTypeGuid: '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D'
That I want to achieve is to get rows after first design key of each project for example if I have this:
    +------------+--------------+-----------+----------------------------------------+-----------------+
| ProjectKey | DesignNumber | DesignKey |               DesignType               | ParentDesignKey |
+------------+--------------+-----------+----------------------------------------+-----------------+
|        152 |            1 |       187 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | NULL            |
|        152 |            2 |      1316 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | NULL            |
|       1171 |            1 |      1206 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | NULL            |
|       1171 |            2 |      1317 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | NULL            |
|       1171 |            3 |      1401 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | NULL            |
+------------+--------------+-----------+----------------------------------------+-----------------+

My desire result is to get:
 152 |            2 |      1316 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D'
1171 |            2 |      1317 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D'
1171 |            3 |      1401 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D'

Once I get this I want to update ParentDesignKey column of each one with first designKey of each project I.E, for this row:
152 |            2 |      1316 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D'

ParentKey should be updated for "187" (DesignKey) of first Design
How can I achieve this?. Regards

A: Here's a cross apply solution:
update d set ParentDesignKey=firstDesignKey
from Design d
cross apply
(
    select top 1 Designkey as firstDesignKey
    from Design dfirst
    inner join ProjectDesign AS pd ON dfirst.DesignKey = [pd].[DesignKey]
    where d.DesignKey = [pd].[DesignKey]
    order by dfirst.DesignNumber asc
)q

A: Assuming I understand the question, you can use lag first_value to get the value of the DesignKey column in the row where the ProjectKey is the same as the current row but the DesignNumber is lower:
SELECT  ProjectKey,
        DesignNumber,
        DesignKey,
        DesignType,
        FIRST_VALUE(DesignKey) OVER(PARTITION BY ProjectKey ORDER BY DesignNumber) AS ParentDesignKey
FROM [ProjectDesign] AS [pd]
INNER JOIN [Design] AS [d]
    ON [d].[DesignKey] = [pd].[DesignKey]
WHERE [d].[DesignTypeGuid] = '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D'

For the sample data you've posted, this query should give you this result set:
+------------+--------------+-----------+----------------------------------------+-----------------+
| ProjectKey | DesignNumber | DesignKey |               DesignType               | ParentDesignKey |
+------------+--------------+-----------+----------------------------------------+-----------------+
|        152 |            1 |       187 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | NULL            |
|        152 |            2 |      1316 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | 187             |
|       1171 |            1 |      1206 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | NULL            |
|       1171 |            2 |      1317 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | 1206            |
|       1171 |            3 |      1401 | '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D' | 1206            |
+------------+--------------+-----------+----------------------------------------+-----------------+

Also, please note you don't actually need to join the Project table since you are not using any of it's columns anywhere.

A: SELECT p.ProjectKey, max(DesignNumber), d.DesignKey, DesignType
FROM [project] AS [p]
      INNER JOIN [ProjectDesign] AS [pd] ON [p].[ProjectKey] = [pd].[ProjectKey]
      INNER JOIN [Design] AS [d] ON [d].[DesignKey] = [pd].[DesignKey]
WHERE [d].[DesignTypeGuid] = '54FBBC23-CB9A-4311-9D7F-0DD7A774F33D'
GROUP BY p.ProjectKey, d.DesignKey, DesignType


text:
Q: Calling JavaScript function through another method There is a JavaScript function that is normally called through a form tag, using onsubmit.
In the code it looks like this:
<form method="post" name="form1" id="form1" onsubmit="return validate(this)">

If I were going to call the validate function through some other method, what variable would I pass it? I mean, the 'this' in the onsubmit call, what would I put there instead? Would it be the id of the form, so "form1"?

A: this refers to the element that the tag creates, that is, the form element. So you would call it with:
validate(document.getElementById('form1');

For more information on events, check out this introduction. The onsubmit attribute you're using is an inline event handler.

A: this in that context is the DOM element(the form)
So you should use it like this:
var form = document.getElementById('form1');
validate(form);


text:
Q: How to display records with certain date from an editbox using ms access and delphi 7 I have a table in MS Access with a name MembersAccount and one of the field name as DatePaid. I am trying to display records from a date entered in an editbox but the output is not displaying any records at all. This is the code I am using.
if ADOQuery1.Locate('datepaid',edit1.Text,[]) THEN
    begin
    open;
    SQL.Clear;
    qry:= 'Select * from MembersAccount WHERE((MembersAccount.[DatePaid])='+edit1.Text+')';
    SQL.Add(qry);
    Active:= True;

Where am I getting the code wrong? Date entered in the editbox is in dd/mm/yyyy format

A: Use parts like these (not full code):
editStr := edit.Text;
myDate := StrToDate(editStr);
sqlDate := FormatDateTime('yyyy/mm/dd', myDate);

qry:= 'Select * from MembersAccount WHERE((MembersAccount.[DatePaid]) = #' + sqlDate + '#)';


text:
Q: Laravel eloquent: GroupBy EMPLOYEE then DAY I am building a Web app with Laravel (6.3)
I have a table appointments which following columns

*

*id

*startDateTime

*endDateTime

*employee_id

*client_id

I want to get results grouped by employees, then inside employees grouped by DAY like this:
  0 => array:5 [▼
    "Angela" => array:6 [▼
        "2020-05-25" => array:2 [▼
            0 => array:6 [▼
              "employee_id" => 6
              "appointmentId" => 566
              "startDateTime" => "2020-05-25 08:00:00"
              "endDateTime" => "2020-05-25 09:00:00"
              "employee" => "Angela"
              "img_slug" => "salon-adam_angela.jpg"
            ]
            1 => array:6 [▼
              "employee_id" => 6
              "appointmentId" => 567
              "startDateTime" => "2020-05-25 09:00:00"
              "endDateTime" => "2020-05-25 10:30:00"
              "employee" => "Angela"
              "img_slug" => "salon-adam_angela.jpg"
            ]
        ]
        "2020-05-26" => array:3
        "2020-05-27" => array:2
        "2020-05-28" => array:4
        "2020-05-29" => array:2
        "2020-05-30" => array:1
    ]
    "Stefanie" => array:6
    "Karolina" => array:6
    "Martina" => array:6
    "Ivonne" => array:1
  ]
]

I am using Laravel, so my eloquent query looks like this
Appointment::where('appointments.employee_id', $employeeId)
    ->join('employees', 'employees.id', 'appointments.employee_id')
    ->join('users', 'users.id', 'employees.user_id')
    ->orderBy('appointments.startDateTime')
    ->select(
        'employees.id as employee_id',
        'appointments.id as appointmentId', 'appointments.startDateTime', 'appointments.endDateTime',
        'users.first_name as employee'
    )
    ->get()
    ->groupBy('employee')
    ->groupBy('appointments.startDateTime')
    ->toArray();

However it just groups by employee, but ignores the day.
If I eliminate the ->groupBy('appointments.startDateTime') I get all the appointments correctly grouped by employee, but when I add the second grouping it just get two levels deeper array, but not grouped by dates.
I have tried all known combinations without success
What am i doing wrong here?

A: You're trying to group by a datetime, not a date.
You need to left or substr your datetime into a date so you can then group by it. Here's an example of how to do it in MySQL
Add ->addSelect(DB::raw("left(appointments.startDateTime, 10) as startDate")) onto your query builder (or alternatively include the DB::raw and its contents in your current ->select()).
Then change your group bys to be ->groupBy(['employee', 'startDate']), and you should be golden.


text:
Q: Google Cloud Speech Versions Google Cloud Speech API has few versions. If I need develop an app using Cloud Speech what version should I need to use?
1.com.google.cloud.speech.v1beta1.
2.com.google.cloud.speech.v1p1beta1.*
3.com.google.cloud.speech.v1

What are the differences between each version?

A: According to Google Speech API release notes, v1beta1 is deprecated as of April 2017.
https://cloud.google.com/speech/release-notes
You should use com.google.cloud.speech.v1
Generally speaking, beta versions work for testing new features that are not available yet, but they are dynamic and some features may change before the final version. They are not recommended for production code.


text:
Q: Divider issue in android xml layout
My goal is to get the layout like the sample about. However, I can't get the small line above the button bar.
What I get is like this.

my xml code is :
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="18dp"
    android:layout_marginRight="18dp"
    android:layout_marginTop="24dp"
    >

  <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:layout_alignParentTop="true"
      android:layout_above="@+id/buttonBarLayout"
      android:showDividers="middle"
      android:divider="?android:dividerHorizontal">

    <TextView
        style="?android:listSeparatorTextViewStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Section header"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:baselineAligned="false"
        android:showDividers="middle"
        android:divider="?android:dividerVertical"
        android:dividerPadding="8dp">

      <TextView
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:textAppearance="?android:textAppearanceMedium"
          android:text="Sample item 1"
          android:layout_gravity="center_vertical"/>

      <ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_action_discard"
          style="?android:borderlessButtonStyle"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:baselineAligned="false"
        android:showDividers="middle"
        android:divider="?android:dividerVertical"
        android:dividerPadding="8dp">

      <TextView
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:textAppearance="?android:textAppearanceMedium"
          android:text="Sample item 2"
          android:layout_gravity="center_vertical"/>

      <ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_action_discard"
          style="?android:borderlessButtonStyle"/>

    </LinearLayout>

  </LinearLayout>

  <LinearLayout
      android:id="@+id/buttonBarLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:orientation="horizontal"
      style="?android:buttonBarStyle"
      >

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Discard"
        style="?android:buttonBarButtonStyle"/>

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Save"
        style="?android:buttonBarButtonStyle"/>

  </LinearLayout>

</RelativeLayout>

I believe that the line is the middle divider. However, if I use LinearLayout the divider will show right under Sample item 2, which is not what I want.
So how can I get what the sample shows?

A: Add an extra View to your layout which will take no height as below...
<View
    android:layout_width="match_parent"
    android:layout_height="0dip" />

Then add the above View and the Linearlayout which holding Buttons inside another LinearLayout with android:divider="?android:dividerHorizontal" attribute as below...
<LinearLayout
    android:id="@+id/buttonBarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:divider="?android:dividerHorizontal"
    android:orientation="vertical"
    android:showDividers="middle" >

    <View
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:background="#000000" />

    <LinearLayout
        style="?android:buttonBarStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="?android:dividerHorizontal"
        android:orientation="horizontal" >

        <Button
            style="?android:buttonBarButtonStyle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Discard" />

        <Button
            style="?android:buttonBarButtonStyle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Save" />
    </LinearLayout>

</LinearLayout>

Finally, your layout will be...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="18dp"
    android:layout_marginRight="18dp"
    android:layout_marginTop="24dp" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/buttonBarLayout"
        android:layout_alignParentTop="true"
        android:divider="?android:dividerHorizontal"
        android:orientation="vertical"
        android:showDividers="middle" >

        <TextView
            style="?android:listSeparatorTextViewStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Section header" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:baselineAligned="false"
            android:divider="?android:dividerVertical"
            android:dividerPadding="8dp"
            android:orientation="horizontal"
            android:showDividers="middle" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:text="Sample item 1"
                android:textAppearance="?android:textAppearanceMedium" />

            <ImageButton
                style="?android:borderlessButtonStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:baselineAligned="false"
            android:divider="?android:dividerVertical"
            android:dividerPadding="8dp"
            android:orientation="horizontal"
            android:showDividers="middle" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:text="Sample item 2"
                android:textAppearance="?android:textAppearanceMedium" />

            <ImageButton
                style="?android:borderlessButtonStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/buttonBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:divider="?android:dividerHorizontal"
        android:orientation="vertical"
        android:showDividers="middle" >

        <View
            android:layout_width="match_parent"
            android:layout_height="0dip" />

        <LinearLayout
            style="?android:buttonBarStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:divider="?android:dividerHorizontal"
            android:orientation="horizontal" >

            <Button
                style="?android:buttonBarButtonStyle"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Discard" />

            <Button
                style="?android:buttonBarButtonStyle"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Save" />
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

Resulted Layout:

A: <?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="18dp"
    android:layout_marginRight="18dp"
    android:layout_marginTop="24dp"
    >

  <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:layout_alignParentTop="true"
      android:layout_above="@+id/buttonBarLayout"
      android:showDividers="middle"
      android:divider="?android:dividerHorizontal">

    <TextView
        style="?android:listSeparatorTextViewStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Section header"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:baselineAligned="false"
        android:showDividers="middle"
        android:divider="?android:dividerVertical"
        android:dividerPadding="8dp">

      <TextView
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:textAppearance="?android:textAppearanceMedium"
          android:text="Sample item 1"
          android:layout_gravity="center_vertical"/>

      <ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_action_discard"
          style="?android:borderlessButtonStyle"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:baselineAligned="false"
        android:showDividers="middle"
        android:divider="?android:dividerVertical"
        android:dividerPadding="8dp">

      <TextView
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:textAppearance="?android:textAppearanceMedium"
          android:text="Sample item 2"
          android:layout_gravity="center_vertical"/>

      <ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_action_discard"
          style="?android:borderlessButtonStyle"/>

    </LinearLayout>

  </LinearLayout>

  <LinearLayout
      android:id="@+id/buttonBarLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:orientation="Vertical"
      style="?android:buttonBarStyle"
      >
      <View android:id="@+id/divider"
        android:layout_widht="match_parent"
        android:layout_height = "1dp"
        android:background="@android:color/black"/>

  <LinearLayout
      android:id="@+id/buttonBarLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
       android:orientation="horizontal"
      style="?android:buttonBarStyle"
      >

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Discard"
        style="?android:buttonBarButtonStyle"/>

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Save"
        style="?android:buttonBarButtonStyle"/>

  </LinearLayout>
 </LinearLayout>

</RelativeLayout>

A: check this below layout. I've made few changes to add the horizontal divider above ButtonBarLayout.
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  android:layout_alignParentTop="true"
  android:layout_above="@+id/buttonBarLayout"
  android:showDividers="middle"
  android:divider="?android:dividerHorizontal"
  android:layout_marginLeft="18dp"
  android:layout_marginRight="18dp"
  android:layout_marginTop="24dp" >

<TextView
    style="?android:listSeparatorTextViewStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Section header"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:baselineAligned="false"
    android:showDividers="middle"
    android:divider="?android:dividerVertical"
    android:dividerPadding="8dp">

  <TextView
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:textAppearance="?android:textAppearanceMedium"
      android:text="Sample item 1"
      android:layout_gravity="center_vertical"/>

  <ImageButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      style="?android:borderlessButtonStyle"/>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:baselineAligned="false"
    android:showDividers="middle"
    android:divider="?android:dividerVertical"
    android:dividerPadding="8dp">

  <TextView
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:textAppearance="?android:textAppearanceMedium"
      android:text="Sample item 2"
      android:layout_gravity="center_vertical"/>

  <ImageButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      style="?android:borderlessButtonStyle"/>

</LinearLayout>

</LinearLayout>

<LinearLayout android:id="@+id/buttonBarLayout"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_alignParentBottom="true"
  android:orientation="vertical"
  style="?android:buttonBarStyle">

  <View
      android:layout_width="fill_parent"
      android:layout_height="1dp"
      android:background="#F1F1F1" />

  <LinearLayout android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  style="?android:buttonBarStyle">

<Button
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="Discard"
    style="?android:buttonBarButtonStyle" />

<Button
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="Save"
    style="?android:buttonBarButtonStyle" />
</LinearLayout>

A: You have to give the id to the Linear layout above the button linear layout and place the view in between the button linear layout and linear layout above it.
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="18dp"
    android:layout_marginRight="18dp"
    android:layout_marginTop="24dp">

  <LinearLayout
      android:id="@+id/layout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:layout_alignParentTop="true"
      android:layout_above="@+id/buttonBarLayout"
      android:showDividers="middle"
      android:divider="?android:dividerHorizontal">

    <TextView
        style="?android:listSeparatorTextViewStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Section header"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:baselineAligned="false"
        android:showDividers="middle"
        android:divider="?android:dividerVertical"
        android:dividerPadding="8dp">

      <TextView
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:textAppearance="?android:textAppearanceMedium"
          android:text="Sample item 1"
          android:layout_gravity="center_vertical"/>

      <ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_action_discard"
          style="?android:borderlessButtonStyle"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:baselineAligned="false"
        android:showDividers="middle"
        android:divider="?android:dividerVertical"
        android:dividerPadding="8dp">

      <TextView
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:textAppearance="?android:textAppearanceMedium"
          android:text="Sample item 2"
          android:layout_gravity="center_vertical"/>

      <ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_action_discard"
          style="?android:borderlessButtonStyle"/>

    </LinearLayout>

  </LinearLayout>

  <View
       android:id="@+id/view1"
android:layout_width="fill_parent"
 android:layout_height="1dp"
  android:layout_below="@+id/layout1"
 android:background="#000000" />

  <LinearLayout
      android:id="@+id/buttonBarLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"

      android:orientation="horizontal"
      style="?android:buttonBarStyle">

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Discard"
        style="?android:buttonBarButtonStyle"
        />

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Save"
        style="?android:buttonBarButtonStyle"/>

  </LinearLayout>

</RelativeLayout>


text:
Q: Force computed.filter() to update? I've got a filter that works once, with whatever values are pre-initialized in, just at initial initiazation, but never updates.  editstate is a service; in this case it just provides those exposed variables.  So the idea is that when editstate.filterValue and editstate.filterField are changed, the filter should update.
But it doesn't.
I've tried having them be local computed values also, but no dice.  The only programmatic thing that works so far is to unrender and rerender the entire component using a handlebars {{#if toggle.
export default Ember.Component.extend({
    store: Ember.inject.service(),
    editstate: Ember.inject.service('edit-state'),
    filteredList: Ember.computed.filter('model', function(current, index, all) {
            return current.get(Ember.get(this.get('editstate'), 'filterField')) == Ember.get(this.get('editstate'), 'filterValue');
    }),

What am I missing?  I don't see any API for forcing a filter to re-compute, nor to tell it more explicitly to watch these values.
Update: I found a terrible hacky way to accomplish my goal: In my service, I create but don't save a record in the model that I'm filtering, just to force updates.  Whenever the filter parameters change, I update that record with the current time (millis).  And of course it's always filtered out by the filter.
It's ugly, it's probably evil... is there a better way?

A: Define every variable (that you use in computed function) at computed definition:
export default Ember.Component.extend({
  store: Ember.inject.service(),
  editstate: Ember.inject.service('edit-state'),
  filteredList: Ember.computed('model', 'editstate.filterField', 'editstate.filterValue', function() {
    return this.get('model').filter((current) => {
      return current.get(Ember.get(this.get('editstate'), 'filterField')) === Ember.get(this.get('editstate'), 'filterValue');
    }
  }),
  ...

or even more readable:
export default Ember.Component.extend({
  store: Ember.inject.service(),
  editstate: Ember.inject.service('edit-state'),
  filteredList: Ember.computed('model', 'editstate.filterField', 'editstate.filterValue', function() {
    let filterField = Ember.get(this, 'editstate.filterField');
    let filterValue = Ember.get(this, 'editstate.filterValue');
    return this.get('model').filterBy(filterField, filterValue);
  }),
  ...


text:
Q: Java, LDAP with MySQL, and authenticating users There's a few moving pieces to this one, so I'll go through things fairly slowly.

*

*I have a java web app that has registered a few thousand users, and stored them in a MySQL DB. The passwords for each user has been hashed using SHA1, plus a bit of extra trickery including a randomly generated salt.

*I also have an LDAP server setup (OpenLDAP). I've managed to configure it to use the same MySQL DB as above as a datasource.

*There is a Lotus Domino server. When users register via the java web app they are also added to the domino server.
When the users try to log into the Domino server is where we have the problems. Currently we're using LDAP authentication (on the LDAP server above). It works if passwords are stored in clear-text, or a straight SHA1 hashing, but the LDAP server can't authenticate those users who have their passwords encrypted by the java web app above (it uses SHA1, plus "extras").
So I'm really not sure how to approach things. Someone suggest using LDAP with SASL authentication - but I'm not even sure that would work.... I would have to replicate the same encryption algorithm that is in use in the java web app somehow.
Any ideas?

A: You might want to look into setting up directory assistance on your Domino server.  Start here --> http://publib-b.boulder.ibm.com/lotus/c2359840.nsf/b3266a3c17f9bb7085256b870069c0a9/b3d4579a610b349885257361004fbdb5?OpenDocument
Hope this helps.


text:
Q: I want to get Java Edition a different device. Will the progress be the same? I used to play on a iPad for Minecraft Bedrock Edition, but I want to play on a computer. My parents will only allow me to pick one of the two editions, Bedrock or Java.
If I use the same account on both editions, will the worlds and the progress on servers be the same?

A: No, worlds are not cross-compatible between Java and Bedrock editions. You may use an external program to convert a world between the two editions but this may break some things or cause them to function differently. For example, redstone functions differently between Java and Bedrock editions. Converting your world may cause the mechanisms to break.
Worlds are also not synced between editions, and are stored locally per your device, not on the account level.
In your case, you're going to have to pick an edition, lock in your choice, and wait until your parents will let you buy the other.

A: There is no official way to mix Java and Bedrock content and multiplayer. I can help you out with certain ways on how you can go about getting progress if you buy the Bedrock version.
If you play using Bedrock on PC with the same Microsoft account as your iPad, you should be able to use a realm to move worlds to your PC version. Note that a realm costs money, and unless you saved your 30-day free trial, there is no other way that I am aware of that is fully supported by Mojang.
As a side note, anything you bought in the Marketplace AFTER the better together update is transferred for free as long as the same Microsoft account is used. And, if you play on servers, all progress and personalization should sync as long as the same Microsoft account.
(This is my first answer. Please let me know how I can improve the quality of my posts)


text:
Q: My old monitor Samsung Syncmaster 740n needs 2-3 min to turn on When I power on my old monitor Samsung Syncmaster 740n, it needs needs 2-3 min to power on. When it turns on, it works fine.
What can be wrong with it and if it possible how to fix it?

A: Almost inevitably this will be due to failing capacitors in the power supply section of your monitor. These can 'dry out' (the commonly used term) and become less effective, with the usual symptoms being some mix of:

*

*a failure to power on

*cycling power on and off

*taking a longer time to power up

This is a common problem with electronics, particularly from a certain time where poor quality control and/or penny-pinching in the supply chain caused a large rise in such failures around 10-15 years ago.
The problem is that the symptoms usually only appear well outside of any warranty period, and often even after manufacturer support for a model has ended.
Happily, this is usually an easy enough thing to fix. Any competent electronic repair shop should be able to diagnose and replace the capacitors. Although they are only a few pennies each, the labour costs may mean this is uneconomic though, given the costs of a new, likely superior, monitor.
If you have a soldering iron and a sense of adventure you may want to try this yourself though. There exist many self-help guides on the internet (www.badcaps.net is a good place to start), and indeed I had much success doing this myself when my printer started playing up a couple of years ago.


text:
Q: How to migrate a Project from 'OpenShift Web Console' to '(Next Gen) Web Console'? Is there a way to migrate a server application (with its repository), to the new Next Gen Console?
I have already a WildFly server in my personal account at URL: https://openshift.redhat.com/app/console/applications
But when I open the Next Gen Console, it's empty, and suggest me to create new project with a new server.
https://console.preview.openshift.com/console/
Is there a way to avoid setting up everything again?
I would like to keep server configurations, git repository, and Jenkins app from my former OpenShift Web Console.

A: Sorry, there is no direct migration tool. The manner in which the systems works is quite different from an operational standpoint, but you are also potentially going to have to tweak how your application code is organised and configured. I would suggest you create a fresh application in the new version to learn more how they are different and then you can plan what you may need to do to migrate it. I would suggest making using of the Google Group for OpenShift if you have more questions as it provides a better forum for discussion.

*

*https://groups.google.com/forum/#!forum/openshift


text:
Q: Which number of "Reallocated Sectors Count" should I trust in Crystal Disk Info? Using Crystal Disk Info checking the hard drives "Reallocated Sectors Count", which number is the correct one and why do they differ?
Why is the tooltip number different from the one in the list?
I assume the number in the list, but it boggles my that the tooltip is different.

A:
Using Crystal Disk Info checking the hard drives' "Reallocated Sectors Count", which number is the correct one, and why do they differ?

The value is stored in hexadecimal, and the notification is displaying the value in decimal.

Why is the tooltip number different from the one in the list?

They are, in reality, the same number.
Current, Threshold and Worst are all integer values.  As the drive has additional failed sectors, resulting in sectors being reallocated, the Threshold will decrease.  Once it hits 140 the software you are using will considered the drive to be failing.

A: The raw value is 1410 which in hex is equals to 5136 in decimals. What the 194 means I haven't figured out yet though.

hex
decimal

1410
5136

194
404

140
320

So, the ID:05 Raw values that contains the value in hexadecimal and the value in the tooltip in decimal.
EDIT: the rows strike through are rubbish as they are not in hex in the listing but integers as the comment below says.


text:
Q: Why am I getting "Unable to load the specified metadata resource" error? I have an MVC5 web application which I usually develop using my laptop.
I am trying to get the app running on my main machine at home for home-working days but have a problem connecting to the local dev database on SQL Server - when I start the app I get the following error:
More info 30/11/16:
Note that the model is generated from EDML using Entity Developer

Unable to load the specified metadata resource. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

The solution consists of 2 projects, one of which is an entity model project which is generated from EDMX.
Note: On my main machine (where it isn't working) the connection string in Web.config is the same as the machine where it works except for Data Source which refers to the SQL Server name on the main machine - I have checked this is correct several times:
I have read several Stack Overflow posts with similar issues - most point to something wrong with the path to the csdl, ssdl, msl part of the connection string.
I have:

*

*Checked the server name is correct in the connection string

*Checked the database name is correct in the connection string

*Checked the database exists and is available

*Checked each of the three files are where the connection string says they are (they are)

*Tried using wildcard in the connection string: res://*/dllname.csdl|res://*/dllname.ssdl|res://*/dllname.msl
Update 30/11/2016:
From the suggestions in this link I have:

*

*Checked the MetadataArtifactProcessing property - it is not set to Copy to Output directory

*Checked the connection string

*We don't have a post-compile task

From the suggestion in this link I have tried setting the connection string connectionString="metadata=res://*/;
Stack Trace:
[MetadataException: Unable to load the specified metadata resource.]
   System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderResource.LoadResource() +85
   System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderResource.CreateReader() +10
   System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderResource.CreateReaders(DataSpace spaceToGet) +72
   System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderComposite.CreateReaders(DataSpace spaceToGet) +99
   System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadEdmItemCollection(MetadataArtifactLoader loader) +41
   System.Data.Entity.Core.Metadata.Edm.<>c__DisplayClass5.<GetMetadataWorkspace>b__0(String k) +37
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +72
   System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(String cacheKey, MetadataArtifactLoader artifactLoader) +75
   System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions effectiveConnectionOptions) +126
   System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace() +43
   System.Data.Entity.Core.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection() +20
   System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory) +393
   System.Data.Entity.Core.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) +35
   App.Models.Entities..ctor() in C:\Users\Me\Desktop\App\App.MVC5\App.Entities.cs:37
   App.MVC5.Models.CurrentUser..ctor(Boolean IsGuiDetailsRequired) in C:\Users\Me\Desktop\App\App.MVC5\Models\AccountModels.cs:87
   App.MVC5.Controllers.HomeController..ctor() in C:\Users\Me\Desktop\App\App.MVC5\Controllers\HomeController.cs:11

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +114
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
   System.Activator.CreateInstance(Type type) +11
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +55

[InvalidOperationException: An error occurred when trying to create a controller of type 'App.MVC5.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +178
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +76
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +88
   Castle.Proxies.Invocations.IControllerFactory_CreateController.InvokeMethodOnTarget() +118
   Castle.DynamicProxy.AbstractInvocation.Proceed() +80
   Glimpse.Core.Extensibility.CastleInvocationToAlternateMethodContextAdapter.Proceed() +11
   Glimpse.Core.Extensions.AlternateMethodContextExtensions.TryProceedWithTimer(IAlternateMethodContext context, TimerResult& timerResult) +41
   Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context) +25
   Glimpse.Core.Extensibility.AlternateTypeToCastleInterceptorAdapter.Intercept(IInvocation invocation) +84
   Castle.DynamicProxy.AbstractInvocation.Proceed() +108
   Castle.Proxies.IControllerFactoryProxy.CreateController(RequestContext requestContext, String controllerName) +214
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +194
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +50
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

A: There's a very popular question over there and from its rating I can assume it helped a lot of people. It even mentions a blog post with complete troubleshooting for this problem. Also, this answer looks like something you didn't try yet.


text:
Q: Determining the previous page in mvc 3 How to check the previous page in mvc 3 application.
Previous Page.

On click of the above link I have to go back to previous page.
How to do this ?

A: This will depend on how is the navigation organized on your website. One possibility is to use the history.go(-1) javascript function which will simply simulate the browser back button:
Previous Page.

Another possibility is to have the calling page pass a ReturnUrl query string parameter to this page which could be used to construct the link:
Previous Page.

Of course this assumes that when you called the controller action that rendered this view you have passed the ReturnUrl query string parameter.

A: Same as Matthew's answer but using a session variable.  That way you could update it selectively in the Action you want.  For example, on a POST action you wouldn't want them to go back to that view with form values there.  What you really want is for them to go back to the page before that.
public ActionResult MyNextPage(string prevUrl)
{
    Session["prevUrl "] = prevUrl;
    View();
}

Then in the View:
Previous Page

Note that if session is expired or null it will throw an exception.


text:
Q: Parameter not working as hard coded value Just rewriting some SQL codes and just testing the results.  When I run the query with hard coded filters, it runs, but when I use a variable it never runs or at least to the time I'm expecting the query with hard coded filter.
Can someone please help me or explain what is wrong.
-- THIS DOESN'T RUN
DECLARE @PortfolioCode INT = 519
    , @ReportDate DATETIME = '2019-09-19'

SELECT
    TCSELL.RemainingQuantityPerc
    , SomeVal1 = TCBUY.SettleAmountTranCcy    * TCSELL.RemainingQuantityPerc
    , SomeVal2 = TCBUY.SettleAmountSettCcy * TCSELL.RemainingQuantityPerc
    , TCSELL.*
FROM
    dbo._Dolfin_vwTradeCost TCBUY
        INNER JOIN dbo._Dolfin_vwTradeSellRunningQty TCSELL
        ON TCBUY.PortfolioCode = TCSELL.PortfolioCode
        AND TCBUY.TitleCode = TCSELL.TitleCode
        AND TCBUY.DocNo = TCSELL.DocNo
        AND TCSELL.RunningQuantity > 0
WHERE 1 = 1
    AND TCBUY.PortfolioCode = @PortfolioCode
    AND TCSELL.ReportDate = @ReportDate

-- THIS WORKS
SELECT
    TCSELL.RemainingQuantityPerc
    , SomeVal1 = TCBUY.SettleAmountTranCcy    * TCSELL.RemainingQuantityPerc
    , SomeVal2 = TCBUY.SettleAmountSettCcy * TCSELL.RemainingQuantityPerc
    , TCSELL.*
FROM
    dbo._Dolfin_vwTradeCost TCBUY
        INNER JOIN dbo._Dolfin_vwTradeSellRunningQty TCSELL
        ON TCBUY.PortfolioCode = TCSELL.PortfolioCode
        AND TCBUY.TitleCode = TCSELL.TitleCode
        AND TCBUY.DocNo = TCSELL.DocNo
        AND TCSELL.RunningQuantity > 0
WHERE 1 = 1
    AND TCBUY.PortfolioCode = 519
    AND TCSELL.ReportDate = '2019-09-19'

A: Please examine what is the datatype of the column ReportDate in the table or view called dbo._Dolfin_vwTradeSellRunningQty (which has the alias of TCSELL).
If the datatype is a DateTime then that should be OK. If it is a string of some sort (like Varchar or Char) then you must also change your variable @ReportDate into that datatype.


text:
Q: NVIDIA drivers don't work with GTX 780 I was using GTX 560 with nvidia's drivers in Ubuntu without problem. Then I have removed that video card and used Intel HD4000 for a week. After that I installed GTX 780, connected LCD with HDMI cable (no DVI on it) and it got weird.
The only resolution I have is 1024*720, SystemSettings--Displays calls my LCD a 'Laptop' and offers no options for it. SystemSettings--Software--Additional Drivers is empty.
I have tried installing nvidia driver packages from repositories with apt-get but it did no visible difference. X just does not pick them up. I just feel that writing xorg.conf in 2013 is not a right thing to do. Am I wrong?
Sure, I can just download NVIDIA drivers from their site, install drivers from binary, create xorg.conf file and be entitled to manual reinstallation of it with every kernel update. May be somebody can tell me a less awkward solution?

A: I have installed CCSM, and toggled OpenGL plugin  off and on there. Then did it with unity plugin. It helped.
The error seems to be reproducible on several PC, including fresh install of Ubuntu. Video card version does not matter, though.


text:
Q: How do I implement word wrap? XNA has Spritefont class, which has a MeasureString method, which can return the Width and Height of a string. I'm trying to understand how to create a method that will efficiently return a string with Environment.Newline inserted in the right places, so that if fits a certain Width and Height (Rectangle is used as a parameter for that).

A: I found following code: XNA - Basic Word Wrapping
public string WrapText(SpriteFont spriteFont, string text, float maxLineWidth)
{
    string[] words = text.Split(' ');
    StringBuilder sb = new StringBuilder();
    float lineWidth = 0f;
    float spaceWidth = spriteFont.MeasureString(" ").X;

    foreach (string word in words)
    {
        Vector2 size = spriteFont.MeasureString(word);

        if (lineWidth + size.X < maxLineWidth)
        {
            sb.Append(word + " ");
            lineWidth += size.X + spaceWidth;
        }
        else
        {
            sb.Append("\n" + word + " ");
            lineWidth = size.X + spaceWidth;
        }
    }

    return sb.ToString();
}

A: To add to Alina's answer, here is an extended version of that function, that will also linebreak single words that are longer than maxLineWidth
    public static string WrapText(SpriteFont font, string text, float maxLineWidth)
    {
        string[] words = text.Split(' ');
        StringBuilder sb = new StringBuilder();
        float lineWidth = 0f;
        float spaceWidth = font.MeasureString(" ").X;

        foreach (string word in words)
        {
            Vector2 size = font.MeasureString(word);

            if (lineWidth + size.X < maxLineWidth)
            {
                sb.Append(word + " ");
                lineWidth += size.X + spaceWidth;
            }
            else
            {
                if (size.X > maxLineWidth)
                {
                    if (sb.ToString() == "")
                    {
                        sb.Append(WrapText(font, word.Insert(word.Length / 2, " ") + " ", maxLineWidth));
                    }
                    else
                    {
                        sb.Append("\n" + WrapText(font, word.Insert(word.Length / 2, " ") + " ", maxLineWidth));
                    }
                }
                else
                {
                    sb.Append("\n" + word + " ");
                    lineWidth = size.X + spaceWidth;
                }
            }
        }

        return sb.ToString();
    }

A: To handle a block of text with carriage returns you need to modify the code as below:
  public static string WrapText(SpriteFont font, string text, float maxLineWidth)
    {
        string[] words = text.Split(' ');
        StringBuilder sb = new StringBuilder();
        float lineWidth = 0f;
        float spaceWidth = font.MeasureString(" ").X;

        foreach (string word in words)
        {
            Vector2 size = font.MeasureString(word);

            if (word.Contains("\r"))
            {
                lineWidth = 0f;
                sb.Append("\r \r" );
            }

            if (lineWidth + size.X < maxLineWidth )
            {
                sb.Append(word + " ");
                lineWidth += size.X + spaceWidth;
            }

            else
            {
                if (size.X > maxLineWidth )
                {
                    if (sb.ToString() == " ")
                    {
                        sb.Append(WrapText(font, word.Insert(word.Length / 2, " ") + " ", maxLineWidth));
                    }
                    else
                    {
                        sb.Append("\n" + WrapText(font, word.Insert(word.Length / 2, " ") + " ", maxLineWidth));
                    }
                }
                else
                {
                    sb.Append("\n" + word + " ");
                    lineWidth = size.X + spaceWidth;
                }
            }
        }

        return sb.ToString();
    }


text:
Q: Overloads vs generic arguments I have a question. In the framework, that was largely written before the generics came, you often see a function with lots of overloads to do something with different types.
a)
Parse(int data)
Parse(long data)
Parse(string data)
..etc

That seems to be to be ok as it helps keeping code small for each method and so. On the other hand, now with generics you can do the following:
b)
Parse<T>(T data)

and then have some kind of ifs/switch statements with typeof() to try to infer what the types are and what to do with them.
What is best practise? Or what are the ideias that'd help me choose between a) and b)?

A: Code Smell.
If you have "some kind of if/switch", that is a code smell that just screams polymorphism. It suggests that generics is not the solution to that problem. Generics should be used when the code does not depend on the concrete types you pass into it.
Watch this Google Tech Talks Video: "The Clean Code Talks -- Inheritance, Polymorphism, & Testing". It addresses specifically what you are talking about.

A: The pattern your describing where the use of generics results in a bunch of ifs/switch statements is an anti-pattern.
One solution to this is to implement a strategy pattern, which allows you to use generics, but at the same time isolating concerns of the Parse method from knowing how to deal with every different case.
Example:
class SomeParser
{
    void Parse<T>(ParseStrategy<T> parseStrategy, T data)
    {
        //do some prep

        parseStrategy.Parse(data);

        //do something with the result;
    }
}

class ParseStrategy<T>
{
    abstract void Parse(T data);
}

class StringParser: ParseStrategy<String>
{
    override void Parse(String data)
    {
        //do your String parsing.
    }
}

class IntParser: ParseStrategy<int>
{
    override void Parse(int data)
    {
        //do your int parsing.
    }
}

//use it like so
[Test]
public void ParseTest()
{
    var someParser = new SomeParser();
    someParser.Parse(new StringParser(), "WHAT WILL THIS PARSE TO");
}

and then you would be able to pass in any of the strategies you develop.  This would allow you to properly isolate your concerns across multiple classes and not violate SRP (single responsibility principle.

A: IMHO, if you need if/switch statements, you should better overload. Generics should be used where the implementation does not depend on the concrete type to still reuse it.
So as a general rule:

*

*overload if there will be a separate implementation for each type

*use generics if you can have a single implementation that works for all possible types.

A: One issue here - if you're requiring if/switch statements to make generics work, you probably have a larger problem.  In that situation, it is most likely that the generic argument won't work (correctly) for EVERY type, just a fixed set of types you are handling.  In that case, you are much better off providing overloads to handle the specific types individually.
This has many advantages:

*

*There is no chance of misuse - you're user cannot pass an invalid argument

*There is more clarity in your API - it is very obvious which types are appropriate

*Generic methods are more complicated to use, and not as obvious for beginning users

*The use of a generic suggests that any type is valid - they really should work on every type

*The generic method will likely be slower, performance wise

If your argument CAN work with any type, this becomes less clear.  In that case, I'd often still consider including the overloads, plus a generic fallback method for types.  This provides a performance boost when you're passing an "expected" type to the method, but you can still work with other, non-expected types.

A: While there's no one-size-fits-all rule on this, generics should be used when the specific type is irrelevant. That isn't to say that you can't constrain the type, but that specific type doesn't actually matter. In this case, the parsing method is entirely dependent on (and different for) each type. Generics don't seem like a good solution here.

A: My rule of thumb for this scenario. There is overlap and there are subtleties, but this gets you on the path:

*

*Overloading methods/functions is concerned with handling types, and doesn't make assumptions about interfaces available on the types.

An overloaded function will deal specifically with a type passed to it, and whatever interface it implements. Example printObject(t) may need to extract a property from 't' and print it manually (e.g. print(t.name) or cout << t.name;)

*Generics is concerned with handling the interface(s) implemented, but is not concerned about the type of object.

A generic function will handle any type passed to it, but expect a specific interface implemented (e.g. printObject(t) may just call t.toString() on the object, presuming it's implemented)


text:
Q: Component won't update in Vue I'm using pinia to store data in my Vue app. There is a component called ListTag:
<template>

    <q-chip
      :removable="tagsWantToggle"
      size="8px"
      outline
      :color="tag.color"
      :class="`co-${tag.color}1 text-${tag.color}  `"
      class="q-ma-none q-mr-sm"
      @remove="removeTag(index)"
    >
      {{ wantCircle(index, tag.label) }}
      <q-tooltip :class="`bg-${tag.color}`" :delay="1000" :offset="[0, 10]"
        >{{ tag.label }}
      </q-tooltip>
    </q-chip>

    <q-btn-dropdown
      v-if="tagsWantToggle && index == tagItems.length - 1 && wantDropdown"
      flat
      color="grey"
      class="q-mx-none q-px-none"
      label=""
      dropdown-icon="expand_more"
      size="8px"
    >
      <q-list
        v-for="(tagDefault, index) in dropdownTagItems"
        :key="index"
        :class="`text-${tagDefault.color}`"
      >
        <q-item clickable v-close-popup @click="addTag(tagDefault)">
          <q-item-section>
            <q-item-label>{{ tagDefault.label }} </q-item-label>
          </q-item-section>
        </q-item>
      </q-list>
    </q-btn-dropdown>

</template>

The parent component called Content contains this code:
<ListTags class="row" :tagsWantToggle="true" :tagItems="store.selectedEmail.tagItems" />

When the page is loaded, the selectedEmail is just an empty object. Later, as I open one email the selected email will be filled with some data, but the ListTags will not be visible. It is strange, because in the Content file I'm using this code:
{{ store.selectedEmail.message }}
 and it works perfectly. It updates if another email is selected.
How could I update the tags inside ListTag?

A: This code inside setup function:
  const storeTagItems = store.tags;
  var dropdownTagItems = null;
  if (store.selectedEmail.tagItems) {
    dropdownTagItems = storeTagItems.filter(
      ({ label: id1 }) =>
        !store.selectedEmail.tagItems.some(({ label: id2 }) => id2 === id1)
    );
  }

... only runs once: when the setup() function is run. It doesn't run every time store.selectedEmail.tagItems or store.tags change. In other words, it's not "reactive".
To make it reactive, write a computed:
const dropdownTagItems = computed(() =>
  store.tags.filter(
    ({ label }) =>
      !store.selectedEmail.tagItems.some(({ label: l }) => label === l)
  )
);

*

*if store.tags is nullable, replace store.tags.filter with (store.tags || []).filter.

*if store.selectedEmail or its tagItems are nullable, replace store.selectedEmail.tagItems.some with
(store.selectedEmail?.tagItems || []).some
dropdownTagItems will now react to any change in store.tags or store.selectedEmail.tagItems. It's reactive.
Notes:

*

*if you use dropdownTagItems in more than one place, consider writing a store getter and move the above computed in that getter, so you don't need to repeat yourself in multiple components.

*if you use storeTagItems anywhere else in the component, you should make it reactive with any of these methods:
a) use store.tags directly;
b) make it a computed: const storeTagItems = computed(() => store.tags)
c) use the storeToRefs helper importable from pinia:
const { tags: storeTagItems } = storeToRefs(store)

A: These are notes from Pinia team:

*
* Store is an object wrapped with reactive, meaning there is no need to write .value after getters but, like props in setup, we cannot destructure it
* In order to extract properties from the store while keeping its reactivity, you need to use storeToRefs()  .
So, in your case, components are not updated because storeTagItems is not reactive. To make it reactive, simply destructure store with storeToRefs().
const {tags: storeTagItems} = storeToRefs(store))


text:
Q: Stop route loading on first request to Angular app In my app, someone can select a language from a select list, and it updates some translations on the page.  It also updated the $location.path() to be /:language.  However, I don't have any special views.  It's a very simple application.  I have the URL updating and all that working fine.  However, if I come to the application not on the root path, such as /spanish, I get the error Cannot GET /spanish.  I want to be able to use whatever language the user decides come to the app with.  How can I use the param on load?  I am communication between controllers using $rootScope.$broadcast.  So I can't use $routeProvider to setup routes since the controllers and views controlling the page do not change at all.
app.js
angular
  .module('howToCussInApp', ['ngRoute'])
  .config(function($locationProvider, $routeProvider) {
    $locationProvider.html5Mode(true);
  });

selector.js
angular.module('howToCussInApp')
  .controller('SelectorController', function ($rootScope, $scope, Translation, $location) {
    $scope.languages = [];

    Translation
      .get()
      .then(function(response) {
        $scope.languages = Object.keys(response.data);
        $scope.currentLanguage = $location.path().slice(1) || $scope.languages[0];
        $scope.update();
      });

    $scope.update = function() {
      $location.replace().path('/' + $scope.currentLanguage);
      $rootScope.$broadcast('languageUpdated', $scope.currentLanguage);
    };
  });

translation.js
angular.module('howToCussInApp')
  .controller('TranslationController', function($scope, Translation) {
    $scope.languageData = {};
    $scope.currentLanguage = '';

    Translation
      .get()
      .then(function(response) {
        $scope.languageData = response.data;
      });

    $scope.$on('languageUpdated', function(event, data) {
      $scope.currentLanguage = data;
    });
  });

A: Turns out, this was unrelated to Angular.  The Grunt server that is created with the Angular Yeoman generator for some reason was throwing the 404, not Angular.


text:
Q: CSS styles doesn't apply when using ngClass I have a problem with dynamically CSS updating. This is my HTML code:
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>Test project</title>
    <link rel="stylesheet" href="Content/bootstrap.css">
    <link rel="stylesheet" href="Content/style.css">

To-do list

{{item.Description}}

                    Is completed: <input type="checkbox" ng-checked="{{item.IsCompleted}}" ng-click="complete($index)" />

And now I want to apply the following css styles if item is completed:
.completed {
    background-color: red;
}

But nothing happened.

A: Try to use the correct ng-class syntax and ensure that .completed CSS class is available due to your CSS declarations. Here is a simple working fiddle which will help you. Compare it with your solution. Please take a look at the ng-class documentation of AngularJS.

{{item.Description}}

            Is completed:
            <input type="checkbox"
                   ng-checked="{{item.IsCompleted}}"
                   ng-click="complete($index)" />

A: You need to change the ng-class syntax. make it simple:


text:
Q: How to determine if files I modified have new commits on github? First, sorry for such a confusing pesky title, I really can't find a better way to describe this (would appreciate any changes suggested to post).
The problem
I synced a github repo. And also modified some files and codes inside according to my needs. But if I want to resync and update my tree to latest commits.

will my changes be overwritten?
Or will repo simply ignore modified files and move on to other files?
Or will there be patching process (I dont think this would be case since chances of problems with auto-patching are quite high)?

My guess is that it skips over modified files. And I may need to manually get the new commits from repo. But how to determine which files that have been modified have new commits? I just want to determine it, then probably manually fetch and modify them manually.
To clarify:
Consider files named "abc" and "def" which I modified.
The repo owner updated his repo with a lot of new commits.
I ran repo sync and it synced all files to newer commits except those I modified. Now how do I determine if the files that repo owner updated include "abc" and/or "def" too (assuming I myself modified a lot of files, so I can't manually check if each file has new commit or not)?
I don't want to see what files I have modified or a complete list of files with new commits, I just want to see if the files that I modified have new commits or not.

Is there any such possible way?

I do know how to determine files that are changed using `git status,

but how do I want to check if those changed files have any new commits.

A: When running repo sync, Repo will rebase any non-published topic branches (i.e. branches you haven't uploaded to Gerrit with repo upload).

Or will there be patching process (I dont think this would be case since chances of problems with auto-patching are quite high)?

Git will try, but if there's a conflict that it can't resolve by itself you have to step in and help out.

Consider files named "abc" and "def" which I modified. The repo owner updated his repo with a lot of new commits. I ran repo sync and it synced all files to newer commits except those I modified.

No. Either Repo rebases your branch (and updates/merges all files) or it doesn't do anything and it's up to you need to rebase or merge from the upstream. Git never does partial updates.

I dont want to see what files I have modified or a complete list of files with new commits, I just want to see if the files that I modified have new commits or not.

I think you're asking the wrong question, but sure, you can list the commits that modify a particular set of files or compare two commits and only display the differences in a particular set of files. Both git diff and git log accept one or more paths to files that you want to restrict the output to. To find the files you can use git ls-files -mo to obtain dirty files and untracked files in your workspace, git diff-tree --name-only -r HEAD~..HEAD to get the files modified by the most recent commit, and so on.
Putting it all together, the following command fetches the most recent state from the upstream and shows the new commits (git log HEAD..origin/master) that touch upon files that you yourself have modified on the current branch since the last update from the upstream (git diff-tree --name-only -r origin/master..HEAD):
git fetch
git log HEAD..origin/master -- $(git diff-tree --name-only -r origin/master..HEAD)

A Unix-like shell is assumed. On Windows things may look differently.

A: You can use git hook to track the list of files.
In your post-receive hook search for the given file and do what ever you need to do.
Another option is to track it manually using the follow flag
git log --follow <path>, it will print out the list of changes made to the given file in each commit


text:
Q: Need help in parsing arguments in awk My input file looks like this:

chr1  150979866   150980273   NM_001303242    chr1    150979273   150980273   NM_001163260    1000

and I want to separate the file based on minimum and maximum values in the
9th column. Where min= 0-500 and max=>500-1000.
I wrote an awk script awk -v min=0 -v max=500 ' $9==0 { next } min <= $9 && $9 <= max { print }' .
But the script does not work.
Can someone help.
Thanks.

A: Below line generate two o/p files : min(0-500) and max(501-1000)
awk '$9 >= 0 && $9 <= 500 {print $0>"min"} $9 > 500 && $9 <= 1000 {print $0>"max"}' file

A: awk -v min=500 -v max=1000 '   $9 == 1000 { next }   min <= $9 && $9 <= max { print }' file

awk -v min=0 -v max=500 '   $9 == 500 { next }   min <= $9 && $9 <= max { print }' file
It worked.
Thanks everyone for their inputs.


text:
Q: insert an object to an NSMutablearray of NSDictionary I am trying to insert an object to an array of NSDictionary but cant find out how. all the examples show how to insert to an array with NSDictionary with insertObject:atIndex, but this one doesnt insert the object under a dictionary key.
My array right now is the following:
NSArray *aaa = [NSArray arrayWithObjects:@"Disable" ,nil];
NSDictionary *aaaDict = [NSDictionary dictionaryWithObject:aaa forKey:@"Computers"];
NSArray *bbb = [NSArray arrayWithObjects:@"Enable", nil];
NSDictionary *bbbDict = [NSDictionary dictionaryWithObject:bbb forKey:@"Computers"];
NSArray *ccc = [NSArray arrayWithObjects:@"Enable", nil];
NSDictionary *cccDict = [NSDictionary dictionaryWithObject:ccc forKey:@"Computers"];

[listOfItems addObject:aaaDict];
[listOfItems addObject:bbbDict];
[listOfItems addObject:cccDict];

I would like to do this, but with a key "Computers":
   NSArray *ar = [NSArray arrayWithObjects:@"xxxx", @"yyyy", @"zzzz", nil];
    NSDictionary *arDict = [NSDictionary dictionaryWithObject:ar forKey:@"Computers"];
    [listOfItems insertObject:ar atIndex:1];

Again - it does add the new array but not under the key "Computers". What am I missing here?
Thanks!

A: You probably wanted to write
[listOfItems insertObject:arDict atIndex:1];
instead of
[listOfItems insertObject:ar atIndex:1];
You're adding the array and not the dictionary like in the first part of your question.

A: I'm not sure I understand exactly what you're trying to do, but did you mean to insert the ar object or the arDict object?  I think your code should look like
NSArray *ar = [NSArray arrayWithObjects:@"xxxx", @"yyyy", @"zzzz", nil];
NSDictionary *arDict = [NSDictionary dictionaryWithObject:ar forKey:@"Computers"];
[listOfItems insertObject:arDict atIndex:1];

A: Do you mean you want to add another array to a dictionary inside your listOfItems array? If that is the case it requires a nested method call as such:
[[listOfItems objectAtIndex:0] setObject:ar forKey:@"Computers"];

A: When it adds the new object you have to get the NSDictionary first. So basically you are using the dictionary wrong. What you have done is equivalent to
[listOfItems addObject:aaa]; and similarly bbb and ccc and ar
What you actually want to do is add the objects to a Dictionary and not a array.
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary addObject:[NSArray arrayWithObjects:@"Disable" ,nil] forKey:@"Key1"]; // your keys need to be unique
[dictionary addObject:[NSArray arrayWithObjects:@"Enable", nil] forKey:@"Key2"];
[dictionary addObject:[NSArray arrayWithObjects:@"Enable", nil] forKey:@"Key3"];

[dictionary addObject:[NSArray arrayWithObjects:@"xxxx", @"yyyy", @"zzzz", nil] forKey:@"Key4"];

A: With leak fixed issue
NSArray *ar = [NSArray arrayWithObjects:@"xxxx", @"yyyy", @"zzzz", nil];
NSDictionary *arDict = [NSDictionary dictionaryWithObject:ar forKey:@"Computers"];
[listOfItems insertObject:arDict atIndex:1];
[ar release]; // fixed the leak
[arDict release];  // fixed the leak