text:
Q: Can't get push notifications in Android to work using ngCordova I'm having a tough time getting push notifications (using the ngCordova plugin) to work. I have followed their sample code exactly as is documented on the site: http://ngcordova.com/docs/plugins/pushNotifications/
(the only difference is that I don't have a deviceready listener, instead, my code is inside the ionicPlatform.ready listener.)
Here is my code:
angular.module('myApp', ['ionic', 'ngCordova'])
.run(function($ionicPlatform, $rootScope, $state, $cordovaPush) {
  $ionicPlatform.ready(function() {
    var config = {
      "senderID": "myID100001000"
    };

    $cordovaPush.register(config).then(function(result) {
      alert(result);
    }, function(err) {
      alert(err);
    })
  });

  $rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) {
    switch(notification.event) {
      case 'registered':
        if (notification.regid.length > 0 ) {
          alert('registration ID = ' + notification.regid);
        }
        break;

      default:
        alert('An unknown GCM event has occurred');
        break;
    }
  });
})

When my app starts I do get the "OK" alert, so I know it successfully goes through the $cordovaPush.register call. However, I was expecting to get a "registered" notification event, right after, but I never get notified.
Any help would be appreciated.

A: The solution is in the comments but this needs a proper answer.
First of all, the register callback always returns OK as long as you pass a senderID, but if the $cordovaPush:notificationReceived event is never called (it may take a few seconds), this ID is probably wrong.
You must use the Project Number, not the Project ID.
To get the number, go to the API Console, select the project and you'll be on the Overview page. On top of this page, you'll see something like this:
Project ID: your-project-id        Project Number: 0123456789

Just copy and use the project number and everything should work.

A: I have suffered with this a lot and I have found out, that there are in fact two versions of the cordova push plugin currently:

*

*https://github.com/phonegap-build/PushPlugin (deprecated)

*https://github.com/phonegap/phonegap-plugin-push (new one)

Both are supported by ngCordova, but only the deprecated version is documented.
The deprecated version is $cordovaPush
and the newer one is $cordovaPushV5, and they have completely different methods.
For me the problem was that I downloaded the cordova-plugin-push and tried to implement it with the old documentation on ngCordova site.
The code is:

 /*
         * Non deprecated version of Push notification events
         */
        function registerV5() {

            $ionicLoading.show({
                template: '<ion-spinner></ion-spinner>'
            });

            if (ionic.Platform.is('browser')) {
                alert("You are running on broswer, please switch to your device. Otherwise you won't get notifications");
                $ionicLoading.hide();
                return;
            }

            /**
             * Configuration doc:
             * https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationinitoptions
             */
            var GCM_PROJECT_ID = 'xxxxxx';

            $cordovaPushV5.initialize({
                "android": {
                    "clearNotifications": false,
                    "senderID" : GCM_PROJECT_ID
                }
            });

            $cordovaPushV5.register().then(function (deviceToken) {
                console.log("Successfully registered", deviceToken);

                $scope.data.deviceToken = deviceToken;

                // Below code required to configure $cordovaPushV5 notifications emitter.
                // Don't pass function it's not handler.
                $cordovaPushV5.onNotification();
                $cordovaPushV5.onError();

                $ionicLoading.hide();
            }, function (error) {
                console.log("Failed to registered");
                console.log("error object : ", error);
                $ionicLoading.hide();
            });
        }

        $rootScope.$on('$cordovaPushV5:notificationReceived', function(event, data) {
            console.log("notification received");
            console.log("data object: ", data);

            var foreground = data.additionalData.foreground || false;
            var threadID = data.additionalData.payload.threadID || '';
            var group = data.additionalData.payload.group || false;

            if (foreground) {
                // Do something if the app is in foreground while receiving to push - handle in app push handling
                console.log('Receive notification in foreground');
            } else {
                // Handle push messages while app is in background or not started
                console.log('Receive notification in background');
                // Open FB messanger app when user clicks notification UI when app is in background.
                if (typeof data.additionalData.coldstart != "undefined" && data.additionalData.coldstart == false)
                    if (!group)
                        // Open FB Messenger of specific user chat window
                        window.open('fb-messenger://user/' + threadID, '_system', 'location=no');
                    else
                        // Open FB Messenger of specific group chat window
                        window.open('fb-messenger://groupthreadfbid/' + threadID, '_system', 'location=no');
            }
        });

        $rootScope.$on('$cordovaPushV5:errorOccurred', function(event, error) {
            console.log("notification error occured");
            console.log("event object: ", event);
            console.log("error object: ", error);
        });

More on this github article: https://github.com/driftyco/ng-cordova/issues/1125 (code from here) and in this article: https://github.com/yafraorg/yafra/wiki/Blog-Ionic-PushV5


text:
Q: Usage of "forte" for "skill to be built" Can we use "forte" in following sentence:

*

*I am looking forward to building my forte in Biotechnology.

*I am looking forward to building my forte as Biotechnologist.

A: The definition of forte is "one's strong point", or a particular talent or thing you do very well. Your forte is biotechnology, because you have worked to build your expertise in that field. You don't build or increase your forte. It's like a favorite color; you just have one (or don't have one).
An example of using "forte":

The author's forte is making her characters seem so real that you forget they're fictional.

"Build my forte" isn't ungrammatical exactly, but it just isn't used that way. If we look at an NGram (and follow the links for each phrase to check the actual usage), the most common construction is some form of "to be" - "is my forte", "wasn't my forte", "used to be my forte", etc.

redpajama_set_name: RedPajamaStackExchange


text:
Q: binding dropdownlist in mvc3 Razor(default Dropdownlist value is not selected) I am binding dropdownlist in mvc3 Razor.
My problem is its not showing default Dropdownlist value selected.An Empty space is shown.
Code is given below:
  @Html.DropDownListFor(model => model.MainHeadingFont, new SelectList(Model.lst_FontType, "Value", "Text"), new { @class = "inputPage7Select" })

CollectionList is passed from Model:
public List<SelectListItem> lst_FontType
    {
        get
        {
            FontType.RemoveRange(0, FontType.Count);
            FontType.Add(new SelectListItem() { Text = "\"Gill Sans MT\", Arial, sans-serif", Value = "\"Gill Sans MT\", Arial, sans-serif", Selected = true });
            FontType.Add(new SelectListItem() { Text = "\"Palatino Linotype\", Times, serif", Value = "\"Palatino Linotype\", Times, serif" });
            FontType.Add(new SelectListItem() { Text = "\"Times New Roman\", Times, serif", Value = "\"Times New Roman\", Times, serif" });
            return FontType;
        }
    }

A: In the controller action rendering this view:
public ActionResult Index()
{
    var model = ...
    model.MainHeadingFont = "\"Palatino Linotype\", Times, serif";
    return View(model);
}

This will automatically preselect the second element of the ddl.


text:
Q: Image not appearing in HTML page Is there a problem with my HTML code that would cause my image to not appear?

   1517 N Lotus

         hello3
         hello4
         hello5

A: your code doesn't show any problem.
 If you are sure that the image is on the same folder where code exist
than try to change the extension .jpeg to .jpg
 that will resolve your problem.


text:
Q: Trying to set binary search tree node to an integer My code has two errors and I cant figure out why. Im trying to insert a node into the tree but it won't let me set the left and right nodes to the integer value. please help, this portion of my program is due on Saturday and today is Wednesday.
void Bst::Insert(TreeNode *&node, int item) {

if (item < node->data) {
    if (node->left == NULL)
        node->left = item;
    else
        Insert(node->left, item);
}

if (new_node->data > root->data) {
    if (node->right == NULL)
        node->right = item;
    else
        Insert(node->right, item);
}

}

A: There are a lot of problems with your code, I have written below c++ code of what it should look like, there might be some minor errors which you might want to investigate.
TreeNode * Bst::Insert(TreeNode *node, int item) {
    if (node == NULL) {
        node = (struct TreeNode*)malloc(sizeof(struct TreeNode));
        node->data = item;
        node->left = NULL;
        node->right = NULL;
    }
    else if (item < node->data) {
        node->left = Insert(node->left, item);
    }
    else if (item > node->data) {
        node->right = Insert(node->right, item);
    }
    return node;
}

I have edited the changes that i think might work, you may also want to include malloc.h in the headers.


text:
Q: Android ViewGroup Incorrectly Shifts Up After Navigating Back I am trying to figure out why my view appears to shift up after returning to an activity's screen.
Here is the image before navigating away to another fragment.

Here is the image after navigating back to original screen:

The xml file of the activity is:
<layout
    <androidx.constraintlayout.widget.ConstraintLayout
      <androidx.appcompat.widget.Toolbar
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       app:layout_constraintTop_toTopOf="parent"
      />
      <androidx.constraintlayout.widget.ConstraintLayout
         .
         .
         .
      </androidx.constraintlayout.widget.ConstraintLayout>
      .
      .
      .
    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

Note that I cannot use fitsSystemWindows=true because I don't want to create a border at the top of the toolbar, the UI should have a continuous white background from behind the status bar.
Also, there is no keyboard present on the screen to cause this shift.

A: Add this to you root layout
android:fitsSystemWindows="true"

And set this to your AppTheme
<item name="android:windowTranslucentStatus">false</item>

A: What worked for me was adding android:fitsSystemWindows="true" within the Toolbar tag itself i.e
 <androidx.constraintlayout.widget.ConstraintLayout
      <androidx.appcompat.widget.Toolbar
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       app:layout_constraintTop_toTopOf="parent"
       android:fitsSystemWindows="true"
      />

Adding this tag to the root layout created a boundary in the toolbar which I was trying to avoid. Setting android:windowTranslucentStatus was not necessary in my case and did not affect the layout.


text:
Q: Localization for Date Range Picker I'm very new to javascript and jquery. I've been searching up and down for a solution to this, but I'm getting nowhere. I'm using the daterangepicker from http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/.
This was a suggested solution in the comments:
$("input").daterangepicker({
 dateFormat:"MM dd yyyy",
 datepickerOptions: $j.extend({},
  $j.datepicker.regional['de'], { //germany
  showStatus: true, //this is just a datepicker option
  showOn: "both",//this is just a datepicker option
  changeYear :true//this is just a datepicker option
})
});

I tried the above approach, but go nowhere. I'm quite noob to javascript, so bear with me.
parent.$('#start_date_<?php echo $widget_id;?>').daterangepicker({
        monthOnly: true,
        arrows:false,
        dateFormat: 'MM yy',
        latestDate: '<?php echo date('Y-m-d');?>',
        presetRanges: [
            {text:'<?php echo lang('dashboards_month_to_date');?>', dateStart: 'm2d', dateEnd: 'today' },
            {text: '<?php echo lang('dashboards_quarter_to_date');?>', dateStart: 'q2d', dateEnd: 'today' },
            {text: '<?php echo lang('dashboards_year_to_date');?>', dateStart: 'y2d', dateEnd: 'today' }
        ],
        presets: {
            allDatesAfter: '<?php echo lang('dashboards_all_dates_from_first');?>'
        },
        altFields:'widgetDate_<?php echo $widget_id;?>',
        datepickerOptions: {
            changeMonth: true,
            changeYear: true,
            maxDate: Date.today()
        },
    });
    parent.$('#widgetDate_<?php echo $widget_id;?>S').val('<?php echo $options->widgetStartDate;?>');
},10);
{/eval}

