text:
Q: Error 500--Internal Server Error java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config I am getting the following error while deploying the war file in weblogic server.I have created this by using Maven.
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
at org.springframework.web.servlet.support.JstlUtils.exposeLocalizationContext(JstlUtils.java:97)
at org.springframework.web.servlet.view.JstlView.exposeHelpers(JstlView.java:135)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:211)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3750)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3714)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2283)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2182)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1491)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:252)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

I have the jstl-1.2 in lib and jstl-1.2 in weblogic too.But getting the same exception.
I have also tried removing the jstl-1.2 from war lib folder.Even though getting the same Exception.
What could be the reason?
This is my pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>se.jo.joassivosWebApp</groupId>
  <artifactId>MApp</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>MApp Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>

 <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.4</version>
</dependency>

<dependency>
 <groupId>javax.servlet</groupId>
 <artifactId>jstl</artifactId>
 <version>1.2</version>
</dependency>

 <dependency>
 <groupId>antlr</groupId>
 <artifactId>antlr</artifactId>
 <version>2.7.7</version>
</dependency>

 <dependency>
 <groupId>commons-collections</groupId>
 <artifactId>commons-collections</artifactId>
 <version>3.2</version>
</dependency>
<dependency>
 <groupId>commons-logging</groupId>
 <artifactId>commons-logging</artifactId>
 <version>1.1.1</version>
</dependency>
<dependency>
 <groupId>dom4j</groupId>
 <artifactId>dom4j</artifactId>
 <version>1.6.1</version>
</dependency>

<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate</artifactId>
 <version>3.2.6.ga</version>
</dependency>
<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-annotations</artifactId>
 <version>3.3.0.ga</version>
</dependency>
<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-commons-annotations</artifactId>
 <version>3.3.0.ga</version>
</dependency>

<dependency>
 <groupId>org.codehaus.jackson</groupId>
 <artifactId>jackson-mapper-asl</artifactId>
 <version>1.6.3</version>
</dependency>

<dependency>
 <groupId>javax.transaction</groupId>
 <artifactId>jta</artifactId>
 <version>1.1</version>
</dependency>
<dependency>
 <groupId>log4j</groupId>
 <artifactId>log4j</artifactId>
 <version>1.2.12</version>
</dependency>

<dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-orm</artifactId>
 <version>3.1.0.RELEASE</version>
</dependency>

<dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-webmvc</artifactId>
 <version>3.1.0.RELEASE</version>
</dependency>
 <dependency>
       <groupId>com.oracle</groupId>
       <artifactId>ojdbc14</artifactId>
      <version>10.2.0.2.0</version>
</dependency>

  </dependencies>
<!--   <build>
    <finalName>MApp</finalName>
  </build> -->

<build>
        <finalName>MApp</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
                    <packagingExcludes>WEB-INF/lib/xercesImpl-2.0.2.jar,WEB-INF/lib/xml-apis-1.0.b2.jar</packagingExcludes>

                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <argLine>-XX:-UseSplitVerifier</argLine>
                </configuration>
            </plugin>
        </plugins>

    </build>

</project>

This is my war lib folder

A: On Weblogic, or Websphere , or JBoss or any other EJB container Set the dependency scope in maven for servlet-api in pom.xml to "provided". Do the same for the jstl dependency. ****They already come as part of your application server. There is absolutely no reason to package the servlets in your jar.****
Ensure they are not present in your war lib folder. If they still are you need to check for transitive dependencies. You can find them out by executing "mvn dependency:tree" from the command line.
On Tomcat or Jetty or other servlet container. jstl does not come as provided library therefore you need to deploy it as part of your WAR archive inside WEB-INF/lib. This would say that if you are using maven the scope of the dependency should be set to "compile".

A: java.lang.NoClassDefFoundError: This error will raise when there is no .class file at the time of classloader trying to load the classes dynamically at runtime.
This exception is also raised when the class file is present also. That situations are,

*

*While initializing static variables.

*Exception raised while initializing static blocks.

In your case, declare the 'provided' in your 'servlet-api' and 'jstl'. If you don't have any problem declare the same for most of the dependencies. when you are declaring a specific dependency in POM.XML you should verify the other dependencies will be compatible with it or not.

A: The problem is of weblogic.xml.I didnot add weblogic.xml.After adding the weblogic.xml with prefer-web-inf-classes tag .Now app is working fine.I have added spring and hibernate based weblogic.xml with prefer-web-inf-classes tag .

A: Basically it is looking for core taglib from jstl jar. Try adding below to your pom or replacing the existing jstl dependency:
<dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>jstl-api</artifactId>
</dependency> You can also add <version>4.0.0-b01</version> if it needs.
Hope this helps.