Say I need to do a localization for french, can someone give me step-by-step guide to do this for the above code. Any help will be greatly appreciated.

A: You can use the daterangepicker options.
this is the italian localization:
$('#inputPeriodo').daterangepicker({
    presetRanges: [
                    { text: 'oggi', dateStart: 'today', dateEnd: 'today' },
                    { text: 'ieri', dateStart: 'today-1days', dateEnd: 'today-1days' },
                    { text: 'ultimi 7 giorni', dateStart: 'today-7days', dateEnd: 'today' } ],
    presets: {
        specificDate: 'giorno specifico',
        allDatesBefore: 'prima del',
        allDatesAfter: 'dopo il',
        dateRange: 'intervallo'
    },
    rangeStartTitle: 'data inizio',
    rangeEndTitle: 'data fine',
    nextLinkText: 'mese successivo',
    prevLinkText: 'mese precedente',
    doneButtonText: 'fatto',
    dateFormat: 'dd/mm/yy',
    datepickerOptions: {
        prevText: '<Prec',
        nextText: 'Succ>',
        monthNames: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno',
            'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
        monthNamesShort: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu',
            'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
        dayNames: ['Domenica', 'Luned&#236', 'Marted&#236', 'Mercoled&#236', 'Gioved&#236', 'Venerd&#236', 'Sabato'],
        dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'],
        dayNamesMin: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa']
    }
});


text:
Q: How to run a TCL script to tell run in every 10 minutes? My TCL script:
source reboot_patch.tcl

set a 1
while {$a < 10} {
    exec reboot_patch.tcl
    after 60000
    incr a
}

I need to run "reboot_patch.tcl" script for every 1 min in my system. I wrote above script. But its running only once and its coming out.
Following is the "reboot_patch.tcl" script:
#!/usr/bin/tcl

package require Expect

spawn telnet 40.1.1.2
expect "*console."
send "\r"
expect "*ogin:"
send "test\r"
expect "*word:"
send "test\r"
expect "*>"
send "clear log\r"
expect "*#"
send "commit \r"
expect "*#"

Please suggest me a way to achieve this.
Thanks in advance.
Script to print numbers from 1 to 10 in windows 7:
#!c:\Tcl\bin\tclsh

set a 1
while { $a < 11} {
puts $a
incr a

}

I am unable to run the above script using "./" format in windows7.

A: In general, exec command will return the output of program execution. It is our responsibility to capture and print and manipulate it.
You have to print it manually like
puts [ exec ./reboot_patch.tcl ]

Or like,
set result [ exec ./reboot_patch.tcl ]
puts $result

Since you are using exec without printing it's result, you have not seen anything. Then how come it got executed for the first time ? Who else can do except the following ?
source reboot_patch.tcl

Well, Since you have sourced the file and it got executed which seemed to be the first time execution but which is not actually from exec command.
Note : If you are calling any of that sourced file's proc, then only it is required to source it. As far as I can see you are not having any proc there. So, source is not required at all.


text:
Q: How find all strings i can create with 3 char I have 3 char "abc".
All combinations with these 3 characters are 3^3 = 27:
aaa, aab, aac, aba, ... etc.
I write a pseudo-code to print all of these combinations:
string dictionary[3] = {"a", "b", "c"};
string str[3];

for (i=0;i<3;++i) {
    str[0]=dictionary[i];
    for (j=0;j<3;++j) {
        str[1]=dictionary[j];
        for(k=0;k<3;++k) {
            str[2]=dictionary[k];
            println(str);
        }
     }
 }

Now, I can see that all loops start at 0 and end at 2.
So I thought there was a way to make this function as a recursive function, although in fact no basic step can be distinguished.
So, i asked myself:

*

*Is it really possible to create a recursive function for this type of problem?

*If it existed, would it be more or less efficient than the iterative method?

*If the number of usable chars would increase, performance would be worse or better?


text:
Q: W subspace of $\mathbb{R^4}$ with $\mbox{dim}W = 3$ and $U =\cdots $. Find $\mbox{dim} U+W$ and $\mbox{dim} U\cap W$
Let $W$ be a subspace of $\mathbb{R^4}$ with $\mbox{dim}W = 3$ and $U
 = \mbox{span}((1,2,1,3),(3,1,-1,4))$. Find $\mbox{dim} U+W$ and $\mbox{dim} U\cap W$

Well, so $\mbox{dim } U = 2$, clearly, and $\mbox{dim }W = 3$. But the exercise solution says that $\mbox{dim} U + W = 4$ (why)?
Also, by the formula:
$$\mbox{dim } (U+W) + \mbox{dim } (U\cap W) = \mbox{dim } U + \mbox{dim }W$$
then shouldn't $\mbox{dim }U\cap V$ be $1$? My book says it's $0$.
Update:
Well, in fact, the exercise says that $W$ is the subspace of the previous exercise:

Let $W$ and $U$ be subspaces of $\mathbb{R^4}$ of dimension $3$. Which
   dimensions can $W + U$ have if $\mbox{span}(W\cap U) =
 \mbox{span}((1,2,1,0),(-1,1,0,1), (1,5,2,1))$

I don't know if information from this previous exercise makes a difference.


text:
Q: Data scraping and I get this problem: We're sorry but viewer-app doesn't work properly without JavaScript enabled. Please enable it to continue I am attempting to scrape https://coworking.routesgrow.com/ .
When attempting to scrape with beautiful soup and normal requests library it wouldn't work. I switched to using selenium and beautiful soup and still the same thing happens and now I recieve this message.
"We're sorry but viewer-app doesn't work properly without JavaScript enabled. Please enable it to continue."
This is my code:
#import requests
import xlsxwriter
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from bs4 import BeautifulSoup

options = Options()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument("--enable-javascript")

page = 1

url = f"https://coworking.routesgrow.com/?page={page}"
driver = webdriver.Chrome(options=options)
driver.get(url)
html = driver.page_source
# req = requests.get(url, headers={
# "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"})
soup = BeautifulSoup(html, "html.parser")
print(soup)

I have attempted several fixes but not on them seem to work. Am I missing or doing something wrong?


text:
Q: Animation starting from the front of the screen I am a newbie in android. I need to complete a task which deals with the animation of the dynamic dashboards moving into the layout from the front of the screen as in for example in the link http://android-developers.blogspot.in/2011/02/animation-in-honeycomb.html as the icons get into the screen from the front of the view in 0.05 seconds. I used different types of animations. I feel that transition animation has to yield the solution. But am not able to come up with any solution.
Please help me and show me a way to move in the imageViews into the layout.
Thanks in advance.

A: Take a look on "Zoom in" or "Modern zoom in" animation. You can find an example in ApiDemos project: App/Activity/Animation.


text:
Q: Use Session ID from supplied parameter instead of default behavior in ASP.NET MVC3 I am writing a simple proof-of-concept web service using ASP.NET MVC3 controller with JSON input/output. I want to allow a login based on a DB table and to return an API key and a session ID. With subsequent requests to other APIs I require passing both API key and a session ID.
How can I set up my MVC3 project so that neither cookie nor cookieless session is being used. I want the session ID from JSON request to be used instead and still have the convenience of a Controller.Session. Is this possible? I don't want to reinvent the wheel with my own session handling.

A: YOu can use the ISessionIDManager interface to create custom logic for storing and retrieving the sessionID.
You set in your web.config that the app uses your custom session id manager instead of the default one and then all you have to do is figure out how you want it to save to the request and retrieve from the request.


text:
Q: Lenovo laptop not connecting to Wifi properly
*

*wifi disconnecting at least every once/20min.

*screen brightness changing on it's own, usually when I change the plug-state (plug or unplug).

I am running this command:
sudo echo 150 > /sys/class/backlight/amdgpu_bl0/brightness

to set a nice brightness val.
I've found this arch wiki on backlight useful, but many things go over the top of my head.
EDIT
Network card info

Network controller: Realtek Semiconductor Co., Ltd. RTL8821AE
802.11ac PCIe Wireless Network Adapter

Model
System Information
    Manufacturer: LENOVO
    Product Name: 80XS
    Version: Lenovo ideapad 320-15ABR
    Serial Number: PF15ZL19
    UUID: eeff1dce-a4e7-11e8-b5f5-8c1645f592e5
    Wake-up Type: Power Switch
    SKU Number: LENOVO_MT_80XS_BU_idea_FM_ideapad 320-15ABR
    Family: ideapad 320-15ABR

Help please?


text:
Q: how can i resolve java.net.BindException adress already in use : bind ...and The Tomcat connector configured to listen on port 8080 failed to start
im also using TCPview, so witch process should i stop in the picture

whats more, im working under spring-boot so i cant configure the port

A:
so which process should i stop

The process with ID 6076

im working under spring-boot so i cant configure the port

Using Spring Boot doesn't stop you from configuring the port. If you are using an embedded container you can set the server.port property. If you are deploying a war to a standalone container then you can use the container's standard mechanism for configuring the port on which it listens.


text:
Q: System.Windows.Forms DataGridView show trailing text instead of leading text PowerShell I'm trying to get a DataGridView cell to show the last # of characters of its value instead of showing the first # of characters.
So the goal is to make the cells display as
[...Store\LANE3\UAT]
Instead of :
[DataStore\LANE3...]
I'm using powershell to create the Form objects. I think I need to somehow hook the DrawText or TextRender functions.. but I'm not sure how and my Google Fu has failed me.
(I could just make the cell width wider but I'd like to keep everything uniform width if possible)

A: Why not just use the string, then substring to get the number of characters you want then replace. Say, something like this...
($FormElementString = '[DataStore\LANE3\LANE3\UAT]')
($ReplaceString     = $FormElementString.Substring(1,4))
($FormElementString -replace "\$ReplaceString", "...")
# Results
<#
[DataStore\LANE3\LANE3\UAT]
Data
[...Store\LANE3\LANE3\UAT]
#>

Update as per your comment.

I was hoping to keep the same value in the datagridview cell but just
display it differently in the system.windows.forms datagridview
object.

If you really are wanting to change the cell-specific view vs the default rendering/truncation, there is a lot more work involved.
See this SO Q&A, note it's all a C#.
C# DataGridView: Long Text Truncated with "..." on the Left Side When the Column is Right-Aligned

A: You could use regex for this:
$str = '[DataStore\LANE3\LANE3\UAT]' -replace '^(.).*(.{22})$', '$1...$2'
$str

Result:
[...Store\LANE3\LANE3\UAT]

Regex details:
^             Assert position at the beginning of the string
(             Match the regex below and capture its match into backreference number 1
   .          Match any single character
)
.             Match any single character
   *          Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
(             Match the regex below and capture its match into backreference number 2
   .          Match any single character
      {22}    Exactly 22 times
)
$             Assert position at the end of the string, or before the line break at the end of the string, if any (line feed)


text:
Q: Error: ENOENT: no such file or directory, scandir '.../node_modules/node-sass/vendor' I am having an issue running my node application on a different computer than the one I usually use. After a lot of troubleshooting:
The error message I'm getting is:
Error: ENOENT: no such file or directory, scandir '.../node_modules/node-sass/vendor'

A posting that I was reading suggested that I run sudo npm install -g node-sass, which gives me the following error:
Error: EACCES: permission denied, mkdir '...nvm/versions/node/v8.9.0/lib/node_modules/node-sass/build'

I then tried to run sudo npm rebuild node-sass but I'm getting the same error message:
Error: EACCES: permission denied, mkdir '.../node_modules/node-sass/build'

I then ran sudo npm install -g node-sass --unsafe-perm=true --allow-root but it also didn't work:
ENOENT: no such file or directory, scandir '.../node_modules/node-sass/vendor'

What am I doing wrong here? Why isn't node-sass working? Why isn't sudo working properly?

A: Windows. Try below
node node_modules/node-sass/scripts/install.js
npm rebuild node-sass

A: *

*Most probably it's not node-sass issue. This sometimes happens when you use different OS to install node-sass. As it uses some native components, the npm install must only be done one OS. Do not copy node_modules from some other place. Do a fresh install.

*Have you tried deleting the node_modules directory and running npm install again?

*Are you working on Windows machione where the npm install was done using a Ubuntu shell (inside windows) and now you are trying to install again from the windows command line? If so, dont. Use only one shell.

*Finally if none of these help, then its possible a user permission issue. Check if you can get super user access sudo su - and then try doing a fresh npm install.

A: Your user does not has the rights to write in the folder you are trying. You are using 3 ... so it goes to the folder /Users on the second one you have ...nvm/versions/node/v8.9.0/lib/node_modules

A: This is because of a missing node-sass dependency or broken node-sass package issue.
You can resolve this by the following steps:

*

*Install node-sass globally, if it is not installed in your system.
npm install -g node-sass

*Open command prompt/terminal on the project root directory and execute the following commands.
nodejs node_modules/node-sass/scripts/install.js
npm rebuild node-sass


text:
Q: DateDiff en c# (para semanas y meses) Tengo este código en visual basic. Y no se como obtener los mismos resultados en C# ya que no existe el diff alli. Solamente puedo hacer con el cálculo de horas. ¿Como puedo obtener los resultados en semanas y meses?
    Dim fechaActual As Date = Date.Today
    Dim fechaFin As Date = New DateTime(2020, 12, 31)
    Dim meses, semanas, horas As Integer
    meses = DateDiff("m", fechaActual, fechaFin)
    semanas = DateDiff("ww", fechaActual, fechaFin)
    horas = DateDiff("h", fechaActual, fechaFin)
    Console.WriteLine("Fecha actual: " & fechaActual)
    Console.WriteLine("Fecha fin: " & fechaFin)
    Console.WriteLine("Faltan: " & meses & "meses")
    Console.WriteLine("Faltan: " & semanas & "" & "semanas")
    Console.WriteLine("Faltan: " & horas & "horas"

A: Lo que podes hacer es agregar la referencia Microsoft.VisualBasic para poder usar la funcion > Microsoft.VisualBasic.DateAndTime.DateDiff
Ejemplo:
        DateTime d1 = new DateTime(2017,5,20);
        DateTime d2 = DateTime.Today;
        long difMonth = Microsoft.VisualBasic.DateAndTime.DateDiff(Microsoft.VisualBasic.DateInterval.Month, d1, d2);


text:
Q: Multiple android project with one core library and multiple localisation I develop a software for multiple customers based on the same core library (which contains the whole UI and all the business logic). If everything was simple, I would reference that library from starting projects and modify the different label in the core library with a variable.
For example :
Core library : com.test.core

package (and apk) 1 : com.test.core.customer1

apk 2 : com.test.core.customer2

Final result : some modification in the ore package depanding of the starting package (labels etc.).
I tryied to change the language on the starting package (for example package1 = fr, package2 = es) : Launch an android application with different resource file
But the drawback is really simple : if I use some Android features, like copy/paste, the wrong language will be showed.
An idea would be to configure eclipse with ant (or something like this) to modify at the compile time on the fly the values/strings.xml package when I compile customer1 or customer2 but I don't know how to do this.
I use Eclipse Juno with applications using android >= 3.2.
Regards

A: This case can be resolved with ant.
I downloaded ant-contrib and put it on C:\ant-contrib\ant-contrib-1.0b3.jar
In the project I created the file specific/lm/strings.xml.
I created the custom_rules.xml file and launch it with ant.
It use the lm property which should be set to true. You can also use the target lm.
<?xml version="1.0" encoding="UTF-8"?>
<project
    name="com.test"
    default="help" >

    <target name="lm">
        <property name="lm" value="true"/>
    </target>

    <taskdef resource="net/sf/antcontrib/antcontrib.properties" >
        <classpath>
            <pathelement location="C:/ant-contrib/ant-contrib-1.0b3.jar" />
        </classpath>
    </taskdef>

    <if>
        <equals
            arg1="${lm}"
            arg2="true" />
        <then>
            <property name="startproject" value="specific/lm"/>
            <echo message="Build spécial LM / Projet : ${startproject}" />
        </then>
    </if>

    <copy file="${startproject}/strings.xml"
        tofile="res/values/strings.xml"
        overwrite="true" />
</project>

you can also use maven Skinning Android app with Maven build profiles


text:
Q: Inserting Rows for some missing columns in Pandas Dataframe
My Dataframe looks like this and i have to insert a few rows

 Date     AccessType    PrePaidSubsRev
 2013-11-01  1    584190
 2013-11-01  2    0
 2013-11-02  1    800020
 2013-11-02  2    0
 2013-11-03  1    705800
 2013-11-03  2    0
 2013-11-04  1    699930
 2013-11-04  3    0
 2013-11-04  2    0
 2013-11-05  1    963270
 2013-11-05  3    0
 2013-11-05  2    0
 2013-11-06  1    874530
 2013-11-06  3    0
 2013-11-06  2    0
 2013-11-07  1    886005
 2013-11-07  2    0
 2013-11-08  1    1209300
 2013-11-08  3    0
 2013-11-08  2    0
 2013-11-09  1    762560
 2013-11-09  2    0
 2013-11-10  1    489730
 2013-11-10  2    0

*

*For dates where the accesstype 3 is missing i have to insert rows
with the same date and accesstype as 3 and PrePaidSubsRev value as 0 .
If someone has any idea please go ahead.

A: >>> group = df.groupby(['Date','AccessType']).sum()
>>> temp = group.unstack()
>>> temp = temp.replace('nan',0)
>>> temp = temp1.stack()
>>> df = temp.reset_index()

This part worked for me..Thanks


text:
Q: Android device to detect display is on or off using the hdmi cable I am creating a app where videos are played in T.v by connecting the android device to T.v through HDMI cable.I want detect if T.V is turned off using the HDMI cable.I also tried a method mentioned in this link but its not working.
How to check the HDMI device connection status in Android?

A: Get the data file from the location /sys/class/display/display0.hdmi/connect.If the data in the file is 0 hdmi is not connected if its 1 its connected.Try this method.
try
    {
File file = new File("/sys/class/display/display0.hdmi/connect")
InputStream in = new FileInputStream(file);
byte[] re = new byte[32768];
int read = 0;
while ( (read = in.read(re, 0, 32768)) != -1)
{
    String string="Empty";
    string = new String(re, 0, read);
    Log.v("String_whilecondition","string="+string);
    result = string;

}
  in.close();
    }
    catch (IOException ex)

     {

          ex.printStackTrace();

       }


text:
Q: Window Background VisualBrush DynamicResource I have two projects, a resourcelibrary which holds a xaml file that simply has a visualbrush inside of it with a key called Theme. Inside this element is the Visual element and so on so forth. My main project is pulling in the xaml file like this
<Window.Background>
    <VisualBrush Visual={DynamicResource Theme}" />
</Window.Background

If I manually put the xaml code in this area it works perfect but I want the user to be able to flip through different xaml "themes". The problem is that right now because visualbrush in the xaml file has the key property the visual property won't convert to visualbrush... obviously... is there a way to set the visualbrush to the dynamicresource of the visualbrush element in the xaml file in resourcelibrary? This would give the effect I want to achieve. Thanks.
EDIT
Main Window
<Window x:Class="OASYS_View.MainWindow"
    Name="V_Window"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:ResourceLibrary;assembly=ResourceLibrary"
    controls:ThemeManager.Theme="{Binding ElementName=themes, Path=SelectedItem}"
    Title="V" Height="1080" Width="1920"
    WindowStyle="None"
    AllowsTransparency="True"
    ResizeMode="NoResize">
<Window.Background>
    <VisualBrush Visual="{DynamicResource Theme}" />
</Window.Background>
<Window.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded">
        <BeginStoryboard>
            <Storyboard Name="WindowFade" Completed="WindowFade_Completed">
                <DoubleAnimation  Name="WindowFadeAnimation"
                                        Storyboard.TargetName="V_Window"
                                        Storyboard.TargetProperty="(Window.Opacity)"
                                        From="0.0" To="1.0" Duration="0:0:1"
                                        AutoReverse="False" RepeatBehavior="1x"
                                        />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
    <EventTrigger RoutedEvent="Window.Unloaded">
        <BeginStoryboard>
            <Storyboard Name="WindowFadeOut" Completed="WindowFadeOut_Completed">
                <DoubleAnimation  Name="WindowFadeOutAnimation"
                                        Storyboard.TargetName="V_Window"
                                        Storyboard.TargetProperty="(Window.Opacity)"
                                        From="1.0" To="0.0" Duration="0:0:1"
                                        AutoReverse="False" RepeatBehavior="1x"
                                        />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</Window.Triggers>
<Grid>
    <ComboBox x:Name="themes" Width="150" Height="20" SelectionChanged="themes_SelectionChanged" SelectedIndex="0" />
    <controls:ProgressIndicator x:Name="Progress" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,50" Foreground="White" />
</Grid>

The Themed xaml file
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ResourceLibrary">

<VisualBrush x:Key="Theme">
    <VisualBrush.Visual>
        <Viewbox Width="1920" Height="1080">
            <Canvas x:Name="PART_Canvas" Width="1920" Height="1080">
                <Canvas>
                    <Path Data="F1 M 1920.000,1079.906 L 0.000,1080.000 L 0.000,0.094 L 1920.000,0.000 L 1920.000,1079.906 Z">
                        <Path.Fill>
                            <LinearGradientBrush MappingMode="Absolute" StartPoint="959.917,-1324.218" EndPoint="959.916,-55.456">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Offset="0.00" Color="#ff5090cd"/>
                                    <GradientStop Offset="0.66" Color="#ff5090cd"/>
                                    <GradientStop Offset="0.76" Color="#ff5090cd"/>
                                    <GradientStop Offset="0.95" Color="#ff287bbf"/>
                                    <GradientStop Offset="1.00" Color="#ff0067b1"/>
                                </LinearGradientBrush.GradientStops>
                                <LinearGradientBrush.Transform>
                                    <MatrixTransform Matrix="1.000,0.000,-0.000,-1.000,0.084,0.631" />
                                </LinearGradientBrush.Transform>
                            </LinearGradientBrush>
                        </Path.Fill>
                    </Path>
                    <Path Data="F1 M 1920.000,1080.789 L 0.001,1080.789 L 0.001,983.908 L 1920.000,983.908 L 1920.000,1080.789 Z">
                        <Path.Fill>
                            <LinearGradientBrush MappingMode="Absolute" StartPoint="959.917,-1102.122" EndPoint="959.917,-988.308">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Offset="0.00" Color="#ff5090cd"/>
                                    <GradientStop Offset="0.87" Color="#ff5090cd"/>
                                    <GradientStop Offset="1.00" Color="#ff5090cd"/>
                                </LinearGradientBrush.GradientStops>
                                <LinearGradientBrush.Transform>
                                    <MatrixTransform Matrix="1.000,0.000,-0.000,-1.000,0.084,0.631" />
                                </LinearGradientBrush.Transform>
                            </LinearGradientBrush>
                        </Path.Fill>
                    </Path>
                    <Canvas>
                        <Path Fill="#ff0067b1" Data="F1 M 51.500,1042.869 C 51.500,1038.111 50.352,1034.229 48.053,1031.217 C 45.751,1028.203 42.730,1026.695 38.986,1026.695 C 35.227,1026.695 32.205,1028.203 29.921,1031.217 C 27.640,1034.229 26.498,1038.111 26.498,1042.869 C 26.498,1047.592 27.631,1051.420 29.899,1054.344 C 32.166,1057.268 35.195,1058.732 38.986,1058.732 C 42.764,1058.732 45.794,1057.268 48.075,1054.344 C 50.359,1051.420 51.500,1047.592 51.500,1042.869 Z M 56.825,1042.869 C 56.825,1047.979 55.179,1052.160 51.887,1055.408 C 48.595,1058.654 44.296,1060.277 38.986,1060.277 C 33.678,1060.277 29.382,1058.654 26.097,1055.408 C 22.813,1052.160 21.174,1047.979 21.174,1042.869 C 21.174,1037.744 22.824,1033.510 26.135,1030.166 C 29.441,1026.818 33.727,1025.148 38.986,1025.148 C 44.263,1025.148 48.556,1026.818 51.863,1030.166 C 55.172,1033.510 56.825,1037.744 56.825,1042.869 Z"/>
                        <Canvas>
                            <Path StrokeThickness="0.5" Stroke="#ff0067b1" StrokeMiterLimit="1.0" Data="F1 M 21.224,1018.291 L 290.490,1018.291"/>
                            <Path Data="F1 M 135.245,1003.188 L 135.060,1009.395 L 137.035,1009.199 L 135.245,1003.188 Z M 130.846,1012.207 L 124.915,1008.137 L 129.871,1013.525 L 130.846,1012.207 Z M 137.423,1010.262 C 133.455,1010.262 130.202,1013.304 129.860,1017.178 L 144.985,1017.178 C 144.644,1013.304 141.391,1010.262 137.423,1010.262 Z M 133.857,1009.986 L 127.557,1002.258 L 132.096,1011.004 L 133.857,1009.986 Z M 145.892,1016.332 L 151.180,1014.025 L 145.482,1014.719 L 145.892,1016.332 Z M 142.287,999.391 L 138.402,1009.178 L 140.571,1009.801 L 142.287,999.391 Z M 128.842,1016.477 L 129.334,1014.762 L 118.275,1012.311 L 128.842,1016.477 Z M 143.382,1011.316 L 146.301,1004.479 L 141.899,1010.357 L 143.382,1011.316 Z M 144.091,1012.125 L 145.122,1013.596 L 151.921,1005.924 L 144.091,1012.125 Z">
                                <Path.Fill>
                                    <RadialGradientBrush MappingMode="Absolute" GradientOrigin="706.543,618.713" Center="706.543,618.713" RadiusX="5.469" RadiusY="5.469">
                                        <RadialGradientBrush.GradientStops>
                                            <GradientStop Offset="0.00" Color="#ffffffff"/>
                                            <GradientStop Offset="0.43" Color="#ffcccccc"/>
                                            <GradientStop Offset="1.00" Color="#ff999999"/>
                                        </RadialGradientBrush.GradientStops>
                                        <RadialGradientBrush.Transform>
                                            <MatrixTransform Matrix="1.238,0.000,0.000,1.237,-737.613,251.618" />
                                        </RadialGradientBrush.Transform>
                                    </RadialGradientBrush>
                                </Path.Fill>
                            </Path>
                            <Path Fill="#ff0067b1" Data="F1 M 77.781,1044.465 L 73.531,1032.145 L 68.950,1044.465 L 77.781,1044.465 Z M 92.457,1058.824 C 92.457,1059.277 92.327,1059.504 92.068,1059.504 C 90.953,1059.504 89.695,1059.453 88.289,1059.357 C 87.076,1059.262 86.045,1059.215 85.189,1059.215 C 84.203,1059.215 82.982,1059.262 81.530,1059.357 C 79.996,1059.453 78.689,1059.504 77.606,1059.504 C 77.351,1059.504 77.222,1059.283 77.222,1058.838 C 77.222,1058.396 77.318,1058.174 77.512,1058.174 C 78.947,1058.109 79.980,1057.920 80.611,1057.604 C 81.238,1057.289 81.553,1056.795 81.553,1056.133 C 81.553,1055.711 81.393,1055.037 81.070,1054.113 L 78.311,1046.012 L 68.371,1046.012 L 65.604,1053.508 C 65.248,1054.516 65.071,1055.291 65.071,1055.844 C 65.071,1057.266 66.377,1058.045 68.993,1058.174 C 69.187,1058.174 69.281,1058.396 69.281,1058.838 C 69.281,1059.283 69.152,1059.504 68.896,1059.504 C 67.928,1059.504 66.854,1059.453 65.676,1059.357 C 64.563,1059.262 63.570,1059.215 62.703,1059.215 C 62.008,1059.215 61.137,1059.262 60.090,1059.357 C 58.994,1059.453 58.060,1059.504 57.285,1059.504 C 57.042,1059.504 56.924,1059.303 56.924,1058.898 C 56.924,1058.449 57.107,1058.207 57.480,1058.174 C 58.818,1058.047 59.879,1057.676 60.662,1057.061 C 61.443,1056.449 62.256,1055.199 63.097,1053.314 L 74.422,1025.533 C 74.518,1025.277 74.745,1025.148 75.102,1025.148 C 75.486,1025.148 75.730,1025.270 75.826,1025.510 L 85.822,1053.314 C 86.388,1054.879 87.151,1056.031 88.109,1056.773 C 89.069,1057.512 90.359,1057.980 91.971,1058.174 C 92.295,1058.207 92.457,1058.424 92.457,1058.824 Z"/>
                            <Path Fill="#ff0067b1" Data="F1 M 115.325,1049.783 C 115.325,1052.994 114.372,1055.545 112.467,1057.439 C 110.561,1059.330 107.982,1060.277 104.736,1060.277 C 103.299,1060.277 101.580,1060.020 99.578,1059.504 C 97.750,1059.021 96.256,1058.779 95.093,1058.779 C 94.995,1056.039 94.803,1053.299 94.512,1050.561 C 94.512,1050.303 94.755,1050.174 95.238,1050.174 C 95.576,1050.174 95.787,1050.303 95.867,1050.561 C 96.740,1053.557 97.855,1055.670 99.215,1056.893 C 100.570,1058.117 102.473,1058.732 104.923,1058.732 C 106.874,1058.732 108.386,1058.166 109.459,1057.039 C 110.530,1055.910 111.064,1054.330 111.064,1052.301 C 111.064,1050.994 110.598,1049.781 109.663,1048.660 C 108.728,1047.537 106.734,1046.094 103.686,1044.320 C 100.184,1042.305 97.893,1040.596 96.811,1039.193 C 95.730,1037.791 95.191,1036.236 95.191,1034.527 C 95.191,1031.902 96.163,1029.682 98.109,1027.869 C 100.057,1026.055 102.525,1025.148 105.513,1025.148 C 106.645,1025.148 107.946,1025.301 109.414,1025.607 C 110.787,1025.883 111.977,1026.020 112.977,1026.020 C 113.171,1028.854 113.429,1031.354 113.752,1033.512 C 113.752,1033.770 113.544,1033.902 113.124,1033.902 C 112.674,1033.902 112.422,1033.770 112.375,1033.512 C 111.840,1031.096 111.029,1029.355 109.947,1028.289 C 108.867,1027.229 107.368,1026.695 105.457,1026.695 C 103.641,1026.695 102.197,1027.229 101.127,1028.289 C 100.057,1029.355 99.522,1030.791 99.522,1032.596 C 99.522,1033.736 99.971,1034.828 100.871,1035.869 C 101.770,1036.908 103.714,1038.301 106.707,1040.041 C 110.253,1042.104 112.574,1043.828 113.676,1045.215 C 114.774,1046.600 115.325,1048.123 115.325,1049.783 Z"/>
                            <Path Fill="#ff0067b1" Data="F1 M 154.821,1026.537 C 154.821,1026.713 154.766,1026.865 154.652,1027.002 C 154.539,1027.133 154.418,1027.205 154.289,1027.205 C 152.691,1027.379 151.486,1027.711 150.671,1028.203 C 149.855,1028.688 148.893,1029.740 147.779,1031.361 L 138.728,1044.369 L 138.728,1054.090 C 138.728,1055.188 138.820,1055.959 139.006,1056.408 C 139.193,1056.859 139.619,1057.229 140.291,1057.508 C 140.959,1057.793 141.979,1058.014 143.350,1058.174 C 143.609,1058.207 143.738,1058.424 143.738,1058.824 C 143.738,1059.277 143.609,1059.504 143.350,1059.504 C 142.271,1059.504 141.051,1059.453 139.695,1059.357 C 138.387,1059.262 137.238,1059.215 136.248,1059.215 C 135.273,1059.215 134.076,1059.262 132.652,1059.357 C 131.152,1059.453 129.862,1059.504 128.782,1059.504 C 128.523,1059.504 128.395,1059.277 128.395,1058.824 C 128.395,1058.424 128.523,1058.207 128.782,1058.174 C 130.734,1057.949 132.061,1057.586 132.762,1057.086 C 133.463,1056.588 133.814,1055.590 133.814,1054.090 L 133.814,1044.465 L 125.443,1031.336 C 124.297,1029.715 123.289,1028.662 122.418,1028.176 C 121.545,1027.689 120.375,1027.365 118.908,1027.205 C 118.649,1027.205 118.520,1026.980 118.520,1026.537 C 118.520,1026.094 118.649,1025.873 118.908,1025.873 C 119.663,1025.873 120.693,1025.920 122.000,1026.020 C 123.418,1026.115 124.563,1026.164 125.430,1026.164 C 126.254,1026.164 127.388,1026.115 128.838,1026.020 C 130.531,1025.920 131.941,1025.873 133.070,1025.873 C 133.328,1025.873 133.459,1026.094 133.459,1026.537 C 133.459,1026.980 133.328,1027.205 133.070,1027.205 C 130.975,1027.494 129.926,1028.047 129.926,1028.861 C 129.926,1029.512 130.257,1030.350 130.916,1031.373 L 137.921,1042.266 L 145.232,1031.336 C 145.752,1030.572 146.010,1029.908 146.010,1029.344 C 146.010,1028.725 145.725,1028.260 145.148,1027.945 C 144.576,1027.629 143.604,1027.379 142.234,1027.205 C 142.039,1027.205 141.941,1026.980 141.941,1026.537 C 141.941,1026.094 142.072,1025.873 142.329,1025.873 C 143.283,1025.873 144.444,1025.920 145.816,1026.020 C 147.153,1026.115 148.268,1026.164 149.155,1026.164 C 149.980,1026.164 150.852,1026.115 151.771,1026.020 C 152.707,1025.920 153.594,1025.873 154.436,1025.873 C 154.693,1025.873 154.821,1026.094 154.821,1026.537 Z"/>
                            <Path Fill="#ff0067b1" Data="F1 M 177.619,1049.783 C 177.619,1052.994 176.666,1055.545 174.762,1057.439 C 172.855,1059.330 170.278,1060.277 167.031,1060.277 C 165.594,1060.277 163.875,1060.020 161.871,1059.504 C 160.046,1059.021 158.551,1058.779 157.389,1058.779 C 157.291,1056.039 157.098,1053.299 156.807,1050.561 C 156.807,1050.303 157.048,1050.174 157.533,1050.174 C 157.872,1050.174 158.081,1050.303 158.162,1050.561 C 159.035,1053.557 160.148,1055.670 161.506,1056.893 C 162.863,1058.117 164.767,1058.732 167.219,1058.732 C 169.169,1058.732 170.682,1058.166 171.753,1057.039 C 172.823,1055.910 173.360,1054.330 173.360,1052.301 C 173.360,1050.994 172.893,1049.781 171.957,1048.660 C 171.021,1047.537 169.029,1046.094 165.979,1044.320 C 162.480,1042.305 160.188,1040.596 159.105,1039.193 C 158.025,1037.791 157.482,1036.236 157.482,1034.527 C 157.482,1031.902 158.459,1029.682 160.403,1027.869 C 162.352,1026.055 164.819,1025.148 167.809,1025.148 C 168.939,1025.148 170.238,1025.301 171.709,1025.607 C 173.082,1025.883 174.268,1026.020 175.271,1026.020 C 175.466,1028.854 175.725,1031.354 176.048,1033.512 C 176.048,1033.770 175.836,1033.902 175.418,1033.902 C 174.965,1033.902 174.717,1033.770 174.666,1033.512 C 174.135,1031.096 173.325,1029.355 172.244,1028.289 C 171.158,1027.229 169.661,1026.695 167.748,1026.695 C 165.935,1026.695 164.492,1027.229 163.422,1028.289 C 162.352,1029.355 161.817,1030.791 161.817,1032.596 C 161.817,1033.736 162.266,1034.828 163.163,1035.869 C 164.061,1036.908 166.010,1038.301 169.002,1040.041 C 172.547,1042.104 174.868,1043.828 175.971,1045.215 C 177.070,1046.600 177.619,1048.123 177.619,1049.783 Z"/>
                            <Path StrokeThickness="0.5" Stroke="#ff0067b1" StrokeMiterLimit="1.0" Data="F1 M 21.224,1066.850 L 290.490,1066.850"/>
                            <Canvas>
                                <Path Opacity="0.5" Fill="#ff4b4d4d" Data="F1 M 199.003,1053.682 L 199.088,1053.682 L 208.492,1026.553 L 210.516,1026.553 L 198.961,1059.369 L 187.532,1026.553 L 189.557,1026.553 L 199.003,1053.682 Z"/>
                                <Path Opacity="0.5" Fill="#ff4b4d4d" Data="F1 M 216.168,1058.316 L 214.143,1058.316 L 214.143,1026.553 L 216.168,1026.553 L 216.168,1058.316 Z"/>
                                <Path Opacity="0.5" Fill="#ff4b4d4d" Data="F1 M 225.024,1028.445 L 225.024,1039.990 L 237.844,1039.990 L 237.844,1041.887 L 225.024,1041.887 L 225.024,1056.420 L 238.181,1056.420 L 238.181,1058.316 L 223.000,1058.316 L 223.000,1026.553 L 238.181,1026.553 L 238.181,1028.445 L 225.024,1028.445 Z"/>
                                <Path Opacity="0.5" Fill="#ff4b4d4d" Data="F1 M 252.436,1053.850 L 264.327,1024.949 L 276.219,1053.850 L 285.033,1026.553 L 287.057,1026.553 L 276.347,1059.369 L 264.201,1030.004 L 252.098,1059.369 L 241.471,1026.553 L 243.495,1026.553 L 252.436,1053.850 Z"/>
                            </Canvas>
                        </Canvas>
                    </Canvas>
                </Canvas>
            </Canvas>
        </Viewbox>
    </VisualBrush.Visual>
</VisualBrush>
</ResourceDictionary>

You'll see that VisualBrush has the keyname but in mainwindow.background I need to bind to visual property of visualbrush.
{"Unable to cast object of type 'System.Windows.Media.VisualBrush' to type 'System.Windows.Media.Visual'."}

A: Edit
Try this
<Window Background="{DynamicResource Theme}"
        ...>

A: Try adding your resource dictionary file to the Window's resources and then point to the visual in the background.
<Window>
  <Window.Resources>
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="Theme.xaml"/>
    </ResourceDictionary.MergedDictionaries>
  </Window.Resources>
  <Window.Background>
    <VisualBrush Visual="{VisualKey}"/>
  </Window.Background>
</Window>


text:
Q: How to show a large image completely on a canvas? I want to load an image from gallery  as a bitmap an show it on a custom view(not an imageview).Here is the code for loading bitmap.
private Bitmap loadBitmap(String filePath, int orientation, int width, int height) {
        Bitmap bitmap = null;
        try {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(filePath, options);
            int scale = 1;
            if ((options.outWidth > width) || (options.outHeight > height)) {
                if (options.outWidth < options.outHeight) {
                    scale = Math.round((float) options.outWidth / width);
                } else {
                    scale = Math.round((float) options.outHeight/ height);
                }
            }
            options.inSampleSize = scale;
            options.inJustDecodeBounds = false;
            bitmap = BitmapFactory.decodeFile(filePath, options);
            if (orientation > 0) {
                // rotate the image w.r.to orientation
                Matrix matrix = new Matrix();
                matrix.postRotate(orientation);
                bitmap = Bitmap.createBitmap(bitmap, 0, 0,width,height, matrix, true);
            }
        } catch (Exception e) {
            bitmap = null;
        }
        return bitmap;
    }

Now my problem is that the canvas does not  show the bitmap completely.Only a part o  it.How can i adjust the image (without losing its clarity,not stretching) with screen size?
Thanks in Advance

A: May be you can try the ScaleType options and use the one whihc suits you the best. Follow the link below for details:
http://developer.android.com/reference/android/widget/ImageView.ScaleType.html


text:
Q: Prevent counterclockwise rotation So I have an object that has a handle attached to it, the player is supposed to rotate this handle. For that, I'm taking in the horizontal and vertical axis of a controllers analogue stick and transform these values into degrees, which I then use to rotate the object.
The problem is that I can't seem to completely block out the possibility of rotating the handle counterclockwise, as the player is only supposed to rotate it clockwise. What happens is that every couple of frames while I try rotating counterclockwise it detects a clockwise rotation, executing my according code, even though I was rotating counterclockwise consistently.
The principles I use to determine which direction the rotation is going is done by comparing the input angle of the last frame to the current input angle, like:
// Variant 1:
var inputAngle = Mathf.Atan2(x, y) * Mathf.Rad2Deg;

float angleDifference = inputAngle - previousAngle;
if (angleDifference > 180f) angleDifference -= 360f;
if (angleDifference < -180f) angleDifference += 360f;

if (Mathf.Sign(angleDifference).Equals(-1))
{
// Counterclockwise rotation
}
else
{
// Clockwise rotation
}

// ...

previousAngle = inputAngle;

In another attempt, I tried to do this comparison by simply checking if my current angle is larger than my previous one while having the input transformed in a 0° to 360° range and also handling the overflow from going back to 0° from 360°, which did not work consistently either.
So I tried to see what the values are giving in this faulty case, but what this told me was simply that the values are not as I expected them to be, as the current angle should be smaller than the previous one while rotating counterclockwise, in those cases and I can't figure out why or how to prevent it?

So I guess in the end my question would be how can I consistently prevent a player from rotating counterclockwise by reading a controller's analogue stick input.

A: I would use Vector3.SignedAngle to get the to-from angle around the forward axis. Then if the angle is negative, it's clockwise; positive is counter-clockwise:
Vector3 previousPos;

Vector3 GetPos()
{
    /* return current controller position, between (-1,-1,0) and (1,1,0) */
}

void Awake() { previousPos = previousPos; }

void Update()
{
    Vector3 curPos = GetPos();

    float deltaAngle = Vector3.SignedAngle(previousPos, curPos, Vector3.foward);

    // If you want to clamp the speed
    // float maxSpeed = 180f; // max rotational speed = 180 degrees per second
    // deltaAngle = Mathf.Clamp(deltaAngle/Time.deltaTime, -maxSpeed, maxSpeed)
    //         * Time.deltaTime;

    bool isClockwise = deltaAngle < 0;
    bool isCounterClockwise = deltaAngle > 0;

    if (isClockwise)
    {
        // do stuff when motion is clockwise
    }
    else if (isCounterClockwise)
    {
        // do stuff when motion is counter clockwise
    }
    else
    {
        // do stuff when no rotational motion occurs
    }

    previousPos = curPos;
}


text:
Q: Accessing content of XML node using Groovy XMLParser I have some elements that have the same tag name, but equal different values. The example below displays my parsing.
<Report>
<ReportHost name= 2.3.3.3><HostProperties>
<tag name="x"> Monday...</tag>
<tag name="z"> Linux.....</tag>

My issue is how do I capture the text after the string "x".. and "z"
Currently I have
langs.Report.ReportHost.each{ReportHost->
${ReportHost.HostProperties.tag['@name']}"

But this is only grabbing x and z. What syntax do I need to grab the text after that which including Monday and Linux.

A: This will print out the tag attribute list and then the node contents list:
langs.ReportHost.each { reportHost ->
  println "tag  = ${reportHost.HostProperties.tag['@name']}"
  println "cont = ${reportHost.HostProperties.tag*.text()}"
}

If you take your each further down the tree, then you can easily print them on one line
langs.ReportHost.HostProperties.tag.each { tag ->
  println "tag=${tag.@name} content=${tag.text()}"
}


text:
Q: Print all possible routes between C to D in Graph only visiting once Working on a problem for graph traversal given a start and end.
Example if given edge routes:
("A","B")
("A","C")
("A","D")
("B","C")
("B","D")
Answer would be:
(C,B,D)
(C,A,D)
(C,A,B,D)
(C,B,A,D)
I am implementing this with two methods addRoute and printRoutes that take a start and des(the source and destination).
I created addRoute to add them, but having trouble trying to find a good solution to print all unique routes.
Solution so far is to convert it to an adjacency list and to run DFS or BFS on it. I need some help creating the BFS/DFS algoritum for this.
public class Graph{
    List<List<String>> edges= new ArrayList<>();
    Map<String, Set<String>> adjList= new HashMap<>();

     void addRoutes(String start, String des) {
         List<String> temp1 = new ArrayList<>();
         temp1.add(start);
         temp1.add(des);
        edges.add(temp1);
        adjList.putIfAbsent(start, new HashSet<>());
        adjList.putIfAbsent(des, new HashSet<>());
        adjList.get(start).add(des);
        adjList.get(des).add(start);
    }
        void printRoutes(String start, String des) {
     Set<String> visited = new HashSet<>();
     // Mark the current node as visited and enqueue it

     // Create a queue for BFS
     Queue<List<String> > queue = new LinkedList<>();
     // Path vector to store the current path
     List<String> path = new ArrayList<>();
     path.add(start);
     queue.offer(path);

     while (!queue.isEmpty()) {
         path = queue.poll();
         String last = path.get(path.size() -1);
         if (last == des) {
             int size = path.size();
             for(String v : path) {
                 System.out.print(v + " ");
             }
         }
         Set<String> lastNode = adjList.get(last);
         for (String neig : adjList.get(start)) {
             if (!visited.contains(neig)) {
                 List<String> newpath = new ArrayList(path);
                 visited.add(start);
                 queue.offer(newpath);
             }

         }
     }
}
    public static void main(String[] args) {
        Graph g = new Graph();
        g.addRoutes("A","B");
        g.addRoutes("A","C");
        g.addRoutes("A","D");
        g.addRoutes("B","C");
        g.addRoutes("B","D");
        System.out.println(g.edges);
        System.out.println(g.adjList);
    }
}

A: Yes, using BFS (or DFS) is right idea for getting all simple paths between vertices.
You just need to modify these algorithms a bit:  BFS uses global visited marks data. Instead make visited data structure local to every branch - as parameter of recursive function in case of recursive implementation.


text:
Q: How to disable terminal scrolling in a Bash script? When using a program like htop - mouse scroll wheel action will not do anything.
How can I reproduce such behavior in my Bash script?
I guess there should be a way to tell the terminal to ignore scrolling requests. How is that done?

A: htop happens to use ncurses
ncurses (and other things that use the full screen in a terminal) initializes the terminal using the terminfo capability smcup.  For xterm (and terminal emulators that imitate it), that switches to the alternate screen.  Those terminals may respond to a wheel mouse by sending up/down cursor keys instead of scrolling the terminal window (which you would see in htop by the focus-line moving up/down).  Your bash script may see those cursor keys, but not handle them.
You can experiment with the feature in a script using
tput smcup

to switch to the alternate screen, and
tput rmcup

to switch back to the normal screen.


text:
Q: Implemented Jaccard distance into ANTLR to find similarity of java code After a while, I was successfully able to get an unique id from a file .java using ANTLR. And then I divide that unique id to 4-gram using N-gram, thanks to ANTLR. This is my code:
public void runAlgoritma(File mainFile, List<String> fileJlist)
 BufferedReader in = null;
 try {
     in = new BufferedReader(new FileReader(FileUtama.getAbsolutePath()));
  } catch (FileNotFoundException e1) {
   e1.printStackTrace();
  }
 final Antlr3JavaLexer lexer = new Antlr3JavaLexer();
 lexer.preserveWhitespacesAndComments = false;

 try {
   lexer.setCharStream(new ANTLRReaderStream(in));
   } catch (IOException e) {
    e.printStackTrace();
   }

 final CommonTokenStream tokens = new CommonTokenStream();
 tokens.setTokenSource(lexer);
    tokens.LT(10); // paksa force load

    Antlr3JavaParser parser = new Antlr3JavaParser(tokens);

    StringBuilder sbr = new StringBuilder();
    List tokenList = tokens.getTokens();
    for (int i = 0; i < tokenList.size(); i++) {
        org.antlr.runtime.Token token = (org.antlr.runtime.Token) tokenList.get(i);
        int text = token.getType();
        sbr.append(text);
    }

    String mainFile = sbr.toString();
    StringBuffer stringBuffer = new StringBuffer();
    for (String term : new NgramAnalyzer(4).analyzer(mainFile)) {

        stringBuffer.append(term + "\n");

    }
    System.out.println(stringBuffer);

I was wondering, How can I compare two java source codes using jaccard similiarity from the n-gram that I have made ?


text:
Q: Native API window designer Why isn't there a designer for native api forms in Visual Studio? Similar to Delphi?
If there exist some programs, tools etc, please advice.
What is the best approach to design complex windows in pure API?

A: There's ressource editor for dialogs, and then there is code.
I've never really missed some visual design tool, though some better support from the controls themselves would be nice.
The core problem is the abstraction level: using just Win32 controls, designing a complex GUI needs some forethought, and the controls all have slightly different oddities, capabilities and features. They don't have a common interface that can be used to build a designer on top.
WinForms was designed from the ground up with designer support in mind, and it shows. The main design concern of Win32 controls was memory footprint of code and data.
Even MFC (which still shows many signs of memory scarcity) doesn't abstract these oddities away well enough to warrant a decent forms designer.
All environments that come with a decent forms editor (I remember Watcom ++ / Optima, ZINC, and quite some others I've forgotten the names of) also come with a decent forms library with a high abstraction level.
Then, there's the problem of modifications. What should be the designer's output? One could shoot for an XML data file, but that would add a dependency to some large libraries to your native app - doesn't make much sense. Or you create code, but C/C++ isn't well suited to that. Another binary format? You'd limit yourself to what the designer allows.

In the end, the designer would have to take care of each control separately, and still could not isolate you from knowing the controls and window mechanisms inside out. It was never undertaken when C++ was the first choice for large scale desktop development. Adding it now, when there are - arguably - better choices, would be a rather stupid move.

A: That's probably because there is no standard way of doing control layouts in WinAPI, you have to manage it by yourself. There is no base "Control" class in WinAPI - everything is a Window of some sort, so no way to support their differences with a common layout editor/designer.
You can however create your window layout in a dialog and make it resizable by yourself or using methods published on codeproject (this or this - both are MFC-related, but that's fairly easy to translate).
Or adapt ScreenLib to your desktop needs.

A: It's because of Microsoft. They've already moved towards dotNet and C#. Visual Studio 2005 has nice GUI editor for those. Why do you need to use the pure API ?


text:
Q: Prolog - Trouble with implementing the Sieve of Eratosthenes I'm trying to write a program in prolog that finds all prime numbers up to a limit N, I'm trying to achieve this by using the Sieve of Eratosthenes. I'm very new to prolog so I haven't really mastered the art of thinking recursively (you can probably see that in my code).
Nonetheless, I (more or less) tried implementing the algorithm in prolog, but didn't get very far as you'll see here:
 allPrimes(N, Primes) :-
     numlist(2, N, Numlist),
     A is round(sqrt(N)),
     foreach(between(2, A, _i), sift(_i, Numlist, Primes)).

 sift(_i, Numlist, Primes) :-
     findall(_j, (member(_j, Numlist), _j \== _i, (_j mod _i =:= 0)), L),
     subtract(Numlist, L, Primes).

I keep getting false as output because subtract(Numlist, L, Primes) fails, my guess as to why it fails is because Primes has already been instantiated and its value can't be changed. I have tried solving this in other ways, but couldn't come up with a solution.
Any help in guiding me in the right direction is very much appreciated!

A: You cannot change the list of primes after you instantiated it. You may however further instantiate some items on it if they were uninstantiated (not your case) and you could probably solve this problem that way.
Here goes a recursive solution based on your algorithm:
allPrimes(N, Primes) :-
    numlist(2, N, Numlist),
    Stop is round(sqrt(N)),
    allPrimes(Numlist, Stop, Primes).

allPrimes([N|Numlist], Stop, [N|Primes]):-
  exclude(is_multiple(N), Numlist, MPrimes),
  (N =< Stop -> allPrimes(MPrimes, Stop, Primes) ; Primes=MPrimes).

is_multiple(N, I):-
  I mod N =:= 0.

So you build a list of possible integers and compute the stop number. Then you call the recursive procedure allPrimes/3 which takes the first prime, then excludes all the multiples of that number from the list and recursively calls itself with the remaining elements.
After finishing the recursion (base case is when N is the stop number) we build back the prime list.
Sample run:
?- allPrimes(100, Primes).
Primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97].


text:
Q: When I call dynamic fragment from another fragment, I still could access buttons in the first fragment? when 2nd fragment is displayed if a click is made in-where a button in 1st fragment exists(at its position exactly  )- that old button onClick got called, something like a transparent button :), well this should no happen at least with replace() .NOTE: the first fragment is a fragment under TabLayout.
public class first_Fragment extends Fragment {

    public first_Fragment ()
    {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {
    View rootview=inflater.inflate(R.layout.profile_fragment, container, false);

     final View fragmentContainer = rootview.findViewById(R.id.container);

        Button new_frament_btn=
        (Button)rootview.findViewById(R.id.new_frament_btn);
        new_frament_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                 Fragment newFragment = new Second_Fragment();
                  FragmentTransaction transaction =
            getFragmentManager().beginTransaction();
                transaction.replace(fragmentContainer.getId(), newFragment);
                transaction.addToBackStack(null);

                 transaction.commit();
            }
        });
        Button btn_toast=
        (Button)rootview.findViewById(R.id.btn1);
        btn_toast.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getActivity(), "this is first fragment",
        Toast.LENGTH_LONG).show();

            }
        });
        return rootview;
    }
}