text:
Q: how to clearTimeout call within SetTimeout Loop condition i have an task to load multiple url in webpage. For i have array size of 10 url links but i have to navigate oly 5 URl out of it, i set Timeout for every page load one after another and load next. When its reaches 5th url i have to visit my home page but since my Array count is 10 its keep on loading 10 times
here my sample code for your reference :
for (var i = 0; i < urlResult.length; i++) {
    myVar = setTimeout(function(y) {
        if (urlResult[y] == lastUrl) {
            wait(5000)
            if (pageVist_num == Total_count) {
                console.log("cleat timeout")
                clearTimeout(myVar);
                document.getElementById("web").src = 'https://www.google.com/'
            } else {
                pageVist_num = pageVist_num + 1
                document.getElementById("web").loadURL(lastUrl);
            }
        } else {
            if (pageVist_num == Total_count) {
                clearTimeout(myVar);
                console.log("clear timeout")
                document.getElementById("web").src = 'https://www.google.com/'
            } else {
                pageVist_num = pageVist_num + 1
                document.getElementById("web").loadURL(urlResult[y]);
            }
        }
    }, i * 18000, i); // we're passing x
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: separating two networks with DMZ? I am a college student wanting to get into server and networking but I have an issue I need help with at home. I asked a question about a year ago about creating two separate networks with the same internet connection. I had a temporary fix until I ran into a problem.
Current situation:
My sister's family lives with us and they are using their own router for their own network. It is currently connected to my router (Asus RT-AC68R).
Any time I make changes to my router settings that require a restart it effects their internet.
I do gaming and currently have a 24/7 file server that I have setup on my network with VPN server on my router to access the server from the internet. I use to have three routers set up to separate the networks,
My router, and my sister's router were connected to the main router that was connected to the internet. My problem is my VPN server on my router would not work I could not connect to the VPN server from over the internet to access my file server on my network.
I changed it back so my router is the main router and my sisters is connected to mine. I am now able to use my VPN and file server over the internet but brings me back to the original issue of their network being affected by my settings.
Question:
Would it work or be a bad idea to do the three router setup again but put my router in the DMZ of the first router. This would separate mine and my sister family's networks while still putting my router out on the internet as if it was the main router thus enabling me to connect to the VPN server and access my file server or would it not work like this or be a bad idea?
Any help or advice is greatly appreciated.


text:
Q: Test if a property on an object is a single observable (and not an observableArray) I'd like to be able to iterate over the knockoutJS observable properties of an object and copy them across to another object which holds other observable properties.  The target object exists within an observableArray (in this case selected is the target and is set on an 'edit' button click).
'Item' is passed in the viewmodel which is bound to a dialog. If cancel is clicked, the item is just ignored, if ok is clicked, the data is persisted on the server, and then item properties are copied across to selected.
Currently I'm doing it like so:
function AttachCommitData(item) {
        for ( var prop in item) {
            if ( prop !== "undefined" ) {
                vm.selected[item](item[prop]);
            }
        }
    }

I'm not sure if this is the way to do it, but it throws an exception as the item holds an observableArray, and the copy to the observable fails.  Is there anyway to only iterate over the obseravables and miss anything else in the loop such as observableArrays, functions etc?
If you could advise also, if this is the best way of attaching a set of observables to another set or not.

A: I would probably use mapping plugin for this:
function attachCommitData(item){
    ko.mapping.fromJS(ko.mapping.toJS(item), vm.selected);
}

See mapping plugin documentation for details.


text:
Q: Flyway 7.7.3 seems to ignore my "callback" I am upgrading from Flyway 5.4 to 7.7.3 and ran into some issue.
 flyway -teams -url=jdbc:oracle:thin:@localhost:1521/XE "-user=xxx as SYSDBA" -password=xxx -table=flyway_schema_history_app -encoding=utf-8 -baselineOnMigrate=true migrate

(I have the teams edition license)
Flyway gives me the following error message:
**
ERROR: Unable to parse statement in /flyway/sql/incremental/Build_302_Baseline/V302_106__fosprd_INSERT_Master_eg_pocqueue.sql at line 117 col 1. See https://flywaydb.org/documentation/knownparserlimitations for more information: No value provided for variable substitution: &R.  Check your configuration. If this is not a SQLPLus variable intended to be substituted (eg. in a string literal), then you will need to add SET DEFINE OFF in the script beforehand.
Caused by: No value provided for variable substitution: &R.  Check your configuration. If this is not a SQLPLus variable intended to be substituted (eg. in a string literal), then you will need to add SET DEFINE OFF in the script beforehand.
**
This is caused by a special character "&" in the SQL statement, however, I have made sure the SQL file is using UTF-8 encoding as well as Unix return (LF).
Also, I keep my callbacks under:
bash-5.0$ pwd
/flyway/sql/callbacks
bash-5.0$ ls
afterBaseline.sql       afterEachUndo.sql       afterMigrateError.sql   afterUndo.sql           beforeEachUndo.sql
afterBaselineError.sql  afterEachUndoError.sql  afterRepair.sql         afterUndoError.sql      beforeMigrate.sql
afterEachMigrate.sql    afterMigrate.sql        afterRepairError.sql    beforeEachMigrate.sql   beforeUndo.sql

This used to be able to run on 5.4 with no issue. But it's giving me this error on 7.7.3, anyone can point me to the right direction?
Thanks

A: This is due to the changes between versions of flyway's SQLPlus support and the fat you have a teams license.
As indicated in the message, this is related to SQLPlus's variable substitution:
https://flywaydb.org/documentation/database/oracle#variable-substitution
If you are not using SQLPlus features, you could try disabling them:
https://flywaydb.org/documentation/configuration/parameters/oracleSqlPlus
but the recommended solution is to place SET DEFINE OFF in the SQL script before the offending ampersand (with the option of reverting that afterwards)


text:
Q: Laravel Model not returning properties with default value after creation In my controller after I create a new Post I return the new post in a post variable. For some reason I don't get the properties with default values back. I noticed that if I set the value to something in controller it does indeed return the properties in the payload.
public function create(Request $request)
    {
        $validatedData = $request->validate(PostValidator::$create);

        $post = new Post();
        $post->postcategory_id = $request->input('postcategoryid');
        $post->user_id = $request->input('authorid');
        $post->thumbnail = $this->uploadFile($request, 'thumbnail', config('app.defaultImage'));
        $post->video = $request->input('video');
        $post->slug = $this->slugify($request->input('title'));
        $post->url = '/publicaciones/'.$this->slugify($request->input('title'));
        $post->title = $request->input('title');
        $post->body = $request->input('body');
        $post->isVisible = false; //IF I DO THIS isVisible is returned in $post variable
        $post->save();

        $post->load(['postcategory','author']);

        return response()->json([
            'post' => $post,
        ]);

    }

A: you can say laravel works like that. default values defined in the database layer is absent in a newly created object. however you can use refresh to refresh the object before returning. and it will have the missing values then.
$post = new Post();
$post->attribute = $request->attribute;
$post->save();

$post = $post->refresh();
return $post;

or you can set default values in the model layer
protected $attributes = [
   'isVisible' => false
];

and you will have the default values when returning a newly created object.


text:
Q: Graph API: modify content of file inside directory I am trying to upload a file to some SharePoint directory using .NET. So far I can upload it to the root:
var fileItem = new DriveItem
{
    Name = "test3.txt",
    File = new Microsoft.Graph.File
            {
            },
    AdditionalData = new Dictionary<string, object>()
            {
                {"@microsoft.graph.conflictBehavior", "rename"}
            }
};

await graphClient
    .Sites["*****.sharepoint.com"]
    .Drive
    .Root
    .Children
    .Request()
    .AddAsync(fileItem);

var sites = await graphClient
    .Sites["*****.sharepoint.com"]
    .Drive
    .Root
    .Children["test3.txt"].Content.Request().PutAsync<DriveItem>(stream);

I can CREATE file inside folder:
await graphClient
    .Sites["*****.sharepoint.com"]
    .Drive
    .Root.Children["New Folder3"]
    .Children
    .Request()
    .AddAsync(fileItem);

But when I try to add content to that file(inside directory):
await graphClient
        .Sites["*****.sharepoint.com"]
        .Drive
        .Root
        .Children["New Folder3"]
        .Children["test.txt"].Content.Request().PutAsync<DriveItem>(stream);

I catch ResourceNotFoundException exception.

A: You can try using the 'ItemWithPath' method and specify the path as said in this SO thread or it would be better giving the id rather than using the Folder name or file name and use it according to this document.


text:
Q: Where find open code-source Spark-streaming Kafka I'm looking for the open code-source of Spark-streaming-kafka with scala
Please do you have an idea about it's link on Apache where can I found it ?
Thanks

A: Not sure of what you're looking for but one of those two links should help:

*

*Spark source code is available on GitHub: https://github.com/apache/spark

*spark-streaming-kafka source code can be downloaded via Maven dependency in your IDE for instance (https://repo1.maven.org/maven2/org/apache/spark/spark-streaming-kafka_2.11/1.6.3/spark-streaming-kafka_2.11-1.6.3-sources.jar)


text:
Q: Selected item not showing in DropdownButton in Flutter I need your help. I'm making a DropdownButton and I'm facing the following problem - I can't see the items that are selected in the DropdownMenuItems. I do not understand what the problem is that nothing is displayed. I'm using the [getwidget][1] package it's a GFCheckboxListTile widget - which just adds a checkbox. Please tell me how can I fix this error?
dropdown
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:getwidget/getwidget.dart';
import 'package:joyn/constants/constants.dart' as constants;

class DropdownWidget extends StatefulWidget {
  List<String> items;
  SvgPicture? icon;
  double width;

  DropdownWidget({
    Key? key,
    required this.items,
    required this.icon,
    required this.width,
  }) : super(key: key);

  @override
  State<DropdownWidget> createState() => _DropdownWidgetState();
}

class _DropdownWidgetState extends State<DropdownWidget> {
  String? selectedValue;
  bool selected = false;

  final List _selectedTitles = [];
  final List _selectedTitlesIndex = [];

  final GFCheckboxType type = GFCheckboxType.basic;

  @override
  void initState() {
    super.initState();
    if (widget.items.isNotEmpty) {
      _selectedTitles.add(widget.items[1]);
    }
  }

  void _onItemSelect(bool selected, int index) {
    if (selected == true) {
      setState(() {
        _selectedTitles.add(widget.items[index]);
        _selectedTitlesIndex.add(index);
      });
    } else {
      setState(() {
        _selectedTitles.remove(widget.items[index]);
        _selectedTitlesIndex.remove(index);
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: widget.width,
      child: DropdownButtonHideUnderline(
        child: DropdownButton(
          items: List.generate(
            widget.items.length,
            (index) => DropdownMenuItem<String>(
              value: widget.items[index],
              child: Container(
                decoration: BoxDecoration(
                  border: Border(
                    bottom: BorderSide(
                      color: constants.Colors.white.withOpacity(0.1),
                      width: 1,
                    ),
                  ),
                ),
                child: GFCheckboxListTile(
                  value: _selectedTitles.contains(widget.items[index]),
                  onChanged: (bool selected) {
                    _onItemSelect(selected, index);
                  },
                  selected: selected,
                  title: Text(
                    widget.items[index],
                    style: constants.Styles.smallTextStyleWhite,
                  ),
                  padding: const EdgeInsets.only(top: 14, bottom: 13),
                  margin: const EdgeInsets.only(right: 12, left: 2),
                  size: 22,
                  activeBgColor: constants.Colors.greyCheckbox,
                  activeBorderColor: Colors.red,
                  inactiveBgColor: constants.Colors.greyCheckbox,
                  activeIcon: SvgPicture.asset(constants.Assets.checkboxIcon),
                  inactiveBorderColor: constants.Colors.greyXMiddle,
                  type: type,
                ),
              ),
            ),
          ),
          value: selectedValue,
          onChanged: (value) {
            setState(() {
              selectedValue = value as String;
            });
          },
          icon: SvgPicture.asset(constants.Assets.arrowDropdown),
          iconSize: 21,
          itemHeight: 66,
          selectedItemBuilder: (context) {
            return _selectedTitles.map(
              (item) {
                return Row(
                  children: [
                    widget.icon ?? const SizedBox(),
                    const SizedBox(width: 8),
                    Text(
                      item,
                      style: constants.Styles.bigBookTextStyleWhite,
                    ),
                  ],
                );
              },
            ).toList();
          },
        ),
      ),
    );
  }
}

A: While the UI is need to update on DropdownMenuItem you can wrap GFCheckboxListTile with StatefulBuilder.
child: Container(
  child: StatefulBuilder(
    builder: (context, setStateSB) => GFCheckboxListTile(
      value: _selectedTitles.contains(widget.items[index]),
      onChanged: (bool selected) {
        _onItemSelect(selected, index);
        setStateSB(() {}); /// we are using StatefulBuilder's setState

       ///add your logic then
  setState(() {
    selectedValue = widget.items[index];
  });
      },

DropdownMenuItem ontap is outSide the GFCheckboxListTile therefore onChanged is not calling.  I am using onChanged from GFCheckboxListTile to update the selectedValue.


text:
Q: Get a specific file with PnP Powershell I need to get a specific file in the SitePages of a SharePoint Online site collection. I know how to get all pages with PnP (see code below), but I need only one specific.
Export & Import of all sites:
Connect-PnPOnline -url https://contoso.sharepoint.com
Get-PnPProvisioningTemplate -out template.xml -Handlers PageContents -IncludeAllClientSidePages
Connect-PnPOnline -url https://contoso.sharepoint.com/sites/anothersite
Apply-PnPProvisioningTemplate -path template.xml

I checked the .xml in Visual Studio and found elements like "PageName" and "Title" but I can't get it to work. Any ideas? I don't want to edit the complete export in Visual Studio and use that. I has to be easier right?

A: To download a specific file, use the following syntax:
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/somesite
Get-PnPFile -Url "/sites/somesite/SitePages/Home.aspx" -AsFile

The parameter -AsFile makes the command save the file to your current directory.
To upload the same file to another site collection, you would use the following:
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/anothersite
Add-PnPFile -Path .\Home.aspx -Folder SitePages


text:
Q: What am I missing to upgrade asp.net mvc .net core 2.2.0 apps to .net core 2.2.1 I have the latest version of visual studio, the sdk and runtimes for x64 and x86 version 2.2.1, but my asp.net mvc .net core applications will only recognize being 2.2.0.  I can install 2.2.1 into .net core libraries.
What do I need to change to allow my web projects to be 2.2.1 instead of 2.2.0?
(It can't be done through nuget, it provides the statement: Implicitly refrenced by an SDK. To update the package, update the SDK to which it belongs
Since the project is referencing a library with 2.2.1, I see the error: Error   NU1605  Detected package downgrade: Microsoft.AspNetCore.App from 2.2.1 to 2.2.0. Reference the package directly from the project to select a different version.)

A: According to Microsoft documentation packages Microsoft.AspNetCore.App and Microsoft.NETCore.App have special versioning semantics which is handled outside of NuGet.
Also note that specifying a version number on Microsoft.AspNetCore.App package does not guarantee that desired version will be chosen. In general, you should not explicitly specify Microsoft.AspNetCore.App version unless you have a good reason to do so (applies to .NET Core 2.1 and later).
You can read more about that here: Microsoft.AspNetCore.App metapackage
If you want to target specific SDK used in your project or solution, add global.json file to project folder (if you want to target only that specific project) or solution folder if you want to target all projects in the solution.
global.json example:
{
  "sdk": {
    "version": "2.2.103"
  }
}


text:
Q: popup form centered on desktop but not on mobil I have a page where when you click on a link and you are not logged in a form pops up to login. It works perfect on desktop and is always centered on the page but on mobil it is at the top so if I click on a link towards the bottom of the page I have to scroll all the way up to see it. My css for the form is:
div.wpcf7 {
position: absolute;
margin: 0 auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 490px;
height: 440px;
z-index: 1042;
background: #f9f9f9;
}

A: Absolute is with respect to page. Fixed is with respect to window(the viewport).
 position: fixed;


text:
Q: laika ruby no such file to load -- initializer Forgive me I am new to ruby. I am trying to install the laika website see http://sourceforge.net/apps/mediawiki/laika/index.php?title=Setting_Up_Dev_Environment-_Mac_OS_X
I have the following error
Bobs-iMac:nwe bob$sudo jruby -S rake db:migrate
(in /Applications/MAMP/htdocs/laika)
Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

but if I check my rails version
Bobs-iMac:nwe bob$ rails -v
Rails 2.3.8

How can this be?
When I comment out the line in environment.rb as the message suggests I then  get a different error message
rake aborted!
no such file to load -- initializer

What is going on?
Any help appreciated Thank you


text:
Q: List sharepoint files in a specific subfolder with Office365-REST-Python-Client I need to download all files from sharepoint in a group of subfolders, but I'm struggling to get the list of files to use the download Method.
I'm using the python library Office365-REST-Python-Client, specifically the enum_files_and_folders.py example.
The problem is my document library is too large. Then a want to enum only files in a specific subfolder.
My sharepoint structure is something like this:
https://mysite/shared documents/General/.../sheets/year/month
I want to download all xlsx files in sheets folder and subfolders, without transversing all document library structure.
Does anyone know a filter option ?
My current code is something like this:
doc_lib = contexto.web.get_folder_by_server_relative_url(relative_url)
items = doc_lib.items.select(["FileSystemObjectType"]).expand(["File", "Folder"]).get().execute_query()
arquivos_fluxo =[]
for item in items:  # type: ListItem
    if item.file_system_object_type != FileSystemObjectType.Folder:
        if "myfiles.xlsx" in item.file.serverRelativeUrl:
            print("File url: {0}".format(item.file.serverRelativeUrl))
            arquivos_fluxo.append(item.file.serverRelativeUrl)

A: i encountered a similar problem. Here's the code that I use to retrieve all files from a subfolder:
def get_all_files_from_document_library(spo_site: str, folder_name: str) -> list:
    try:
        user_credentials = UserCredential(global_settings.SYSTEM_USER_SPO, secret.SYSTEM_USER_PWD)
        ctx = ClientContext(f"{global_settings.SHAREPOINT_BASE_URL}/sites/{spo_site}").with_credentials(user_credentials)
        files = ctx.web.get_folder_by_server_relative_url(folder_name).files
        ctx.load(files).execute_query()
        file_list = []
        for file in files:
            file_list.append({"Name": file.name, "ServerRelativeUrl": file.serverRelativeUrl})

    except:
        logging.error("Could not retrieve files from folder '%s/%s'", spo_site, folder_name)
        return None
    return file_list

I used the answers posted on this github issue as a reference.


text:
Q: Android GPS - Curious cold start behavior The behavior is as follows:
Start my app 'cold', for example device powered off all day, then powered on in an arbitrary location.
The GPS will do two things: It will work as intended and I will receive location updates, OR it will simply 'sit' there.
This might be all and well, as it can take GPS hardware some time to get a fix, but here is what is bugging me:
If I open a particularly well made competitor's app that uses GPS, they get fixes immediately. If I then return to my app, all of a sudden my app is receiving updates and working properly.
Perhaps it is for them to know, and for me to figure out, but if any one has any insight they would be willing to share...
Here is my GPS code:
private void initGPS() {
    String ls = Context.LOCATION_SERVICE;
    mLocationManager = (LocationManager) getSystemService(ls);
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    criteria.setCostAllowed(true);
    mProvider = mLocationManager.getBestProvider(criteria, true);
    if (mProvider == null) {
        mHandler.postDelayed(checkGPS, 1000);
        return;
    } else {
        mHandler.removeCallbacks(checkGPS);
    }
    getGpsUpdates();
}

private void getGpsUpdates() {
    mLocationManager.requestLocationUpdates(mProvider,
            mTimeBetweenGPSUpdates, mDistanceBetweenGPSUpdates,
            locationListener);
    mLocationManager.addGpsStatusListener(gpsStatus);
}

Very simple. From log statements, it seems that things are working. getGpsUpdates() fires once as it should, however after that I get no location updates.
Thanks,
Dane


text:
Q: How to set up in-memory database in ClientDataSource? First I was using this way how to get connection and all was fine.
con = DriverManager.getConnection("jdbc:derby:memory:datab;create=true");

But now I have to change it to DataSource and how I find out derby had class ClientDataSource for this, but for the hell I can't find out how to setup that virtual DB in JUnit tests.
ClientDataSource ds = new ClientDataSource();
con = ds.getConnection();

A: Since I found this question during my googling :
The answer is to use the EmbeddedDataSource instead of the ClientDataSource and to keep the "memory:" prefix before the database name
import org.apache.derby.jdbc.EmbeddedDataSource;
...
EmbeddedDataSource ds = new EmbeddedDataSource();

ds.setDatabaseName("memory:" + "datab");
ds.setCreateDatabase("create");
ds.setUser("user");
ds.setPassword("pwd");


text:
Q: How can I search symbols with partial words in VS Code with IntelliSense? How can I search symbols (e.g. class) with partial words in VS Code and IntelliSense?
In VS Code, it's possible to look for files with partial words. For example, it's possible to locate a file this_is_my_best_class.py with file search and typing thisbest. Similar doesn't seem to work for symbols though.
Let's say you have a class called MyBestInheritedIntelliSenseClass and you want to locate that from your work space. Is there a way to look for a symbol with typing something like BestIntelSen instead of typing e.g. the whole MyBestInheritedIntelliSen?
I'm using VS Code (v1.41.1, Windows) and Python extension (v2020.1.58038).
I have used PyCharm for a very long time and now changed to VS Code to see what it is about. Looking for symbols as explained above is how I would do it in PyCharm and - as an old habit - would use similar with VS Code. What is the right way to do it?

Here's the same with screenshots. This is the class I could look for (VS Code):

This is what I would like to type (VS Code):

This is what I would like to see it (this is from PyCharm):

And this is the same working for files in VS Code:

A: For the Go to Symbol in Editor... command (the one where the search input starts with "@"), fuzzy searching is purportedly supported by VS Code. See Allow fuzzy result on searching symbol in file #62435:

This is now actually working. Since a few months outline uses the same fuzzy score algorithm IntelliSense sense does and the samples should you have listed should now work. please file individual issues for cases that don't work well. - jrieken

For the Go to Symbol in Workspace command (the one where the search input starts with "#"), fuzzy searching needs support on a per-extension basis. This is mentioned in at least two issue tickets on the VS Code GitHub repo:
In Ctrl+T (Go to Symbol in Workspace...) does not support fuzzy search
#156865

Previously, #106788, #62435, #33746. I think we just pass the query over to extensions and they have to support this to return the results, its not on us. This is different for symbol search in the file where we get all results iirc. - bpasero

And in Add fuzzy search to search by symbol
#33746:

The sorting and ranking (in the UI) is actually using our fuzzy search logic but that only helps when the extension that provides the data uses a similar relaxed algorithm. In the jsdoc we have the following statement

*

*The query-parameter should be interpreted in a relaxed way as the editor will apply its own highlighting and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the characters of query appear in their order in a candidate symbol. Don't use prefix, substring, or similar strict matching.

There is not much more VS Code can do as it is only rendering results that extension providing. Therefore closing as 'caused by extension' and with a pretty please to file this in the context of each extension. - jrieken

Here are a few of those extension-specific issue tickets for this feature that I was able to find through related GitHub links and by googling "github issues "go to symbol" workspace fuzzy" and "github issues "go to symbol in workspace" fuzzy":

*

*microsoft/python-language-server: "Open symbol by name" not fuzzy matching #697

*microsoft/pylance-release: Symbol search matching in middle of word, or with fuzzy matching
#362

*microsoft/vscode-cpptools: Allow "fuzzy" substring symbol search, similar to Go To File (CTRL+P) and Completion
#2751

*bmewburn/vscode-intelephense: Fuzzy search for "Go To Symbol in Workspace"? #21 and Wider fuzzy search in "Go to symbol in workspace"? #2205

*microsoft/vscode-go: Fuzzy search of workspace symbols #2950

*rubyide/vscode-ruby: Go To Symbol In Workspace not working with fuzzy search #653


text:
Q: What defines a hyper carry? In League of Legendes, what defines a hyper carry?
What the champions can fit the role and why it isn't used more frequently?

A: Hyper-carry is actually an old/obsolete concept that no longer applies.
Basically, regardless of how well/poorly a champion was doing, after hitting the 50-55 minute mark, certain champions become incredibly strong.
This was prevalent during season 1/early or pre-season 2. Champions like Olaf, Irelia and especially) Master Yi could have catastrophic impact in teamfights/duels once they finish the bulk of their build (for Irelia that meant Trinity+Survivability; for Yi it meant Attack Speed + Life steal; and I never played Olaf back then so I can't comment) and regardless of how hard they had been shut down throughout the game, they will tear you apart after that point.
Basically what I'm trying to say is that Irelia could jump in vs 5, kill 2 and be on the verge of killing the 3rd before being shut down. And when I say jump in vs 5, I mean SOLO vs 5; so you can imagine.
Item and champion balancing has taken care of that though.
Bit of nostalgia: at the time when i was playing Irelia, the phrase 'better nerf Irelia' was already lol-lingo so you can imagine how incredible she was.

A: Well, I don't know about "hyper", but if it's similar to hard carry - carry, who can carry hardest with full inventory and max lvl, I think it would be Tristana. She can easily reach max as with less as items, her range max lvl is awesome and she has escape. You just stand behind your team and kill enemies with max as.

A: A "Hyper Carry" by definition is someone that scales so well into Late Game, that he becomes unstoppable.
In LoL, there are no True Hyper Carries, due to the fact that all carries can be focused and shut down at some point, although if we look at Vayne, she can be defined as a "Hard Carry" (amongst others) due to the fact that she reaches a higher peak at end game (with her True Damage, which scales with ATK speed, which you can find on the common ADC items such as SotD and Phantom Dancer)
There are two exceptions, mainly due to the fact that a fed champion "Can be shut down by CC".
This does not apply to Irelia and Olaf. Once one of these has an advantage in gold and levels (aka "fed"), they are very VERY hard to stop, mainly due to their damage output, tankiness, sustain, and immunity to CC.
So, conclusion:

*

*LoL has "No Hyper Carries" (Faceless Void waves Hello)

*LoL has several champions with a higher potential when fed. (Olaf, Irelia for example)

*LoL also has simple carries that naturally reach a higher peak at end-game than other, known as "Hard Carries" or "Late Game Carries". (Vayne, Kog'maw and others)

Additional details:
Due to popular demand, I am now apparently forced to list the most dangerous champions to feed.

*

*Irelia - Heavy CC reduction, innate tankiness and regeneration, True damage. Very hard to stop after she has an advantage.

*Olaf - Short CC Immunity + tankiness buff, heavy True Damage on demand, very VERY tough once at an advantage (the less Current HP he has, the faster he attacks. The more MAX HP he has, the more damage he deals)

*Farm-carries: Nasus, Sion and Veigar - Long story short, they have good CC and an INFINITE stat potential due to the fact that their stats scale with their farm (Nasus Q Bonus Damage, Sion HP (with Atma's, AD as well), Veigar Ability Power)

Gimme moar and I'll fill the list


text:
Q: Can I set multi-on-select on grid panel cells in ExtJS? Can I set multi-on-select on grid panel cells?
Hey guys, I'm fairly new to ExtJS and I was wondering if there is a way to multi-on-select grid CELLS or give the illusion of multi-on-select. By "illusion" I mean to change the CSS of the individual cell dynamically on click so that it looks like it has remained toggled.
The following is code to my Grid window
Code:
Ext.create ('Ext.window.Window' , {    title: this.id,
    width: 500 ,
    closeAction: 'hide',
    height: 500 ,
    modal: true,
    centered: true,
    items: [{
        xtype: 'gridpanel',
        sortable: false,
        allowDeselect: true,
        columnLines: true,
        header: false,
        sortableColumns: false,
        border: false,
        columns: [{
            xtype: 'gridcolumn',
            dataIndex: 'ID',
            text: 'ID',
            flex: 2
        },
        {
            xtype: 'gridcolumn',
            dataIndex: 'Title',
            text: 'Title',
            flex: 3
        },
        {
            xtype: 'gridcolumn',
            dataIndex: 'Beginner',
            text: 'Beginner',
            flex: 5
        },
        {
            xtype: 'gridcolumn',
            dataIndex: 'Intermediate',
            text: 'Intermediate',
            flex: 5
        },
        {
            xtype: 'gridcolumn',
            dataIndex: 'Advanced',
            text: 'Advanced',
            flex: 5
        }],
        // One header just for show. There's no data,
        store: Ext.getStore('disciplinesStore')
    }]
    selModel: Ext.create('Ext.selection.CellModel', {
            allowDeselect: true,
            listeners: {
            select: {
                  fn: me.onCellModelSelect,
                  scope: me
                    }
              }
        })
}).show ();

And then
onCellModelSelect: function(cellmodel, record, row, column, eOpts) {

        if(column === 2){
            stuff = 'Beginner';
        }else if(column === 3){
            stuff= 'Intermediate';
        }else if(column === 4){
            stuff = 'Advanced';
        }
        Ext.Msg.alert('asd',record.get(stuff));
    }

A: I realized an alternate way of solving this;
Instead of applying a cell selector which doesnt allow mode: 'MULTI', divide each of the columns into individual tables and apply a row selector or check box selector to them and set that to MULTI. Works like a charm.
As a reference for others with the same problem, it now successfully looks like this

The code of the Beginner, Intermediate and Advanced columns was replace by individual tables with a row selector function as follows
{
 xtype: 'gridpanel',
 flex: 2.5,
 autoRender: false,
 id: 'thegrid',
 style: 'white-space:normal',
 width: 723,
 header: false,
 title: 'My Grid Panel',
 allowDeselect: true,
 columnLines: true,
 sortableColumns: false,
 store: 'disciplinesStore',
 columns: [
     {
          xtype: 'gridcolumn',
          dataIndex: 'Beginner',
          text: 'Beginner',
          flex: 5
      }
           ],
           selModel: Ext.create('Ext.selection.RowModel', {
           allowDeselect: true,
           mode: 'SIMPLE',
           listeners: {
               deselect: {
                     fn: me.onRowModelDeselect,
                     scope: me
                     },
           selectionchange: {
                     fn: me.onRowModelSelectionChange,
                     scope: me
                     }
               }
         })
   }


text:
Q: Find $x,y,z \in \mathbb Z$ , $1Find $x,y,z \in \Bbb Z, 1<x<y<z$ and $xyz - 1 = t(x-1)(y-1)(z-1)$.

A: Rearranging, we have
$$xyz-1=zt(x-1)(y-1)-t(x-1)(y-1)$$
$$z\left(xy-t(x-1)(y-1)\right)=1-t(x-1)(y-1)$$
$$z=\frac{1-t(x-1)(y-1)}{xy-t(x-1)(y-1)}=\frac{t(x-1)(y-1)-1}{t(x-1)(y-1)-xy}=\frac{t-\frac{1}{(x-1)(y-1)}}{t-\frac{x}{x-1}\frac{y}{y-1}}$$
Now, since $z>y>x>1$, we have $z \geq 4$, and we must have
$$\frac{t-\frac{1}{(x-1)(y-1)}}{t-\frac{x}{x-1}\frac{y}{y-1}}\geq 4$$
Looking at the terms in the denominator, we have $\frac{x}{x-1} \leq \frac{2}{1}, \frac{y}{y-1} \leq \frac{3}{2}$, since $x\geq 2, y\geq 3$
Thus $\frac{x}{x-1}\frac{y}{y-1} \leq 3$. If $t>3$, the denominator is positive, and we have
$${t-\frac{1}{(x-1)(y-1)}}\geq4\left({t-\frac{x}{x-1}\frac{y}{y-1}}\right)$$
$${-\frac{1}{(x-1)(y-1)}}\geq\left({3t-4\frac{x}{x-1}\frac{y}{y-1}}\right)$$
However, if $t>3$, the RHS is strictly nonnegative, while the LHS is strictly negative. Thus, we reach a contradiction.
Edit: In fact, you can improve the bound slightly and go some way to solving the problem for integer $t$ by considering the following cases.
Firstly, for $t=3$, you can show that
$$3t-4\frac{x}{x-1}\frac{y}{y-1}$$
for $x\geq3$. Therefore, for $t=3$, it suffices to check the cases where $x=2$.
Now when we have $t=3, x=2$, the equation simplifies to $(y-3)(z-3)=5$, corresponding to the solution $(x,y,z,t)=(2,3,8,3)$.
Similarly, for $t=2$, it suffices to check the cases $x=2, 3, 4$ or $(x,y)=(5,6)$.
Considering the equation modulo $2$, we can eliminate the cases $x=2,4$. For $x=3$, the equation simplifies to give $(y-4)(z-4)=11$, corresponding to the solution $(x,y,z,t)=(3,5,15,2)$. Finally, we substitute $(x,y)=(5,6)$ into the original equation and obtain $30z-1=40(z-1)$, which has no integer solutions.
Finally, for $t=1$, we can simplify the original equation to the following
$$xy+yz+zx=x+y+z$$.
But we have $$xy+yz+zx\geq3x+4y+2z>x+y+z$$ Thus there are no solutions to the equation when $t=1$.
To summarize, the two integer solutions for integer t are $(x,y,z,t)=(2,4,8,3) or (3,5,15,2)$.


text:
Q: $\{a_n\}$ is a sequence of nonnegative real numbers satisfying $a_{n+1} \leq a_n + \frac{(-1)^n}{n}$. Prove convergence.
Let $\{a_n\}$ be a sequence of non-negative real numbers satisfying $a_{n+1} \leq a_n + \frac{(-1)^n}{n}$. Prove $\{a_n\}$ converges.

It is easy to show $a_n$ is bounded by $a_1$ plus the alternating harmonic series.  By similar means, it is easy to provide a small upperbound on the difference $a_m - a_n$ for $m > n$.  However, I'm having difficulty giving a lower bound for this difference to give us an absolute bound.  I'm now searching for alternative approaches.

A: Define $s_n = \sum_{k=1}^n \frac{(-1)^{n}}{n}$, and then define $b_n = a_{n+1}-s_n$. Note that $s_n$ is bounded (because it converges), and $a_n$ is also bounded (since $0 \leq a_n \leq a_1+s_n$). Therefore $b_n$ is bounded.
Note that $b_n = a_{n+1}-s_n \leq a_n +\frac{(-1)^n}{n}-s_n = a_n-s_{n-1}=b_{n-1}$. Thus $b_n$ is decreasing.
Since $b_n$ is bounded and decreasing, it converges. Since $b_n$ and $s_n$ are convergent, their sum $a_{n+1}=b_n+s_n$ also converges. Thus $a_n$ converges.

A: Probably it is easier to show $\{a_n\}$ converges by showing that $\limsup_{n\to\infty}a_n = \liminf_{n\to\infty}a_n$.  I'll give a sketch below: I think you'll be able to fill in the details.
Since $a_n$ consists of nonnegative real terms, the $\liminf$ is finite, so for every $\epsilon > 0$ and for every $N$, you can find an $n>N$ such that $a_n - \liminf_{n\to\infty} a_n < \frac{\epsilon}{2}$.  Also, by the convergence theory for alternating series, you can choose an $N$ such that $\left|\sum_{k=n}^m \frac{(-1)^k}{k}\right|  < \frac{\epsilon}{2}$ for all $n > N$.
Now, using your reasoning, $a_m \le a_n + \left|\sum_{k=n}^m \frac{(-1)^k}{k}\right| < \liminf_{n\to\infty} a_n + \epsilon$.  Taking the $\limsup$ now and since $\epsilon > 0$ was arbitrary, you can find that $\limsup_{n\to\infty}a_n \le \liminf_{n\to\infty} a_n$.  This implies that the $\limsup$ and $\liminf$ are equal, so $a_n$ converges.


text:
Q: How do I get all the properties and methods of a DOM element I can get all the properties and methods of a DOM element in the following way
var e = document.createElement('div')
let arr = []
for(let key in e){
  arr.push(key)
  console.log(key)
  //cloneNode
  //...
}

But I want to know why the following methods are not available?
const arr = Object.key(e)
//result: []

const arr2 = Object.getOwnPropertyNames(e)
//result: []

why?
Assuming that:
How do I get all the properties and methods of a DOM element and store them in an array

A: As VLAZ mentioned, many of those properties you want to retrieve come from the prototype chain. In order to store all of them in an array, we will actually need to loop through the prototype chain using recursion.
Using recursion will allow us to create a simple function we can use to quickly retrieve all available properties and methods for any node or object without having to set up a for..in loop each time. Here is how I would achieve this:

var e = document.createElement('div');

const getAllProperties = (e, props = []) => e.__proto__ ? getAllProperties(e.__proto__, props.concat(Object.getOwnPropertyNames(e))) : [...new Set(props.concat(Object.getOwnPropertyNames(e)))];

const divProps = getAllProperties(e);

console.log(`ALL ${e.constructor.name} properties (${divProps.length})`, divProps);

You could even take this one step further and return each property and method available along with the values associated with keys by mapping them back to the original node/object in a new key-value object:

const e = document.createElement('div');

const getAllProperties = (o, e = o, props = []) => e.__proto__ ? getAllProperties(o, e.__proto__, props.concat(Object.getOwnPropertyNames(e))) : Object.fromEntries([...new Set(props.concat(Object.getOwnPropertyNames(e)))].map(prop => [prop, o[prop]]));

const divProps = getAllProperties(e);

console.log(`ALL ${e.constructor.name} properties (${Object.keys(divProps).length})`, divProps);

A: It is because these built-in properties of a DOM object are enumerable but are not own properties. In fact these properties are inherited properties. If a property is enumerable but not own-property propertyIsEnumerable method will give false.

Observe the example below:

let inp = document.getElementsByClassName('someclass')[0]
console.log(inp.propertyIsEnumerable('onclick'))
<input type='range' class='someclass' min='0' max='100' />

As the output of the above code snippet gives out false, that means the property onclick is enumerable but not an own property. Any enumerable properties appear in for...in loop. But only enumerable and own properties appear in Object.keys method. That is why you get the value in for...in loop but not with Object.keys

A: I am assuming you only need the keys and not their values.
First, confirm if the var e as you defined below is indeed an object.
var e = document.createElement('div')

Second, the correct method that returns an array of a given object's own enumerable property names, iterated in the same order that a normal loop would is below
Object.keys(e)

MDN link for reference
If you refer to the MDN docs you will find the below example
const object1 = {
  a: 'somestring',
  b: 42,
  c: false
};

console.log(Object.keys(object1));
// expected output: Array ["a", "b", "c"]


text:
Q: Overloading a generic extension method I have a problem overloading an extension method.
I have two extension Methods:
Method A - For standard objects:
public static bool HasChanged<T>(this T obj1, T obj2, Func<T, T, bool> equalityExpression)

Method B - For IEnumerables:
public static bool HasChangedList<T>(this IEnumerable<T> obj1, IEnumerable<T> obj2, Func<T, T, bool> isEqualExpression)

But I would like to give them both the same names, that is currently not working, cause IEnumerables are objects aswell, so the compiler isnt able to decide whether to use the first one or the second one on an IEnumerable.
I am sure, its not possible to let first method take all object but an IEnumerable, so is there another way around?

A: (Not really a solution, but too long for a comment. Hopefully, one of the C# spec gurus will show up and tell us why overload resolution works like this in this particular case.)
If

*

*you qualify the parameters of your equalityExpression or if

*the inner type of the IEnumerable can be inferred from the lambda expression,

it should work fine:
class Program
{
    static void Main(string[] args)
    {
        var array = new[] { 1, 2, 3 };

        // uses the IEnumerable overload -- prints false
        Console.WriteLine(array.HasChanged(array, (int x, int y) => x == y));

        // uses the IEnumerable overload -- prints false
        Console.WriteLine(array.HasChanged(array, (x, y) => x >= y));

        // uses the generic overload -- prints true
        Console.WriteLine(array.HasChanged(array, (x, y) => x == y));

        Console.ReadLine();
    }
}
static class Extensions
{
    public static bool HasChanged<T>(this IEnumerable<T> obj1, IEnumerable<T> obj2, Func<T, T, bool> isEqualExpression)
    {
        return false;
    }
    public static bool HasChanged<T>(this T obj1, T obj2, Func<T, T, bool> equalityExpression)
    {
        return true;
    }
}


text:
Q: Unable to edit C# code in Views while debugging using Visual Studio 2015 I have been testing single version of Visual Studio 2015 (from the first CTP to CTP6), and while it's nice, the one thing that bugs me the most is that I am no longer able to edit C# code within views while debugging. I am able to copy paste code in, but once it's in, I can't delete it or change it unless I break all threads or stop debugging.
I've not found anything on Google or MSDN forums - hopefully someone here may know why.
Has this feature been disabled until the full release of VS2015, is it buggy, or is it related to my setup? I've tried running in safe mode, reinstalling, etc. I've tried it on numerous PCs, all with the same result.

A: This issue has been fixed in Visual Studio 2015 RC. Seems it was disabled (either on purpose or temporarily because it wasn't complete in the CTP)


text:
Q: Convert JKS file to BKS or create BKS file I want to connect server with ssl in android, I used from JKS, but I can not use JKS in android, I must change jks to bks, how can create bks file, I used from below order for conver jks to bks file :
"keytool -importkeystore -srckeystore mytruststore.jks -destkeystore mytruststore.bks -srcstoretype JKS -deststoretype BKS -srcstorepass changeit -deststorepass changeit -provider org.bouncycastle.jce.provider.BouncyCastleProvider"
But I could not, can I use open ssl software? How can resolve my problem?
Best Regards

A: The easier is using program "KeyStore Explorer" -> http://keystore-explorer.org/downloads.html
From Tools - Change KeyStore Type - BKS
Regards

A: You can use portecle to create BKS format key for Android

A: The correct command should looks like :

keytool -importkeystore -srckeystore testkeys -srcstoretype JKS
  -srcstorepass passphrase -destkeystore testkeys.bks -deststoretype BKS -deststorepass password -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath
  C:\Personal\Work\lib\bouncycastle\bcprov-jdk15on-152.jar

You need to supply the provider path so that it can find it when doing conversion.


text:
Q: Imitating @keyframes rule using Javascript only I'm trying to create a function that uses percentage to get a number.
The idea is to have something like this:
0%: 100px
50%: 200px
75%: 210px
So when I run my function at a percentage like 25% it blends 0 and 50 together, same for above 50%.
It sounds kind of complicated, the overall idea is to create something using JS only that will ease the numbers going from 0 to 100%
I've tried using regular percentage calculation, yet it doesn't really work for 3 or more variables.

A: So if you don't mind I've taken the liberty of turning your percentage into a JSON object:
let input = {
  0: 100,
  50: 200,
  75: 210,
};

We can then do something like this if we assume percentages are always whole numbers:
let output = {};
let previous = null;
// for each whole percent
for(let keyPercent in input)
{
  // cast to number
  let currPercent = parseFloat(keyPercent);
  // get value of percent
  let currValue = input[currPercent];
  if (currValue != null) { // if value is present
    if (previous != null) { // and previous value is not null
      // find the step size (valDiff) / (percentDiff)
      let step = (currValue - previous.value) / (currPercent - previous.percent);
      // count to multiply by step
      let count = 0;
      // this produces the percent value for every step between previous.percent and currPercent
      for (let prevPercent = previous.percent; prevPercent <= currPercent; prevPercent += 1) {
        output[prevPercent] = previous.value + (step * count);
        count += 1;
      }
    }
    // set previous value
    previous = { percent: currPercent, value: currValue };
  }
}
console.log(output);

this outputs something along the lines of:
0: 100
1: 102
2: 104
...
48: 196
49: 198
50: 200
51: 200.4
52: 200.8
...
73: 209.2
74: 209.6
75: 210

Let me know if you need any clarification.
Note: comments are made in code


text:
Q: Rhombus in layers tikz Is there an way to plot something like

with tikz? (I mean other than carefully drawing each rhombus so that they do not intersect).

A: Yes, there is. You can install an orthographic projection with the perspective library, and project on the xy planes with the 3d library. The distance between the planes can be controlled by adjusting the view angles, and introducing a prefactor for \Z in canvas is xy plane at z=-\Z.
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3d,perspective}
\begin{document}
\begin{tikzpicture}[3d view={20}{12}]
\foreach \Z in {0,...,4}
{\begin{scope}[canvas is xy plane at z=-\Z,transform shape]
 \ifnum\Z>0
 \draw (0,0) grid[step={pow(2,2-\Z)}] (4,4);
 \fi
 \draw[semithick,red] (0,0) coordinate(p\Z) rectangle (4,4);
\end{scope}
\path (p\Z) node[left]{$\mathcal{D}_{\Z}(Q)$};}
\end{tikzpicture}
\end{document}


text:
Q: enums in SQL Server database Is there a better or easier way to store the enums (Enumerations available in programming languages like C#) in SQL Server database other than simply creating a lookup table (with Id, code and name as columns) for each of them (especially when there are very few rows in each of those tables)? I found an article that suggests creating just one lookup table for all enumerations and the approach is criticised by some people in comments saying it violates referential data integrity. if at all the enumeration is used by only one table, is it a good practice to use some predefined codes and then add a constraint for them (may be using extended properties)?

A: *

*Personally, I like to define one lookup table per enum, because it is a kind of documentation as well. If someone wants to know what an id stands for, he would find it easily in a table. Looking for this information in a column constraint is not evident.

*It is also much easier to add new values in a table than in a constraint.

*If you create a database diagram, individual lookup tables appear more logical.

*You can add additional information to individual lookup tables besides id and text, if required (like a comment, a sort column, some sort of flag etc.).

*And as you have said, it is better for referential integrity
However; if you are using an o/r-mapper with the code-first approach, using enums provided by the programming language feels quite natural. This is because you are not designing a database but an object model. The o/r-mapper creates the database automatically for you.

A: As changing the enum inside your code will also require to release a new version of your application, I'd go for no lookup table at all, but only add a check constraint to the column in question.
If you however need to store localized names of the enum in the database, then I'd go for one lookup table for each enum.
The "one true lookup table" isn't going to give you any advantages.
Edit: if you need to dynamically retrieve the enum values (e.g. for a dropdown) or need to find out which values are allowed, then using lookup tables is probably better for you.

A: Using the same table for several look-ups can come back to haunt you. One example is creating an Indexed View. This can help with performance if you have several fields where you want to display the lookup value, but SQL Server (at least 2005) won't allow you to reference the same table more than once (If this has been fixed, I would really like to know how to go about it because I could really use it in a current application with a single lookup table.).
One of your lookups may require an additional field, and by using one table, you'll have a lot of unecessary nulls. Indexing can be more flexible with separate tables. What if the new field needs to be required for one particular type of lookup? SQL Server will do well with a constraint, but when thrown in the same table a little more complexity is going to be needed.
You may not have any of these issues right now. I just don't see an advantage to a single table, but some apps like to have a dynamic way to generate lookup lists and won't create a new table for each one.


text:
Q: The ratio of the volume of a trihedron in a ball to the volume of that ball
In $\mathbb{R}^3$ consider the convex body defined as
  $$C=\left\{(x, y,z): x \geq 0, y \geq 0, z-x-y \geq 0\right\}.$$

Let $B(0,r)$ denote the open ball of radius $r>0$ with the center at zero. I am thinking about the following questions:
a)  Is it true that the ratio $\frac{V(C\cap B(0,r))}{V(B(0,r))}$ does not depend on $r$?
(My conjecture is that this is not necessarily so.)
b)  If a) is not true then is it possible to show that the ratio $\frac{V(C\cap B(0,r))}{V(B(0,r))}$ is bounded from below by a positive constant for any $r>0$?
(My conjecture would be yes but I don't know how to show this.)
c)  Can the conclusion either in a) or b) be reached for any convex body $C$ with non-empty interior in $\mathbb{R}^3$ obtained by the intersection of a finite number of half-spaces containing $(0,0,0)$?
I would greatly appreciate any hints on how to possibly approach these questions.

A: As achille hui explained, the scaling transformation $x\mapsto \frac{x}{r}$ can be used to answer this, and in greater generality.
Let $C$ be any cone, meaning a set such that $x\in C\implies rx\in C$ for all $r>0$. All sets $C$ you consider are cones in this sense.
The scaling transform $x\mapsto x/r$ maps $C\cap B(0,r)$ onto $C\cap B(0,1)$. The Jacobian determinant of this transform is $r^n$. Hence,
$$\frac{\operatorname{vol}(C\cap B(0,r)}{\operatorname{vol}(C\cap B(0,1)} = r^n$$


text:
Q: Why are my Django form fields not rendering in the template? I'm receiving no errors and everything seems fine but the fields to my form will not show up.
My form:
from django import forms

class ContactForm(forms.Form):
    name = forms.CharField(required=False, max_length=100, help_text='100 characters max')
    email = forms.EmailField(required=True)
    comment = forms.CharField(required=True, widget=forms.Textarea)

My view:
from .forms import ContactForm

def contact(request):
    form = ContactForm(request.POST or None)
    if form.is_valid():
        print(request.POST)

    context = {'form': form}
    return render(request, 'contact.html', context)

contact.html template:
<form method="POST" action=""> {% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" class="btn btn-default" />
</form>

base.html template:
{% block content %}
{% endblock content %}

{% include "contact.html" %}
</div>

What am I missing? The template housing the form is not surrounded by any block tags because the template is being {% include[d] %} into my base.html.
Additional details: The form and view are in their own separate 'contact' app, and I haven't configured any urls for the contact app as I planned on simply including the template into base.html
Edit--adding urls config:
main urls.py for the project:
urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^', include("projects.urls", namespace='projects')),
]

urls.py for my 'project' app:
urlpatterns = [
    url(r'^$', projects_home, name='home'),
    url(r'^(?P<slug>[\w-]+)/$', project_detail, name='detail'),
]

As for the 'contact' app, I have not configured any urls--would this be wrong? I thought I'd be able to simply make the views/form(as displayed in original post) for the 'contact' app and bring the form into my templates.


text:
Q: C# Breakpoint does not hit when there is CR:CrystalReportViewer My web app needs to generate reports from database.
I used Crystal Reports, but including it my page disables the debug (in which I cannot hit the breakpoint)
While redirecting to a new page(that holds my crystalreport) works as a workaround.
I still want to know why this happens, and make it work.
Things I've tried:

*

*Reinstall crystal report

*Enabled Optimize Code from Build Project Properties

This is the CrystalReportViewer from my aspx.page
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"/>

Running in:

*

*Visual Studio 2015

*IIS 10 (Full Installion)

*Windows 10

Additional Info:

*

*There are no errors, clicking a button with a breakpoint on the onclick event does not hit the breakpoint.

*If I delete the CrystalReportViewer, debugger hits the breakpoint

A: Try to attach to the CR process too.


text:
Q: Is it possible to use a parameter for LIKE / NOT LIKE I am attempting to pass parameters for LIKE / NOT LIKE and the % signs to make a dynamic query that runs based on what is passed from the application.  I get an error though as TSQL is confused about the parameter for like/not like as its not Boolean.  Is it possible to do it this way or am I going to have to write multiple if statements to check to see what parameters are being passed.
@fullName varchar(100), @SrchCriteria1 varchar(15), @SrchCriteria2 varchar(15),
@fullName1 varchar(100), @SrchCriteria3 varchar(15), @SrchCriteria4 varchar(15),
@fullName2 varchar(100), @SrchCriteria5 varchar(15), @SrchCriteria6 varchar(15),
@qualifer varchar(10), @qualifer1 varchar(10), @qualifer2 varchar(10)

SELECT d.*
FROM   defendants_ALL d, #tmpFullname t1, #tmpFullname1 t2, #tmpFullname2 t3
WHERE  d.combined_name + @qualifer + @SrchCriteria1 + t1.Item + @SrchCriteria2
and  d.combined_name + @qualifer + @SrchCriteria3 + t2.Item + @SrchCriteria4
and  d.combined_name + @qualifer + @SrchCriteria5 + t3.Item + @SrchCriteria6

EXEC uspJudgments @qualifier = 'LIKE', @qualifier1 = 'LIKE', @qualifier = 'NOT LIKE', @fullName = 'johns', @fullName1 = 'jim,j.', @SrchCriteria1 = '%', @SrchCriteria2 = '%',  @SrchCriteria3 = '%', @SrchCriteria4 = '%', @fullName2 = 'johnson', @SrchCriteria5 = '%', @SrchCriteria6 = '%'

So that should return all combinations of jim johns and j. johns but will not include jim johnson and j. johnson.  I know that is a rare combination but I couldn't think of a better one ATM that is more common.
Dynamic SQL:
DECLARE @Query NVarChar(1024)
SET @Query = 'SELECT d.* FROM defendants_ALL d, #tmpFullname t1, #tmpFullname1 t2, #tmpFullname2 t3'  +
'WHERE d.combined_name' + @qualifier + @SrchCriteria1 + 't1.Item' + @SrchCriteria2 +
' and d.combined_name' + @qualifier + @SrchCriteria3 + 't2.Item' + @SrchCriteria4 +
' and d.combined_name' + @qualifier + @SrchCriteria5 + 't3.Item' + @SrchCriteria6

A: LIKE accepts an expression for the pattern, e.g. d.combined_name LIKE @SrchCriteria.
You are attempting to assemble a dynamic query.  To do so, you need to create the entire query in a string and then use EXECUTE:
declare @Query as NVarChar(1024) = 'SELECT d.* FROM ...' +
  'WHERE d.combined_name ' + @qualifer + @SrchCriteria1 + t1.Item + @SrchCriteria2 +
  '...'

The statement may be assembled in several steps before being passed to EXECUTE.


text:
Q: Is a relation from a set $A$ to a set $B$ always a proper subset of $A\times B$? Is a relation from a set $A$ to a set $B$ always a proper subset of $A\times B$? Or, is it possible that the relation covers the entire set $A\times B$?

A: It is entirely valid to have a relation that relates every element of $A$ to every element of $B$.
It can even have fancy properties -- for example if $B$ is a singleton set, the relation $A\times B$ will be a function!

A: Recall that the definition of a relation $R$ between two sets $A$ and $B$ is a subset $R \subseteq A \times B$ so relations are not always a proper subset of $A \times B$.
For example, given $A = \{a,b,c\}$ and $B = \{d,e,f\}$, we have $R = \{(a,d),(a,e),(a,f),(b,d),(b,e),(b,f),(c,d),(c,e),(c,f)\}$ which covers the entire set $A \times B$.

A: If either $A$ or $B$ are empty, then $A\times B=\varnothing$. In that case there is only one relation between the two sets. The empty relation. And there are certainly no proper subsets to $A\times B$.


text:
Q: Auto-correlation in saga for Requst/Reply I wanted to ask, do I understand it correctly that thanks to this https://github.com/rebus-org/Rebus/issues/105 when I do saga for Request/Reply I can leave ConfigureHowToFindSaga empty?
If it's true it would be nice to mention it in Wiki page, as well as the need for registering saga in adapter :)
The code below seems to work, could you please see if it's ok?
namespace ConsoleApplication1
{
    class Program
    {
        static IBus bus;
        static void Main(string[] args)
        {
            var adapter = new BuiltinContainerAdapter();

            adapter.Register<SampleSaga>(() => new SampleSaga(bus));

            bus = Configure.With(adapter)
                             .Logging(l => l.ColoredConsole())
                             .Transport(t => t.UseMsmq("enpoint1", "endpoint1_errors"))
                             .MessageOwnership(x => x.FromRebusConfigurationSection())
                             .Sagas(x => x.StoreInMemory())
                             .CreateBus()
                             .Start();

            bus.SendLocal(new SampleMessage() { Test = "Hi there" });
        }
    }

    class SampleSaga : Saga<MessageHolder<SampleMessage>>,
                                           IAmInitiatedBy<SampleMessage>,
                                           IHandleMessages<Response>
    {
        IBus bus;

        public SampleSaga(IBus bus)
        {
            this.bus = bus;
        }

        public override void ConfigureHowToFindSaga()
        {
        }

        public void Handle(SampleMessage message)
        {
            Data.Message = message;
            bus.Send(new Request());
        }

        public void Handle(Response message)
        {
            Console.Write(string.Format("Response arrived. Holded message: {0}", Data.Message.Test));
            MarkAsComplete();
        }
    }

    class MessageHolder<T> : ISagaData
    {
        public Guid Id { get; set; }
        public int Revision { get; set; }
        public T Message { get; set; }
    }

    class SampleMessage
    {
        public string Test { get; set; }
    }
}

namespace ConsoleApplication2
{
    class Program
    {
        static IBus bus;
        static void Main(string[] args)
        {
            var adapter = new BuiltinContainerAdapter();

            adapter.Handle<Request>(x => bus.Reply(new Response()));

            bus = Configure.With(adapter)
                             .Logging(l => l.ColoredConsole())
                             .Transport(t => t.UseMsmq("endpoint2", "endpoint2_errors"))
                             .MessageOwnership(x => x.FromRebusConfigurationSection())
                             .CreateBus()
                             .Start();
        }
    }

    public class Request
    {

    }

    public class Response
    {

    }
}

A: Yes it's true, and I agree with you that it should be documented somewhere :)
The feature has been there for quite some time now, though, and I haven't used it that much - mostly because I feel that it's a little bit too black box to be immediately understandable, which I think code should be most of the time.
My feelings could be caused by me having used the feature too little, though, so I might get another feeling some time in the future :)
Your code looks fine, and I think it should work perfectly. Now, I know it's just a simple POC, but please remember to "host" your container adapter somewhere for the duration of the application lifetime, and please remember to dispose it when the application shuts down.


text:
Q: Why can't I install iChat on my Mac? I was trying multiple times to install these iChat versions below, but they're not installing on my Mac:

*

*iChat Update 1.0 (Universal)

*iChat Update 1.0 (PPC)
Whenever I'm trying to install these, it's giving below errors:

A: Your installing an update and not the program itself.
If you get your OSX install disk, put it into the computer and select option installs from the menu, you will be able to install the iChat program. Then you may follow up with this update.
For Lion / Mountain Lion:
iChat is no longer on these systems. All iChat functionality has been migrated into the new messages app! So just use the messages app. It is installed as default however you can use the preferences menu to add an iChat account!

A: If I can respond to your question with another question, did you by chance install the Messages Beta and are now wanting to restore iChat?  Because iChat should be present on a standard 10.7 install unless you deleted it manually yourself (in which case you should follow Timothy's and my suggestions about the recovery partition).
In the event what I am suggesting is true, look here.


text:
Q: JavaScript sum function I have stacked in the sum of an array. The code is bellow
function User(name,email) {
        this.name = name;
        this.email = email;
        this.cartAmount = [];
        this.total = 0;
}
User.prototype = {
        constructor: User,

        addCart: function(mrp){
            this.cartAmount.push(mrp);
        },

        changeEmail: function(newmail){
            this.email = newmail;
        },

        showCart: function() {
            var cart = this.cartAmount.length >0 ? this.cartAmount.join("tk,") : "No product in the cart";
            return this.name+" has "+cart+" in his cart.";
        },

        intotal: function(){
            for(var n in this.cartAmount){
                this.total += this.cartAmount[n];
                return this.total;
            }
        }
    };
    athar= new User("Athar Jamil", "atharjamil@gmail.com");
    console.log(athar.name);
    athar.changeEmail("atharjamil@yahoo.com");
    console.log(athar.email);
    athar.addCart(20);
    athar.addCart(50);
    athar.addCart(80);
    console.log(athar.intotal());

It shows me only 20 as the result of the sum. What is the problem?

A: Do not use this.total for that. If you call this method several times, your total will increase each time you call it. You should at least put a this.total = 0 at the top of your method.
I personally would have written it like this instead :
intotal: function(){
    var out = 0;
    for(var n in this.cartAmount){
        out += this.cartAmount[n];
    }

    return out;
}

A: Using Array.prototype.reduce() you can simplify that function a lot:
intotal: function() {
  return this.cartAmount.reduce((a, b)=> a + b)
}

From MDN:

The reduce() method applies a function against an accumulator and each value of the array (from left-to-right) to reduce it to a single value.

Here you pass an arrow function to the reduce method, which takes two arguments: a and b, and returns sum of them.

A: intotal function returning the first element of cartAmount array.
Place the return statement of intotal function outside of for loop.

A: You're returning too early, hence your for loop runs only once and returns the first item in the cart.
Try this instead:
 intotal: function(){
    for(var n in this.cartAmount){
        this.total += this.cartAmount[n];
    }

    return this.total;
    }

A:

function sum(){
 var args = Array.prototype.slice.call(arguments);
 return args.reduce(function(pre,curr){
   if(!isNaN(curr)){
     return pre+curr;
   }
   else
   {
    throw Error("Non-Numeric arguments"+curr);
   }
},0)
}
    var result = sum(12,13,14); //pass any number of parameter to sum
    alert("Sum Is:"+result);

A: https://www.npmjs.com/package/mnjs
First import sum function from mnjs package
<script src="https://cdn.jsdelivr.net/npm/mnjs/browser/index.js"></script>

or
const { sum } = require('mnjs')
or
import { sum } from 'mnjs'
Then use sum function as follow:
const cartAmount = [1, 4, 2]

sum(cartAmount)   // returns 7

https://runkit.com/dr-montasir/mnjs-sum-function


text:
Q: Search Controller move along tableview code of search controller
it's working fine for searching
issue 1:
when I scroll tableView, I want to show search controller along with table view, search controller also gets scrolled with table view.
 let searchController = UISearchController(searchResultsController: nil)

  override func viewDidLoad() {
        super.viewDidLoad()
          searchController.searchResultsUpdater = self

        searchController.hidesNavigationBarDuringPresentation = false

        searchController.dimsBackgroundDuringPresentation = false

        tableView.tableHeaderView = searchController.searchBar

        searchController.delegate = self

        searchController.searchBar.sizeToFit()

        self.searchController.searchBar.delegate = self

        tableView.tableHeaderView = nil

        definesPresentationContext = true
}

update data of searching  :
func updateSearchResults(for searchController: UISearchController) {

        _ = kidsData

        let searchToSearch = searchController.searchBar.text

        if(searchToSearch == "")
        {
            self.kidsData = self.KidsDataDuplicate

        }
        else{

            self.kidsData.removeAll()

            let itemsarray = self.KidsDataDuplicate

            var forkidsinArray = [String]()

            for Kids in itemsarray {

                forkidsinArray.append(Kids.name)
                if(Kids.name.range(of: searchToSearch!, options: .caseInsensitive) != nil)
                {
                    self.kidsData.append(Kids)

                }

            }
          }

        self.tableView.reloadData()
    }

issue 2 :
Tableview navigation bar contains search button, when I click on search button at navigation bar, search controller should show its working at tableview header, but after scrolling tableview I want to show search controller at tableview starting cell.
 I can try the scroll delegates it's not working for me
 pls help me......!
this is code of search button at navigation
var launchBool: Bool = false {
    didSet {
        if launchBool == true {

            Status = 1
            tableView.tableHeaderView = searchController.searchBar
                   let indexPath = IndexPath(row: 0, section: 0)
               self.tableView.scrollToRow(at: indexPath, at: .middle, animated: true)

        } else {

               tableView.tableHeaderView = nil
               myInt = 0

        }
    }
}

 @IBAction func NAVSearchButton(_ sender: UIBarButtonItem) {
       launchBool = !launchBool

    }


text:
Q: Why do cell phones sometimes interfere with amplifiers I have an old Sony amplifier (TA-F117R) next to my desk where I keep my cell phone. Sometimes I put it ontop the amplifier, because it is pervecly alighed with the surface.
When I hang some call up and land the phone close to the amplifier the loud beeping noises started to burst from the speakers, something like the "modem calls" in the old ages of dial-up internet connection.
I suspect the phone - transmitter negotiation is responsible for that. The radi waves transmitted from the cell phone are strong enough to induce parasitic currents in the amplifiers circuits leading to the noise.
What makes me wonder is that this noise is generated only when I hang up the call and put the phone close the amp. I can send/recieve SMS, e-mails and browse the internet using the phone. I have bluetooth, NFC, GPS and Wi-Fi on all the time.
I have Sony Xperia L now, but I could observe the interference with all phones I used to have (Philips Fisio, SonyEricsson K770i, Samsung Galaxy-Y,...) and amplifiers (Old stereo, PC speakers).
What exactly causes such interferences and why SMS and others are transmitted without such interference.
The answer here blames the GSM protocol and the fact 800 - 900 MHz signal interfers with the amplifier's structures. However it dosn't address why SMS and data transfer do not cause such interference.

A: Even though audio amplifiers won't typically process any signals above 40kHz or so in usable fashion, the early stages of such amplifiers may not completely filter them out.  If high-frequency signals are strong enough, they may overdrive an amplifier stage, causing distortion.  Applying harmonic distortion to a signal that contains multiple frequencies may yield new spectral content at any frequency which can be formed by adding or subtracting any integer multiples of any frequencies present in the original.
Some wireless protocols use a variety of frequencies which are distributed in somewhat random fashion.  If such transmissions are picked up by an audio amplifier, the sum and difference tones will be distributed over a wide range of frequencies, and the result will simply be a slight increase in the level of background noise.
The problem with GSM is that its spectral content is distributed in a way that causes many of the sum and difference frequencies to coincide, thus concentrating their energy at a few discrete audio frequencies.  If the designers of GSM had foreseen the extent to which it would wreak havoc on audio, they could have easily adjusted the design slightly to avoid such frequency concentrations.  Unfortunately, by the time the problem was discovered it would have been impractical to adjust the design.

A: The chirps you hear from inactive speaker coils or amplifiers is the AM demodulation of Broadcast sync tones from cell phones exciting the coils.
This carrier burst sync to nearest towers is modulated quite different from the constant amplitude frequency hopping schemes used.
Even some car speakers nearby causes the coils to rub on the magnets from lateral forces of microwave energy on parasitic resonances tilting the coil while moving, which adds some sharper tones to pattern of "dit-da-da-dit" repeated several times.

A: The usual problem with interference from GSM cell phones is caused by rectification of the strong RF signal at the semiconductor junctions at the input of the amplifier.
GSM uses Time Domain Multiplexing Access (TDMA) to share the RF frequency with other users - it only turns the RF signal on for a short time at a 217Hz rate synchronized with other users and the base station using the remaining time.
This short relatively high-power RF can be rectified by any semiconductor junctions to cause a slight change in the bias level of the amplifier for the duration of the RF pulse (~0.5ms).  This is a buzz at 217Hz that can then get amplified by the amplifier to appear at the speakers.
It is not necessary for the amplifier to have any response at the RF frequency which can be up to about 2GHz.
The cure is to provide filtering to avoid the RF signal getting to the first stage of the amplifier.  The filtering may be as simple as a small high-frequency capacitor across the inputs, an RF choke in series or a more complex filter.
Bipolar junction transistors are more sensitive to this effect than FET front ends so it will be affected by which devices are used.
It's not obvious why SMS and data transfers would not cause noise as well - they use the same mechanism for transferring data.
More recent cell-phone protocols used in 4G and 5G cellular networks don't use TDMA but OFDMA instead. The cell-phone transmitters are on constantly rather than being interrupted so the amplitude demodulation that occurs accidentally with GSM wouldn't result in an audio tone. It may result in other effects by affecting the biasing and is conceivable that there might be clicks, pops or hisses resulting.


text:
Q: How can i compare 2 teams with their winning percentage? in C I get these errors with this code: in void teamEnter(){
[Error] expected identifier or '(' before string constant
[Error] 'ans1' undeclared (first use in this function)
[Error] 'ans2' undeclared (first use in this function)
Actually I want to subtract 2 teams winning percentage. I tried many ways but i couldnt find how can i equal team name with teamWinPercentage and then subtract first team to second team. Is there something different way that i tried now. I get errors in this code and i think this code will not reach my main goal. Thanks..

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int mainMenuChoose, leagueMenuChoose, leagueSubtractMenuChoose, returnMainMenu;

void mainMenu(){
printf("\n\tChoose");
printf("\n_____________________________________");
printf("\n1- see league");
printf("\n2- Compare Teams");

printf("\n\nChoose what you want : ");
scanf("%d",&mainMenuChoose);

switch(mainMenuChoose){
    case 1:
        leagueMenu();
        break;
    case 2:
        leagueSubtractMenu();
        break;
    default:
        printf("\nPlease enter correctly!");
 }
}

void leagueMenu(){
printf("\n\n\tLIG Menu");
printf("\n_____________________________________");
printf("\n1- See Team");
printf("\n2- Back to Main Menu");
printf("\n\n Choose: ");
scanf("%d",&leagueMenuChoose);

switch(leagueMenuChoose){
    case 1:
        seeTeams();
        break;
   case 2:
        mainMenu();
        break;
    default:
        printf("\nPlease enter correctly!!");
  }
 }

void leagueSubtractMenu(){
printf("\n\n   League subtract menu");
printf("\n_____________________________________");
printf("\n1- Enter Teams");
printf("\n2- Genel Menuye Donme Islemi");
printf("\n\nChoose: ");
scanf("%d",&leagueSubtractMenuChoose);

switch(leagueSubtractMenuChoose){
    case 1:
        enterTeam();
        break;

    case 2:
        mainMenu();
        break;
    default:
        printf("\nPlease enter correctly!");
  }
 }
 void enterTeam(){
    /*
printf("\n 1 - Arsenal");
printf("\n 2 - Aston Villa");
printf("\n 3 - Brentford");
printf("\n 4 - Brighton & Hove Albion");
printf("\n 5 - Burnley");
printf("\n 6 - Chelsea");
printf("\n 7 - Crystal Palace");
printf("\n 8 - Everton");
printf("\n 9 - Leeds United");
printf("\n 10 - Leicester City");
printf("\n 11 - Liverpool");
printf("\n 12 - Manchester City");
printf("\n 13 - Manchester United");
printf("\n 14 - New Castle United");
printf("\n 15 - Norwich City");
printf("\n 16 - Southampton");
printf("\n 17 - Tottenham");
printf("\n 18 - Watford");
printf("\n 19 - West Ham United");
printf("\n 20 - Wolverhampton\n\n");
*/

FILE *pFile;
if (pFile !=NULL){

char *teams[]={"Arsenal","Aston Villa","Brentford","Brighton & Hove Albion","Burnley","Chealsea","Crystal Palace",
    "Everton","Leeds United","Leicester City","Liverpool","Manchester City","Manchester United",
    "New Castle United","Norwich City","Southampton","Tottenham","Watford","West Ham United","Wolverhampton"};
    char ans1[25];char ans2[25];

float teamWinPerc[20]={0.642,0.441,0.430,0.500,0.385,0.685,0.485,0.367,0.371,0.455,0.828,0.842,
    0.567,0.444,0.228,0.430,0.614,0.228,0.541,0.500};

printf("\nCarefull for case type!\n");
printf("Enter first team: ");
scanf("%s",&ans1);
    if(strcmp(teams,ans1)==0){
        printf("Enter second team: ");
        scanf("%s",&ans2);
        if(strcmp(teams,ans2)==0){
            printf("%s - %s",ans1,ans2);
        }
        else{
        printf("Wrong data!");

        printf("\n Back to main menu with 0 or exit with different value: ");
            scanf("%d",&returnMainMenu);

            while(returnMainMenu==0){
            mainMenu();
            }
        }
    }
    else{
        printf("Wrong Data!");

        printf("\n Back to main menu with 0 or exit with different value: ");
            scanf("%d",&returnMainMenu);

            while(returnMainMenu==0){
            mainMenu();
            }
    }
    /*
    int i;
    for(i=1;i<21;i++){
        printf("[%d] = %s\n",i,takimAd[i]);
        printf("%d. Takimi giriniz:",i+1);

    }*/
        //scanf("%s",takimAd[20]);

    //fscanf(pFile, "%d %s %3.f",&sira,&name,&ky);

    //for(sira=1;sira<21;sira++){}

    /*while(fgets(name, sizeof(name),pFile)){
        fscanf(pFile, "%d %s %3.f",&sira,&name,&ky);
        printf("1.Takimi Girin: ");
        scanf("%s",&takim1);
            if(strcmp(name,takim1)==0){
            printf("%s",takim1);
            fscanf(pFile, "%d %s %3.f",&sira,&name,&ky);
            }

        printf("2.Takimi Girin: ");
        scanf("%s",&takim2);
            if(strcmp(name,takim2)==0){
            printf("%s",takim2);
            fscanf(pFile, "%d %s %3.f",&sira,&name,&ky);
            }
        printf("%3.f - %3.f = %3.f",ky-ky);
    }*/

}

else{
    printf("File cant open.\n");
}

//char Arsenal=(float) 0.642;
//char Astonvilla=(float)0.441;
/*chelsea,manchesteru,tottenham,
manchesterc,westham,wolverhampton,brighton,
crystalpalace;*/

/*printf("Karsilastirmak istediginiz takimlari secin:\n");
printf("1. Takimi secin:\n ");
scanf("%c",&Arsenal);
printf("2. Takimi secin:\n ");
scanf("%c",&Astonvilla);
printf("%.3f - %.3f",Arsenal,Astonvilla);
*/
return 0;
}

void seeTeams(){
FILE * fPointer;
fPointer =fopen("takimlar.txt","r+");
char singleLine[200];

while(!feof(fPointer)){
fgets(singleLine,200,fPointer);
puts(singleLine);
}

fclose(fPointer);

printf("\n Back to main menu with 0 or exit with different value:");
scanf("%d",&returnMainMenu);

while(returnMainMenu==0){
    mainMenu();
 }
}

A: scanf("%s",ans1); // remove & ans1 is address
scanf("%s",ans2); // remove & ans2 is address

// what are you trying with this? I think you want to know
// if ans1 is inside team, you should performs one strcmp()
// on each teams member element [0]... [19]
if(strcmp(teams,ans1)==0)

// void function but return integer, you cant do that
void enterTeam()
{
--snip--
return 0; // if it is void don't return integer
}

FILE *pFile; // need to be initialized before to use
if (pFile !=NULL) // uninitialized

Down below an example of strcmp(), looking for a name in a list
#include <stdio.h>
#include <string.h>

#define NAME_LENGTH 80

char *teams[NAME_LENGTH] =
    {"Arsenal","Aston Villa","Brentford","Brighton & Hove Albion",
    "Burnley","Chealsea","Crystal Palace","Everton","Leeds United",
    "Leicester City","Liverpool","Manchester City","Manchester United",
    "New Castle United","Norwich City","Southampton","Tottenham","Watford",
    "West Ham United","Wolverhampton"};

int is_listed(char *);

int main()
{
    int r = 0;
    char team_name[80];

    printf("Give me a team name, I will verify:  ");
    scanf("%s", team_name);

    r = is_listed(team_name);

    if(r == -1)
    {
        printf("\n Name is not in list!\n");
    }
    else
    {
        printf("\n Name is position %d in the list\n", r);
    }

    return 0;
}

// Return position in the list, -1 if it is not in the list
int is_listed(char *my_name)
{
    int n;
    for(n =0; n<20; n++)
    {
        printf("\n%s ?? %s", teams[n], my_name);
        if(strcmp(teams[n], my_name) == 0)
        {
            return n;
        }
    }
    return -1;
}

A: I think that a two-dimension array and a struct will be a better solution, but down below a solution just using arrays, atof function convert an array to a float.
#include <stdio.h>
#include <stdlib.h>

#define NAME_LENGTH 80

char teams[][2][NAME_LENGTH] =
  {
    {"Arsenal", "0.642"},
    {"Aston Villa", "0.441"},
    {"Brentford", "0.430"}
};

int main()
{
    float team_a;
    float team_b;

    team_a = atof(teams[0][1]);
    team_b = atof(teams[0][1]);

    if(team_a > team_b)
    {
            printf("The best team is %s with a %f score\n", teams[0][0], team_a);
    }
    else
    {
            printf("The best team is %s with a %f score\n", teams[1][0], team_b);
    }

    return 0;
}


text:
Q: Windows custom sound events Say for example I want to make windows 7 play a sound every time I open Firefox
This is what I do:
With regedit I create the following:
HKEY_CURRENT_USER->AppEvents->EventLabels->Firefox (default = Firefox)
HKEY_CURRENT_USER->AppEvents->Schemes->Apps->Firefox->Launch (default = 0)
I then go to Control Panel - Sound - Sounds and give the newly created Firefox -> Launch program event a sound to play. I apply the changes and open firefox - no sound is played.
What am I missing?
I guess I need to specify somewhere what this event is about?

A: What you did is partly correct, but it is only half of the thing that is necessary. The second question on this MSDN page describes how to add a Windows sound event and how to play it.
With your registry changes you created an application specific sound Event for the application Firefox. Then you set the sound file to play using Control Panel. Now if Firefox calls the Windows function PlaySound as PlaySound(_T("Launch"), NULL, SND_APPLICATION) then Windows will play the sound you configured. The problem is that Firefox does not call PlaySound, so the sound event is not triggered and the sound is not played.


text:
Q: Alert dialog theme does not inherit `windowBackground` from activity theme In my app I have this theme in the styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">#000000</item>
    <item name="colorAccent">@color/neon_green</item>
    <item name="android:windowBackground">@color/black_17</item>
</style>

but the attribute windowBackground does not cause the dialog background to change. The dialog background color is still white. The neon_green highlight color does appear for the dialog text though.
Only the background color that does not change.
AlertDialog.Builder builder =
        new AlertDialog.Builder(new ContextThemeWrapper(act, R.style.AppTheme));
builder.setMessage("text")
        .setPositiveButton("pos ", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // FIRE ZE MISSILES!
            }
        })
        .setNegativeButton("neg", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog
            }
        });
builder.create().show();

A: I just added this to my styles
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:textColor">@color/white</item>
    <item name="android:textColorPrimary">@color/white</item>
    <item name="android:background">@color/black_17</item>
</style>

then I passed the styles to the builder
AlertDialog.Builder builder =
                new AlertDialog.Builder(act,
                           R.style.AppCompatAlertDialogStyle);