the first fragment xml
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/profile_background_yellow1"
android:id="@+id/container"

android:layout_height="match_parent"
android:orientation="vertical">

        <Button
            android:id="@+id/new_frament_btn"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_below="@+id/setting"
            android:layout_centerHorizontal="true"
            android:src="@drawable/profile_friends" />

        <Button
            android:id="@+id/btn1"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:src="@drawable/profile_account_setting"/>
       .............
    />

the second fragment code
public class Second_Fragment extends Fragment {

    public Second_Fragment ()
    {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_two, container, false);
    }
}

the second fragment xml
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
  >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:text="second_fragment"
    android:textSize="40dp"
    android:textStyle="bold" />

</RelativeLayout>

A: Add android:clickable="true" in the xml file of second fragment layout.
I think this is gonna help.
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:clickable="true" />


text:
Q: Downloaded and imported Json Are Gone when i close my app and reopen it When i Download The Json file From The Server And once I Close my App and Reopen it again All the  Servers  that Are Downloaded and Imported Are gone..
The Question Is..
How To Keep  the Json Files Downloaded and Imported When I Close My App...
my code:
//GET INPUT FROM STREAM
InputStream is=new BufferedInputStream(con.getInputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(is));

String line;
StringBuffer jsonData=new StringBuffer();

A: After you download them you should save all the data into a SharedPreferences, so when you app opens again it will pull the data from there
To implement manage of SharedPreferences do this
To set the values just do this
SharedPreferences.Editor editor = getSharedPreferences("MY_PREFS_NAME", MODE_PRIVATE).edit();
 editor.putString("myData", jsonData);
 editor.apply();

To retrieve this data do this
SharedPreferences prefs = getSharedPreferences("MY_PREFS_NAME", MODE_PRIVATE);
String data = prefs.getString("myData","");

Call the data from the shared preferences when your app restarts, so you will be downloading the data -> storing it into sharedpreferences -> call again the data from sharedpreferences when app is reopened
For more info you should read the official SharedPrefs doc here : https://developer.android.com/training/data-storage/shared-preferences.html
hope it helps !
Happy coding !


text:
Q: How to upgrade to spring-integration-kafka 2.1.0.RELEASE with xml configuration? I am upgrading spring-integration-kafka from 1.0.0.M2 to 2.1.0.RELEASE and client 0.9.0 to 0.10.0
Current xml configuration as below

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
 xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
 xmlns:task="http://www.springframework.org/schema/task"
 xsi:schemaLocation="http://www.springframework.org/schema/integration/kafka http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd
  http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">

 <int:publish-subscribe-channel id="inputToKafka" />

 <int-kafka:outbound-channel-adapter
  kafka-producer-context-ref="kafkaProducerContext" auto-startup="true"
  channel="inputToKafka" order="1">
 </int-kafka:outbound-channel-adapter>

 <bean id="producerProperties"
  class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="properties">
   <props>
    <prop key="topic.metadata.refresh.interval.ms">${topic.metadata.refresh.interval.ms}</prop>
    <prop key="message.send.max.retries">${message.send.max.retries}</prop>
    <prop key="send.buffer.bytes">${send.buffer.bytes}</prop>
   </props>
  </property>
 </bean>

 <bean id="fcmNotificationEncoder"
  class="org.springframework.integration.kafka.serializer.avro.AvroReflectDatumBackedKafkaEncoder">
  <constructor-arg value="common.vo.NotificationVo" />
 </bean>

 <int-kafka:producer-context id="kafkaProducerContext"
  producer-properties="producerProperties">
  <int-kafka:producer-configurations>
   <int-kafka:producer-configuration
    broker-list="${kafka.servers}" key-class-type="java.lang.String"
    value-class-type="common.vo.fcmNotificationVo"
    value-encoder="fcmNotificationEncoder" topic="trigger-fcm-notification"
    compression-codec="none" />
  </int-kafka:producer-configurations>
 </int-kafka:producer-context>

 <int:service-activator input-channel="ip-chanel-trigger-fcm-notification"
  ref="fcmNotificationConsumer">
 </int:service-activator>

 <bean id="consumerProperties"
  class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="properties">
   <props>
    <prop key="auto.offset.reset">${auto.offset.reset}</prop>
    <prop key="socket.receive.buffer.bytes">${socket.receive.buffer.bytes}</prop> <!-- 10M -->
    <prop key="fetch.message.max.bytes">${fetch.message.max.bytes}</prop>
    <prop key="auto.commit.interval.ms">${auto.commit.interval.ms}</prop>
   </props>
  </property>
 </bean>

 <int-kafka:zookeeper-connect id="zookeeperConnect"
  zk-connect="${zookeeper.servers}" zk-connection-timeout="${zookeeper.connection.timeout}"
  zk-session-timeout="${zookeeper.session.timeout}" zk-sync-time="${zookeeper.sync.time}" />

 <bean id="kafkaThreadListener" class="api.utils.KafkaConsumerStarter"
  init-method="initIt" destroy-method="cleanUp" />

 <int-kafka:inbound-channel-adapter
  kafka-consumer-context-ref="consumerContextFCM" auto-startup="false"
  channel="ip-chanel-trigger-fcm-notification" id="kafka-inbound-channel-adapter-FCM">
  <int:poller fixed-delay="1000" time-unit="MILLISECONDS"
   receive-timeout="0" />
 </int-kafka:inbound-channel-adapter>

 <!-- Consumer -->

 <bean id="fcmNotificationDecoder"
  class="org.springframework.integration.kafka.serializer.avro.AvroReflectDatumBackedKafkaDecoder">
  <constructor-arg value="common.vo.NotificationVo" />
 </bean>

 <int-kafka:consumer-context id="consumerContextFCM"
  consumer-timeout="4000" zookeeper-connect="zookeeperConnect"
  consumer-properties="consumerProperties">
  <int-kafka:consumer-configurations>
   <int-kafka:consumer-configuration
    group-id="trigger-fcm-notification" max-messages="50"
    value-decoder="fcmNotificationDecoder">
    <int-kafka:topic id="trigger-fcm-notification"
     streams="10" />
   </int-kafka:consumer-configuration>
  </int-kafka:consumer-configurations>
 </int-kafka:consumer-context>

</beans>

How to change this to 2.1.0.RELEASE ?
~~~~~~~~~~~~~~~
EDITED HERE:
Using reference modified the xml as per my requirement. I got small issue while reading the Consumer Record . I got payload as follows

{
kafka_offset=7,
kafka_receivedMessageKey=null,
kafka_receivedPartitionId=0,
kafka_receivedTopic=trigger-fcm-notification,
kafka_acknowledgment=Acknowledgment for ConsumerRecord(topic = trigger-fcm-notification, partition = 0, offset = 7, CreateTime = 1476864644264, checksum = 3680317883, serialized key size = -1, serialized value size = 270, key = null, value = common.vo.NotificationVo@203c8c95)
}

I need the value (NotificationVo) for further use in consumer. How to get it as part of payload?
~~~~~~~~~~~~~~~
EDITED HERE:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
 xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
 xmlns:task="http://www.springframework.org/schema/task"
 xsi:schemaLocation="http://www.springframework.org/schema/integration/kafka http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd
  http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">

 <int:publish-subscribe-channel id="inputToKafka" />

 <int-kafka:outbound-channel-adapter
  id="kafkaOutboundChannelAdapter" kafka-template="template"
  auto-startup="true" channel="inputToKafka" topic="trigger-fcm-notification"
  order="1">

  <int-kafka:request-handler-advice-chain>
   <bean
    class="org.springframework.integration.handler.advice.RequestHandlerCircuitBreakerAdvice" />
  </int-kafka:request-handler-advice-chain>
 </int-kafka:outbound-channel-adapter>

 <!--Producer-->
 <bean id="template" class="org.springframework.kafka.core.KafkaTemplate">
  <constructor-arg>
   <bean class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
    <constructor-arg>
     <map>
      <entry key="bootstrap.servers" value="localhost:9092" />
      <entry key="retries" value="5" />
      <entry key="batch.size" value="16384" />
      <entry key="linger.ms" value="1" />
      <entry key="buffer.memory" value="33554432" />
      <entry key="key.serializer"
       value="org.apache.kafka.common.serialization.StringSerializer" />
      <entry key="value.serializer"
       value="common.vo.NotificationVoSerializer" />
     </map>
    </constructor-arg>
   </bean>
  </constructor-arg>
 </bean>

 <int-kafka:message-driven-channel-adapter
  id="kafka-inbound-channel-adapter-FCM" listener-container="container1"
  auto-startup="true" phase="100" send-timeout="5000"
  channel="ip-chanel-trigger-fcm-notification" mode="record"
  message-converter="messageConverter" />

 <bean id="messageConverter"
  class="org.springframework.kafka.support.converter.MessagingMessageConverter" />

 <int:service-activator input-channel="ip-chanel-trigger-fcm-notification"
  ref="fcmNotificationConsumer">
 </int:service-activator>

 <!--Consumer-->
 <bean id="container1"
  class="org.springframework.kafka.listener.KafkaMessageListenerContainer">
  <constructor-arg>
   <bean class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
    <constructor-arg>
     <map>
      <entry key="bootstrap.servers" value="localhost:9092" />
      <entry key="enable.auto.commit" value="false" />
      <entry key="auto.commit.interval.ms" value="100" />
      <entry key="session.timeout.ms" value="15000" />
      <entry key="group.id" value="trigger-fcm-notification" />
      <entry key="key.deserializer"
       value="org.apache.kafka.common.serialization.StringDeserializer" />
      <entry key="value.deserializer"
       value="common.vo.NotificationVoDeserializer" />
     </map>
    </constructor-arg>
   </bean>
  </constructor-arg>

  <constructor-arg>
   <bean class="org.springframework.kafka.listener.config.ContainerProperties">
    <constructor-arg name="topics" value="trigger-fcm-notification" />
   </bean>
  </constructor-arg>
 </bean>

</beans>

This is the modified xml config file
~~~~~~~~~~~~~~~
EDITED HERE:
Consumer class:

package common.notification.consumer;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.common.TopicPartition;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import common.vo.NotificationVo;

@Component
public class FcmNotificationConsumer {

 @SuppressWarnings("unchecked")
 @ServiceActivator
 public <K, V> void process(Map<K, V> payload) {

  String topic = null;
  System.out.println("payload=====>"+payload.toString());

  for (K item : payload.keySet()) {
   topic = (String) item;
  }

  Object ackObject = payload.get(topic);
  System.out.println("ackObject=====>"+payload.get(topic));

 }
}

O/P:

payload=====>{kafka_offset=21, kafka_receivedMessageKey=null, kafka_receivedPartitionId=0, kafka_receivedTopic=trigger-fcm-notification, kafka_acknowledgment=Acknowledgment for ConsumerRecord(topic = trigger-fcm-notification, partition = 0, offset = 21, CreateTime = 1476887227554, checksum = 222603853, serialized key size = -1, serialized value size = 270, key = null, value = common.vo.NotificationVo@29206bb8)}

ackObject=====>Acknowledgment for ConsumerRecord(topic = trigger-fcm-notification, partition = 0, offset = 21, CreateTime = 1476887227554, checksum = 222603853, serialized key size = -1, serialized value size = 270, key = null, value = common.vo.NotificationVo@29206bb8)

~~~~~~~~~~~~~~~
EDITED HERE:
Received expected payload after changing the method parameter in Consumer class.

package common.notification.consumer;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import common.vo.NotificationVo;

@Component
public class FcmNotificationConsumer {

 @SuppressWarnings("unchecked")
 @ServiceActivator
 public void process(Message<?> message) {
        System.out.println("Message=====>"+message);
       Object payloadObject = message.getPayload();
   NotificationVo notificationVo = (NotificationVo) payloadObject;
 }
}

O/P:

Message=====>GenericMessage [payload=common.vo.NotificationVo@4c144e99, headers={kafka_offset=16, kafka_receivedMessageKey=null, kafka_receivedPartitionId=0, kafka_receivedTopic=trigger-fcm-notification, kafka_acknowledgment=Acknowledgment for ConsumerRecord(topic = trigger-fcm-notification, partition = 0, offset = 16, CreateTime = 1476949945607, checksum = 2501578118, serialized key size = -1, serialized value size = 270, key = null, value = common.vo.NotificationVo@4c144e99)}]

Finally working as expected.
Thanks a lot for the support.

A: OK. Now it is more cleaner than before.
So, you current code is for Apache Kafka 0.8. Since version 0.9 it has fully different design. Therefore the current code for the Spring Integration Kafka 1.0 must be throw away.
You should read about Apache Kafka 0.10: https://kafka.apache.org/documentation.
About Spring Kafka, which is based on the Kafka Client 0.10: http://docs.spring.io/spring-kafka/docs/1.1.1.RELEASE/reference/html/
And pay attention to the chapter there about Spring Integration Kafka: http://docs.spring.io/spring-kafka/docs/1.1.1.RELEASE/reference/html/_spring_integration.html
And note: nobody here is going to do work for you.
EDIT
I'm not sure why you say that you have a payload like that, because that is exactly headers. That value in the ConsumerRecord is converted to the payload of the message.
Please, share the code where you receive that and try to extract the value. The <int-kafka:message-driver-channel-adapter> produces Message<> with those headers and payload from the converted ConsumerRecord value.


text:
Q: Parse Apache log with Python 2.7 I'm trying to read a log file from a github url, add some geographic info using the IP as a lookup key, and then write some log info and the geographic info to a file. I've got the reading from and writing to file from the log, but I'm not sure what lib to use for looking up coordinates and such from an IP address, nor how to really go about this part. I found the regex module, and by the time I started to understand it, I found out it's deprecated. Here's what I've, got, any help would be great.
import urllib2
apacheLog = 'https://raw.githubusercontent.com/myAccessLog.log'

data = urllib2.urlopen(apacheLog)
for line in data:
    with open('C:\LogCopy.txt','a') as f:
        f.write(line)

A: *

*The re module isn't deprecated, and is part of the standard library. Edit: here's the link for the 2.7 module

*Your for loop is opening and closing the file at each iteration. Probably not a big deal but it might be faster for large files to open the file once and write what needs to be written. Just swap the locations of the for and with lines.

So
data = urllib2.urlopen(apacheLog)
for line in data:
    with open('C:\LogCopy.txt','a') as f: # probably need a double backslash
        f.write(line)

becomes
data = urllib2.urlopen(apacheLog)
with open('C:\LogCopy.txt','a') as f: # probably need a double backslash
    for line in data.splitlines():
        f.write(line) # might need a newline character
        # f.write(line + '\n')

*Similar question regarding geolocation Python library
Best of luck!
Edit: added the data.splitlines() call after reading Piotr Kempa's answer

A: Well the first part is simple. Just use for line in data.split('\n') assuming the lines end with a normal newline (they should).
Then you use the re module (import re) - I hope it was still in use in python 2.7... You can extract the IP address with something like re.search(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", line), look up the re.search() function for details how to use it.
As for locating the IP geographically, it was already asked I think, try this question: What python libraries can tell me approximate location and time zone given an IP address?


text:
Q: Add "from date" and "to date" in GROUP PRICE we have a magento 1.7.0.2 and we use "group price" to set different price for registered user.
It works fine, but I would like to implement the "from date" and "to date" to automatically enable and disable promotions like special price.
I don't want to use catalogue rules because i've to menage all single product price.
Thanks

A: This question also exists on stackoverflow: "Adding a From and a To date for tier prices in admin module".
The conclusion is "this is not possible by default within, magento" and the solution is creating a custom module which listens to the sales_quote_add_item and modifies the price/applied promotions of an item added to the cart, if the current date is not in the specified range.
The question is based on the same version number of Magento (1.7) as you are using.


text:
Q: Give variable name but not its value to a function To remove tedious code i would like to create a function to simplify it.
So to change the settings that i stored in an object, I created this.
var settings = {
    color : 'red'
    //one of many settings
};
alert(settings.color); // returns red
function changeValue(property, value){
    settings.property = value;
}
changeValue('color', 'blue');
alert(settings.color); // still return red

it seems like its treated as a string instead.
And if i try this:
function changeValue(object, value){
    object = value;
}
changeValue(settings.color, 'blue');

it would only give the function the value which is 'red'.
and this:
changeValue('settings.color', 'blue');

would not work obviously.
So how do i solve this ? How do i pass down a variable to a function but not its value so it can be altered ?
Note: the function is simplified for now, but would contain a lot more magic when it works.

A: Pass the object and the name of the property that you want to change as separate arguments:
function changeValue(obj, prop, value) {
    obj[prop] = value;
}

changeValue(settings, "color", "blue");

Assuming var prop = "color" then obj[prop] is equivalent to obj.color. The first notation allows you to dynamically specify the property that should be changed.

A: when you do settings.color you get a value, rather than object. You'd have to do something like
function changeValue(object, field, value){
    object[field] = value;
}

used like
changeValue(settings, 'color', 'blue')

which may not actually reduce time for you at all..

EDIT::
I have made this function for you. But please.. Don't ever use it.
var settings = {
    color : "blue"
}

function setField(str, value){
    var args = str.split(".").reverse();
    var obj = window[args.pop()];
    while(args.length -  1 > 0)
        obj = obj[args.pop()]
    obj[args.pop()] = value;
}

alert(settings.color);
setField("settings.color", "red");
alert(settings.color);


text:
Q: \leftmark header: decreasing the distance between the chapter name and the chapter-number After compiling the following document, it seems that there are at least two white-spaces between chapter 1 and blablabla  in the header of page 3.
How I can control this distance? Increasing or decreasing it? Or reducing it to a single white-space?
   \documentclass{book}
    \usepackage{fancyhdr}
    \begin{document}

    \chapter{blablabla}
    \pagestyle{fancy}
    \fancyhf{}
    \fancyhead[EL]{\thepage\ \ Title}
    \fancyhead[OR]{\leftmark\ \ \thepage}

    \newpage
    a
    \newpage
    b
    \end{document}

A: There really is a double space as can be seen when looking at a snippet from book.cls
\@chapapp\ \thechapter. \ %

Witch introduces two spaces after the period. One way to get rid of that extra space, is patching the command \chaptermark, which is executed to update the header information when a chapter starts.
To add a little more to the answer than this short little hack, i used the alternative package scrlayer-scrpage to set the header and footer. It is very powerful.
\documentclass{book}
%\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{blindtext}
%\tracingpatches
\patchcmd{\chaptermark}{. \ }{.\ }{}{}% <- magic here
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\rohead{\leftmark\ \ \pagemark}
\lehead{\pagemark\ \ Title}
\begin{document}

\chapter{blablabla}
%\pagestyle{fancy}
%\fancyhf{}
%\fancyhead[EL]{\thepage\ \ Title}
%\fancyhead[OR]{\leftmark\ \
%\thepage}

\blindtext[20]
\end{document}


text:
Q: Center UIImage in UINavigationController I'm trying to center a background UIImage in a UINavigationController that's instantiated in code:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:mainMenuViewController];
self.window.rootViewController = navController;
UIImage *navBackgroundImage = [UIImage imageNamed:@"fancy_header_logo"];
navBackgroundImage = [navBackgroundImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
[navController.navigationBar setContentMode:UIViewContentModeCenter];
navController.navigationBar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

The image displays correctly in portrait on all devices except for the iPhone 6. The image is stored in Images.xcassets in 1x, 2x, Retina 4 2x, 3x, and iPad 2x sizes.
Any pointers or suggestions would be greatly appreciated. Many thanks in advance.
UPDATE:
I've made some progress. Taking a hint from this answer I made some changes:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:mainMenuViewController];
self.window.rootViewController = navController;
UIImage *navBackgroundImage = [[UIImage imageNamed:@"fancy_header_logo"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, -260, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

This now works in all cases except iPhone 6 (not plus) in portrait (the app does not rotate on iPhones.) Now the image is scaled larger and instead of being left justified, it is now scaled larger and is too far to the right.
For the record, the image is being used when stepping through the code running in the iPhone simulator is 640x128 at 144 ppi.
UPDATE 2:
It appears that the iPhone 6 is using the image listed as 2x (in the .xcassets file) This is the same file as used by the iPhone 4 (in the simulator.) I have tried massaging the png file so that it displays right on the iPhone 6, but makes it display incorrectly on the iPhone 4.

A: Im not sure if this is the correct answer or not but I discovered that it doesn't seem to natively show as an iPhone 6 and 6 plus application unless your app has a launch image for the bigger iPhones.
Try just adding a launch image for these devices :)

A: Check this:
UIImage *image = [UIImage imageNamed: @"logo"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
self.navigationItem.titleView = imageView;


text:
Q: Log In procedure not working in oracle 11g My table contain only two row. When i am giving empid and password of another row stil login is done. This is my procedure
CREATE OR REPLACE PROCEDURE prco_LoginCheck(Emp_Id    IN number,
                                            Cpassword In varchar2,
                                            cur_out   out Types.cursor_type) AS

BEGIN

  open cur_out for

    select count(*) from TBL_REGISTRATION a
    where a.confirm_password= Cpassword and a.emp_id=Emp_Id;

END prco_LoginCheck;

A: Aside from the fact that storing a password in a table is a horribly insecure design (you should only be storing a hash of the password plus some random salt), and the fact that it doesn't make a lot of sense to define your own weak ref cursor type rather than using the built-in sys_refcursor (unless you really need to work with ancient versions of Oracle), and that returning a cursor from a procedure seems like a really odd way to do a login rather than writing a function that returns a boolean or some indicator, the problem is one of naming conventions.
When you write the SQL statement
 select count(*)
   from TBL_REGISTRATION a
  where a.confirm_password= Cpassword
    and a.emp_id=Emp_Id;

I assume that your intention is to compare the emp_id column in tbl_registration to the emp_id parameter.  That is not actually what is happening, however.  Your unqualified emp_id is resolved as a column in the table not the parameter.  Normally, people use a naming convention to ensure that parameter names don't match column names.  I, for example, generally use a p_ prefix for parameters and l_ for local variables.  That would look something like
CREATE OR REPLACE PROCEDURE prco_LoginCheck(p_Emp_Id    IN number,
                                            p_password  In varchar2,
                                            p_cur_out   out Types.cursor_type) AS

BEGIN

  open p_cur_out for
     select count(*)
       from TBL_REGISTRATION a
      where a.confirm_password= p_password
        and a.emp_id=p_Emp_Id;

END prco_LoginCheck;

It is also possible to use your existing parameter names and just fully qualify the emp_id to force it to resolve to the parameter name
CREATE OR REPLACE PROCEDURE prco_LoginCheck(Emp_Id    IN number,
                                            Cpassword In varchar2,
                                            cur_out   out Types.cursor_type) AS

BEGIN

  open cur_out for
     select count(*)
       from TBL_REGISTRATION a
      where a.confirm_password= Cpassword
        and a.emp_id=prco_LoginCheck.Emp_Id;

END prco_LoginCheck;


text:
Q: SQL Server TSQL: Put Subsequent (date) rows into bins i have following table:
id    insertDate
1     2015-01-01
22    2015-01-02
43    2015-01-03
46    2015-01-06
124   2015-01-07

In the end i want to have a possiblity to group the rows that differ exaclty in one day so in that case
id    insertDate    groups
1     2015-01-01    1
22    2015-01-02    1
43    2015-01-03    1
46    2015-01-06    2
124   2015-01-07    2

How is this possible? I bet it is some fancy window function usage

A: This is a "gaps and islands" problem.
One approach is below. This works on SQL Server 2005+. I have assumed that insertDate is unique as per your example data.
WITH CTE
     AS (SELECT *,
                DATEDIFF(DAY, 0, [insertDate]) - ROW_NUMBER() OVER (ORDER BY ID) AS Grp
         FROM   YourTable)
SELECT [id],
       [insertDate],
       DENSE_RANK() OVER (ORDER BY Grp) AS Grp
FROM   CTE