text:
Q: compiling multiple cpp files together, which include same headers, results in undefined references to everything I am struggling since quite some time with restructuring a c++ project of mine. It has been working when it still was a single file that included every part of that (literally right in the file, not even #include, except for io stuff). It compiled fine then, but now:
I have single files for every class, since compilation is taking several seconds if it is all squished together, which is a bit too long for the usually rather small changes i make to my code.
This was working well so far, i made the appropiate Makefile (i am using gcc and make via command line, no ides, on msys2 on windows) and the compilation spits out no code errors, except the problem where it literally does not find a single reference to my functions, or anything else, like the std:: stuff.
While trying to figure out where it comes from, i rebuilt the code structure for something much smaller. Just 2 cpp files, each includes a function definition for a function signature that was included via a short .h file. (e.g. func.cpp:1 #include"func.h". test.cpp also contains the 'main' function. i will append the whole code further down in this thread)
Both of these files include only one function(except main, but that is not the point here), which are just a wrapper for simple stdout stuff. To make those work(compile without code syntax errors), i had to include the appropiate std header in the according cpp file. so func.cpp and test.cpp include func.h and test.h respectively, and BOTH include iostream.
Now, when i try to compile that, i get the same undefined reference errors i have in my bigger project (though a whole lot less here)
C:\msys64\tmp\cc0oLmKB.o:func.cpp:(.text+0x17): undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:\msys64\tmp\cc0oLmKB.o:func.cpp:(.text+0x26): undefined reference to 'std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:\msys64\tmp\cc0oLmKB.o:func.cpp:(.text+0x46): undefined reference to 'std::ios_base::Init::~Init()'
(this goes on for around half a dozen more functions.)
This is apparently a problem with cpp code, since it works fine if i replace the c++-iostream stuff with c's stdio/printf (in both files, so 2xiostream => 2xstdio), but i have absolutely no idead how to fix that. i have wrapped the iostream includes in a ifndef block so that it would not be included more often than it has to(which makes no sense here since none of the cpp files includes the other one, but i am desperate!), but that does not change a thing. (previously, i compiled both into the respective .o file, and linked them via gcc func.o test.o -o main, from which i got the same result, lots of undefined references).
I have absolutely no idea what to do now. My only idea left is, that it might be a problem with the gcc/std-libs version for msys2, so i will try that same piece of code on a linux machine and tell you if that works, but it probably won't.
Looking forward to yours answers,
Patrick
I have no idea why this is flagged as a duplicate. the existing threads do not answer my problem. as i said, it works with c header files, but not with c++ ones. this is probably a linking error, but i have yet to see an explanation on how to fix this.
extended infos:
func.h:
int myprint();

test.h:
void stuff();

func.cpp:
#include"func.h"

#ifndef IO
#define IO
#include<iostream>
#endif

//if the iostream stuff is replaced with stdio.h and std::cout etc. replaced with printf, it works

int myprint(){
    std::cout<<"hello"<<std::endl;

}

test.cpp:
#include"func.h"
#include"test.h"

#ifndef IO
#define IO
#include<iostream>
#endif

void stuff(){
    std::cout<<"stuff"<<std::endl;
}

int main(int argc, char **argv){

    myprint();
    stuff();

    return 0;
}

compile command: (adding any std also did not help, just so you know)
gcc -o main func.cpp test.cpp

compiler output:
C:\msys64\tmp\ccY7n59u.o:func.cpp:(.text+0x17): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:\msys64\tmp\ccY7n59u.o:func.cpp:(.text+0x26): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:\msys64\tmp\ccY7n59u.o:func.cpp:(.text+0x41): undefined reference to `std::ios_base::Init::~Init()'
C:\msys64\tmp\ccY7n59u.o:func.cpp:(.text+0x71): undefined reference to `std::ios_base::Init::Init()'
C:\msys64\tmp\ccY7n59u.o:func.cpp:(.rdata$.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_[.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_]+0x0): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
C:\msys64\tmp\ccY7n59u.o:func.cpp:(.rdata$.refptr._ZSt4cout[.refptr._ZSt4cout]+0x0): undefined reference to `std::cout'
C:\msys64\tmp\ccSaa3Ax.o:test.cpp:(.text+0x17): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:\msys64\tmp\ccSaa3Ax.o:test.cpp:(.text+0x26): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:\msys64\tmp\ccSaa3Ax.o:test.cpp:(.text+0x6a): undefined reference to `std::ios_base::Init::~Init()'
C:\msys64\tmp\ccSaa3Ax.o:test.cpp:(.text+0x9a): undefined reference to `std::ios_base::Init::Init()'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:2: main] Error 1

gcc -v:
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-6.3.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 6.3.0 (Rev3, Built by MSYS2 project)


text:
Q: HTML5 canvas array creation error I am using the following code to try out the canvas element
    Shape = function(x,y){
        this.x = x;
        this.y = y;
    };

    shapes = new array();

    shapes.push(new Shape(50,50,10,10));
    shapes.push(new Shape(100,100,10,10));
    shapes.push(new Shape(150,150,10,10));

    function animate(){
        context.clearRect(0,0, canvas.width(),canvas.height());
        var shapesLength = shapes.length;
        for(var i = 0; i < shapesLength; i++){
            var tmpShape = shapes[i];
            tmpShape.x++;
            context.fillRect(tmpShape.x,thmpShape.y,10,10);
        }
        context.fillStyle = 'yellow';
        context.fill();
        if(playAnimation){
            setTimeout(animate, 1)
        }
    }

However, when I run this in the browser I get the following error -
ReferenceError: array is not defined

shapes = new array();

I have tried making it a global and local variable I just cant see where I am going wrong?

A: array should be capitalized, as that is the name of the constructor:
shapes = new Array();

In addition it's better to use the square bracket notation to create an array. Like this:
shapes = [];

redpajama_set_name: RedPajamaStackExchange


text:
Q: Xcode crashing after archive? App crashes after creating an archive of the app. My app works fine in several different branches of syncing, however, as soon as I create a Product-> Archive, after that has been completed, the app no longer runs and I receive "Thread 1: signal SIGABRT" afterwards. This has happened on two different laptops. Even if I try to delete and re-download I get the same results.
To clarify, my issue does not happen while archiving. All of this happens after I archive the app.

A: Try to increase the version in the project settings to a higher number than the one released to app store


text:
Q: how to bind this json data programitically in android , example i have mention below My json data from Server
 [
  {
    "status": [
      {
        "itemcode": "129652030900",
        "barcode": "129652030900^4500031080^20190919^10",
        "batchno": "4500031080"
      },
      {
        "itemcode": "129652030900",
        "barcode": "129652030900^4500031080^20190919^10",
        "batchno": "4500031080"
      }
    ],
    "Productlocation": "BAYLOC"
  },
  {
    "status": [
      {
        "itemcode": "129652030900",
        "barcode": "129652030900^4500031080^20190919^10",
        "batchno": "4500031080"
      },
      {
        "itemcode": "129652030900",
        "barcode": "129652030900^4500031080^20190919^10",
        "batchno": "4500031080"
      }
    ],
    "Productlocation": "BAYLOC"
  }
]


text:
Q: How to calculate distinct element and puth distint values in a particular array Column is a array having around 10000 values which include repetitive values also. I want a array darray which should include only distinct values without repetition. I was trying to do by this code. But length of darray is coming out as 0. Some problem with the break statements. With using break I want to come out of inner two loops but not the third loop. Help me out.
darray=[]
m=0

for d in range(0,length):
    f=0
    for r in range(d,length):
        if f==1:
            break
        for l in range(0,m):
            if column[r] == darray[l]:
                f=1
                break
            elif column[d] == column[r]:
                darray.append(column[d])
                m+=1
                f=1
                break

lent = len(darray)
print lent;

A: If ordering in the resulting array is not relevant, you can just use a set:
lent=set(column)

(or list(set(column)) if you need the result to actually be a list)
Otherwise, you can use a set as auxiliary data structure to quickly see if the new array already has an element.
s=set()
lent=[]
for v in column:
    if v not in s:
        lent.append(v)
        s.add(v)

Both of these are O(n log n), compared to the O(n^2) (or worse) of the naive solution.


text:
Q: Add header.ejs file inside the ejs-locals header block I don't know whether it is possible or not So Please give me a suggestion. My question is How to add(include) header.ejs inside the ejs-locals header block?
boilerplate.ejs
<!DOCTYPE html>

    <title>It's me</title>
    <%-scripts%>
    <%-stylesheets%>

      <%-blocks.header%>

      <%-body -%>

      <%-blocks.footer%>

index.ejs
<% layout('boilerplate') -%>
<% script('foo.js') -%>
<% stylesheet('foo.css') -%>

I am the  template

I'm red if foo.css was loaded.

Here are some muppets we know about:

<% block('header', "
I'm in the header.
") -%>
<% block('footer', "
I'm in the footer.
") -%>

header.ejs

I'm in the header

In the above code(index.ejs), You can see header block has the HTML code.But there I would like to include the header.ejs.
Thanks.


text:
Q: Combine files in a filegroup SQL Server 2005 I need to combine files in a filegroup in SQL Server 2005. How do I do this? I've run the EMPTYFILE DBCC Shrinkfile but it's crawling..

A: One way (for the tables at least) would be to drop the clustered index and then re-create the clustered index specifying the filegroup you are trying to combine them into.  Since the clustered index is applied to the actual table this would accomplish what you are trying to do (for the tables).
You can read more about this approach on this MSDN forum topic.
http://social.msdn.microsoft.com/Forums/en-US/sqlreplication/thread/043c2bd4-07a1-4361-8c2b-7f375dd72107


text:
Q: Unresolved external symbol from a console application in visual studio I created a console application project(let's call it ProjectA) in visual studio, and another project which is the googletest project to test the ProjectA. Now I got unresolved external symbol problem when testing functions that have definition in cpp. (If I put everything in .h, there's no problem). How to make the content in the cpp visible to the googletest project? I notice ProjectA only creates a exe but no lib...
Many thanks!

A: As you have not provided code, I can give high level details.
Try to link your ProjectA to projectB So that when linker try to link it will find the proper definition.


text:
Q: Automatically underline rows in excel based on unique data I frequently use a spreadsheet, onto which we put a table of data.
The data is actually several rows per item we would be dealing with, but the number of rows changes.
For example, several items will all be listed with the same order number. What I then have to do is go through and underline the rows (bottom border) when it changes into a new order.
Is there a more convenient way to highlight a section of the table, then have an entire row formatted with the bottom border everytime a new value is found in a column?


text:
Q: Preventing direct access to a page, but allowing iframe embedding Can I prevent direct access to a file, but allow that page to be embedded in an other page as an iframe?
I am using Apache and php on the serverside, and the file to be included is on the same domain.

A: Perhaps not the best solution (as some browsers or routers remove it) but you could use the HTTP_REFERER server value?
Something like:
<?php
if($_SERVER['HTTP_REFERER'] !== 'http://my-domain.com/page-x') {
    header('HTTP/1.1 403 Forbidden');
    exit;
}
//rest of code here

A: Nope, you cannot. Either you make your page available to everyone, or to no-one.
You can protect the page via basic authentication in order to restrict he users who can access it, however who accesses it will need to know the credentials for the page. There is a SO question on a topic like this: Basic authentication for a url in an iframe.


text:
Q: How to change the color of a formfield its value has been modified by the user? I have to generate a Pdf file with Itext, and make it editable by the user. Thanks to Itext, that's almost OK. There is a problem, still. How can I show a field has been modified by the user, that is to say, how can I show that the value of a field in the final Pdf is not the one that had been preset ? I was thinking, for instance, of boldening the font, or changing the field's background, but I don't know how to do.
I tried with pdfAction.createJavaScript, but it seems that I can't change the style of an element of my Pdf, because there's no css in it. Can anyone help please ?
Here is a piece of my code :
PdfTextFormField champTempsMinutes = PdfTextFormField.createMultilineText(
        pdfDocument,
        new Rectangle(currentX, currentY, 20f, 14f),
        "champTempsMinutes",
        "_ _");

champTempsMinutes.setFontAndSize(fontHelvetica, 8);
champTempsMinutes.setJustification(1);
champTempsMinutes.setFieldName("toto");

champTempsMinutes.setAdditionalAction(
        com.itextpdf.kernel.pdf.PdfName.V,
        PdfAction.createJavaScript("app.alert(\"Mouse Enter\")"));
        PdfAction.createJavaScript("app.alert(this.getField('toto').value);"));

A: You can use the following additional action which will make the border around your form field red:
field.setAdditionalAction(PdfName.V,
                PdfAction.createJavaScript("this.getField('fName').strokeColor = color.red;")

Please note that it will only work in the viewers that support JS. Adobe Reader/Acrobat and Foxit are among them.


text:
Q: How to reverse only hebrew chars on a string dart? I would like to reverse only hebrew chars in a string .
For example :
input: 1234 בלה בלה בלה
output': הלב הלב הלב 1234

A: Note that for the algorithm below to work you will need to manually add all the Hebrew characters to the list named chars I have only added the 3 Hebrew chars you specified in your example
Note that you could populate the char List using a json array if you can find one online. How to get json from the web

*

*Create List of Hebrew characters

  final List<String> chars = <String>[
    "ב",
    "ל",
    "ה",
  ];

*Create temp String from original string with only Hebrew characters, but in reverse

    String temp = "";
    for (int i = widget.reverseString.length - 1; i >= 0; i--) {
      if (chars.contains(widget.reverseString[i])) {
        temp += widget.reverseString[i];
      }
    }

*Replace occurrences of Hebrew characters in original string with temp values

int tempIndex = 0;
String reveredString = widget.reverseString;
for (int r = 0; r < widget.reverseString.length; r++) {
  if (chars.contains(widget.reverseString[r])) {
    reveredString = _replaceCharAt(reveredString, r, temp[tempIndex]);
    tempIndex++;
  }
}

Full Example:
//ref:
//https://www.geeksforgeeks.org/reverse-a-string-without-affecting-special-characters/
import 'package:flutter/material.dart';

class ReverseHebrew extends StatefulWidget {
  final String reverseString;

  const ReverseHebrew({
    Key? key,
    required this.reverseString,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _ReverseHebrewState();
  }
}

class _ReverseHebrewState extends State<ReverseHebrew> {
  /*
    This list must be manually populated to include all Hebrew characters for this
    code to properly work.
   */
  final List<String> chars = <String>[
    "ב",
    "ל",
    "ה",
  ];

  String _replaceCharAt(String oldString, int index, String newChar) {
    return oldString.substring(0, index) +
        newChar +
        oldString.substring(index + 1);
  }

  String _reverse() {
    // copy hebrew chars to temp in reverse order
    String temp = "";
    for (int i = widget.reverseString.length - 1; i >= 0; i--) {
      if (chars.contains(widget.reverseString[i])) {
        temp += widget.reverseString[i];
      }
    }

    // replace occurrences of Hebrew chars in the original string with
    // the reversed values in temp
    int tempIndex = 0;
    String reveredString = widget.reverseString;
    for (int r = 0; r < widget.reverseString.length; r++) {
      if (chars.contains(widget.reverseString[r])) {
        reveredString = _replaceCharAt(reveredString, r, temp[tempIndex]);
        tempIndex++;
      }
    }

    // return reversed string
    return reveredString;
  }

  @override
  Widget build(BuildContext context) {
    return Text(_reverse());
  }
}

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            children: [
              Text("Original: 1234 בלה בלה בלה"),
              Text("Reversed:"),
              ReverseHebrew(
                reverseString: "בלה בלה בלה 1234",
              ),
            ],
          ),
        ),
      ),
    ),
  );
}

Ref: Geeks for Geeks Algorithm

A: Seemingly Hebrew has the range \u0590-\u05fe (according to this nice JavaScript Unicode Regex generator).
So we can use this to find and reverse Hebrew only from any given string.
Here is the perfect working example:
String reverseHebrew(String text) {
    text = text.splitMapJoin(
      RegExp(r'[\u0590-\u05FF]+'),
      onMatch: (m) => m.group(0).split('').reversed.join(),
      onNonMatch: (string) => string,
    );
    // reverse words in string
    return text.split(' ').reversed.join(' ');
  }


text:
Q: I want to use parameterized query in @databricks/sql node.js Query = "select * from repos where id="sj"
parameterized =
"select * from repos where id = ?"
result - executestatement(parameterized,"sj")

I want to pass parameters to the sql query for @databricks/sql module but I am unable to figure out a way. The node.js package has this issue listed if anybody knows a work around?
Parameterizing the query for prevention of sql injection of application.


text:
Q: SAS EG: Prompts with Dynamic List on Metaserver I'm trying to develop a SAS Prompt that has a drop down with values pulled from a field on a table I'm storing in the Work library.
When I click "Browse" in the "Data Source" area, I'm confined to my SAS Folders.
I'm on a metadata server and don't yet understand the limitations.
How would it be possible to store a table in the SAS "My Folder" folder?
I've created a static list from the data. Should I use this option instead? If so, is there a way to update the list using a SAS Script?
I'm new to SAS EG but not Base SAS. I'm not familiar with "Files" or the "Metadata Server". I typically just query data out of multiple libraries and store in in a work folder prior to export.

A: The SAS Metadata Server stores metadata about your EG project in the metadata server repository. The actual project files are stored on the WebDAV server. Regular users do not need to know about the WebDAV server. The important part to know is that the metadata server repository in your case acts like a file system. On that file system, your system administrator must have granted rights (with ACTs and ACEs).
Since 2011, the recommended best practice from SAS is to DENY rights initially, and ALLOW rights on a basis of need.
SAS prompts consist of metadata only. They are read by the SAS Prompting Framework which take care of the user interface. As such, you do not need to store them in you WORK library. Instead, SAS EG jobs can take parameters from the Prompting Framework, and you can use the parameters as SAS Macro variables in your SAS EG code.
To use a table with EG you must have been granted to enterprise resources. If you want to use local resources, you must be able to import Excelsheets via the File menu.
The biggest difference between SAS Foundation and Enterprise Guide (with Metadata Server) is that

*

*on SAS Foundation, you and your team can access everthing, and need to do every yourselves (including documentation)

*and EG / MS tasks are split up in different interfaces to be more scalable over the entire Enterprise (company wise). All relations between entities are stored in the metadata server and are automatically documented / graphable. You as a developer are a bit more dependant of others, roles are split up, like with autorisation in your case. For larger organisations to be compliant this situation is generally considered an improvement.

For more information please see the SAS Intelligence Platform Overview documentation.


text:
Q: Creating a shared string array which children processes can access I am declaring an array of string using
char users[10][256];

then I am forking and creating 10 child processes.
I need each child process to access and modify this string array. How do I do that ?

A: You'd probably want to use Shared Memory.
Under Linux, you can check this out. It uses shmget, shmat and shmdt to create shared memory segments, get shared memory segments and detach shared memory segments respectfully.
Under Windows, you can check this out. It uses OpenFileMapping and MapViewOfFile to create "File Mappings" and map them to the process's virtual memory respectfully.
Both, finally, achieve the same result.


text:
Q: Drupal error "Unable to allocate memory for pool" I get this error with my Drupal site:

Warning: Unknown: Unable to allocate memory for pool. in Unknown on
  line 0

I have observed a similar post for Wordpress  but not sure if it applies for Drupal. Can any one explain what should I do. I am using Drupal 6.27 and PHP 5.2.17.

A: It's an APC configuration issue. APC is an opcode cache for PHP
Search for APC settings in your php.ini or maybe in an apc.ini linked to your php.ini.
Possible solution is playing with these:
decrease apc.ttl and increase apc.shm_size

A: Sometimes the error will still occur even if you try yo override the settings with ini_set(). In this case you can also disable is entirely. For low traffic sites this will not be an issue.
Add this line to the top of your index.php file:
ini_set('apc.cache_by_default',0);

A: Your Drupal site runs on the PHP programming language. You can configure the version of PHP used by your website.
The latest version of PHP 5.5. Uses OPcache opcode cache, and includes the APCu extension for 100% compatibility with the APC user caching API.
I upgrade the version from PHP 5.3 To PHP 5.5 and this worked for me.


text:
Q: Migrating to Office365 - Accessing Outlook folders via Access VBA Our organization is migrating to Office 365. Currently we have an MS Access tool which is extracting public folder calendar data using a vba code shown below. Is there any changes to the code, if it is in O365 environment?
Set myns = ol.GetNamespace("MAPI")
Set mycal = myns.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("foldername").Folders("subfoldername")

Any help on this is greatly appreciated.

A: It will work - you don't need to do any changes.


text:
Q: Malformed request when creating billing plan So I a using the node paypal-rest-sdk module and I'm trying to create a billing plan. Using the documentation here I made this JSON:
const billingPlanAttributes = {
  name: 'Subscription',
  description: 'Monthly subscription plan',
  type: 'INFINITE',
  payment_definitions: [{
    name: 'Regular monthly infinite payments',
    type: 'REGULAR',
    frequency_interval: '1',
    frequency: 'MONTH',
    cycles: '0',
    amount: {
      currency: 'USD',
      amount: '4.99',
    },
  }],
  merchant_preferences: {
    cancel_url: 'http://localhost:3000/subscribe/cancel',
    return_url: 'http://localhost:3000/subscribe/return',
    auto_bill_amount: 'YES',
  },
};
But when using the paypal.billingPlan.create(... function I get the error 'MALFORMED_REQUEST', 'Incoming JSON request does not map to API request'. So I guess my JSON is not in the correct format or I'm missing something that is need.
The documentation has a charge_models key but it does not mention that it is required unlike other keys.
If you can point me in the right direction that would be great.
Edit: changed the return url and cancel url to include the full domain but still same error.

A: There could be more to this, but I noticed one thing wrong with your JSON.  Remove commas for items last in a list. After 'amount' and 'merchant_preferences'.  JSON is picky.

A: late answer, I know, but ran in exactly the same issue than you.
In the create function of the billing plan
public function create($apiContext = null, $restCall = null)
{
    $payLoad = $this->toJSON();
    $json = self::executeCall(
        "/v1/payments/billing-plans/",
        "POST",
        $payLoad,
        null,
        $apiContext,
        $restCall
    );
    $this->fromJson($json);
    return $this;
}

I found out, that the toJSON method always returned false. Why the hell!?!
I did the same as you did and copied the complete sample code into my code. Then it worked as expected. Now I checked, what the difference was in to my code.
I realized, that I used an umlauts (ä,ü,ö) in the name and description of the billing plan. I changed the umlauts to
'ä' => 'ae',
'ö' => 'oe'
'ü' => 'ue'

Then it worked fine! Maybe someone else is running in this issue, too.


text:
Q: How to get height of div before its expanded So I'm using bootstrap collapse, and when the user clicks on a link I want to expand the div and calculate its height and add that height to h3.
My problem is that I get 0 when I click on link and expand div, and when I click again it collapses in div then it get its true height. Any help?
$(document).ready(function(){
    $("#open_tech").click(function(){
    var height = $(".price_list").height();
        $('.left_side_menu h3').css('height',height);
        console.log(height);
    })
});

A: What you want is the shown.bs.collapse event

This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).

$('.price_list').on('shown.bs.collapse', function () {
    var height = $(".price_list").height();
    $('.left_side_menu h3').css('height', height);
    console.log(height);
})
.left_side_menu h3 {
  background-color: #ccc;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>

<button data-toggle="collapse" data-target=".price_list">Collapsible</button>

  Lorem ipsum dolor text.... Lorem ipsum dolor text....

Some header text


text:
Q: What are the words of Galadriel at the beginning of the Fellowship? In the trilogy of the movies, at the very beginning Galadriel says a few words starting with "The World is changed. I feel it..." In the background the words start in Elvish "Yamma presta..." What are those words?

A: Here's a site that talks about linguistics in the Lord of the Rings movies. According to it, the complete line is:

I amar prestar aen, han mathon ne nen, han mathon ne chae a han noston ned 'wilith.

which -- as you'd expect -- is a Sindarin version of Galadriel's English lines:

'The world is changed; I can feel it in the water, I can feel it in the earth, I can smell it in the air.'

Note that the movie gives these lines to Galadriel, but in the book, they're said by Fangorn to Galadriel, in a very different context: it's in chapter 6 of book VI, and

 he's lamenting the fact that, because the world is changing, the two of them will likely never meet again.

One further note: the attempted transcription in the OP is missing the Rs at the end of "amar" and "prestar." This can probably be traced to Cate Blanchett's non-rhotic Australian accent creeping into her Sindarin pronunciation; in Tolkien's elvish languages as correctly pronounced, that R should always be audibly rolled. The pronunciation chapter at the beginning of Helge Fauskanger's Quenya course has some remarks on this kind of thing (mostly about the correct pronunciation of "Mordor").


text:
Q: Htaccess Redirect from one subfolder to another I'm looking to do a .htaccess redirect for my author URL to a standard user profile URL
I'm looking to redirect
https://domainname.com/author/{username} to https://domainname.com/user/{username}
This is what I have at the moment but it doesn't seem to work
RewriteEngine On
RewriteRule ^/?author/(.*)$ /user/$1 [R,L]

Any advice would be appreciated
Full htaccess content
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^author/(.*)/?$ /user/$1? [NC,R=301,L]
</IfModule>

<IfModule mod_alias.c>
RedirectMatch 403 \,
RedirectMatch 403 \:
RedirectMatch 403 \;
RedirectMatch 403 \=
RedirectMatch 403 \[
RedirectMatch 403 \]
RedirectMatch 403 \^
RedirectMatch 403 \`
RedirectMatch 403 \{
RedirectMatch 403 \}
RedirectMatch 403 \~
RedirectMatch 403 \"
RedirectMatch 403 \$
RedirectMatch 403 \<
RedirectMatch 403 \>
RedirectMatch 403 \|
RedirectMatch 403 \.\.
RedirectMatch 403 \%0
RedirectMatch 403 \%A
RedirectMatch 403 \%B
RedirectMatch 403 \%C
RedirectMatch 403 \%D
RedirectMatch 403 \%E
RedirectMatch 403 \%F
RedirectMatch 403 \%22
RedirectMatch 403 \%27
RedirectMatch 403 \%28
RedirectMatch 403 \%29
RedirectMatch 403 \%3C
RedirectMatch 403 \%3E
RedirectMatch 403 \%3F
RedirectMatch 403 \%5B
RedirectMatch 403 \%5C
RedirectMatch 403 \%5D
RedirectMatch 403 \%7B
RedirectMatch 403 \%7C
RedirectMatch 403 \%7D
# COMMON PATTERNS
Redirectmatch 403 \_vpi
RedirectMatch 403 \.inc
Redirectmatch 403 xAou6
Redirectmatch 403 db\_name
Redirectmatch 403 select\(
Redirectmatch 403 convert\(
Redirectmatch 403 \/query\/
RedirectMatch 403 ImpEvData
Redirectmatch 403 \.XMLHTTP
Redirectmatch 403 proxydeny
RedirectMatch 403 function\.
Redirectmatch 403 remoteFile
Redirectmatch 403 servername
Redirectmatch 403 \&rptmode\=
Redirectmatch 403 sys\_cpanel
RedirectMatch 403 db\_connect
RedirectMatch 403 doeditconfig
RedirectMatch 403 check\_proxy
Redirectmatch 403 system\_user
Redirectmatch 403 \/\(null\)\/
Redirectmatch 403 clientrequest
Redirectmatch 403 option\_value
RedirectMatch 403 ref\.outcontrol
# SPECIFIC EXPLOITS
RedirectMatch 403 errors\.
RedirectMatch 403 config\.
RedirectMatch 403 include\.
RedirectMatch 403 display\.
RedirectMatch 403 register\.
Redirectmatch 403 password\.
RedirectMatch 403 maincore\.
RedirectMatch 403 authorize\.
Redirectmatch 403 macromates\.
RedirectMatch 403 head\_auth\.
RedirectMatch 403 submit\_links\.
RedirectMatch 403 change\_action\.
Redirectmatch 403 com\_facileforms\/
RedirectMatch 403 admin\_db\_utilities\.
RedirectMatch 403 admin\.webring\.docs\.
Redirectmatch 403 Table\/Latest\/index\.
</IfModule>
#AIOWPS_ADVANCED_CHAR_STRING_FILTER_END
#AIOWPS_BLOCK_SPAMBOTS_START
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
RewriteCond %{HTTP_REFERER} !^http(s)?://domainname\.com [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule .* http://127.0.0.1 [L]
</IfModule>

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

<ifModule mod_headers.c>
Header set X-Frame-Options DENY
Header set Referrer-Policy: no-referrer-when-downgrade
</ifModule>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>

A: With your shown samples, attempts please try following .htaccess rules file, make sure to keep your .htaccess rules file along with user folder.
Make sure to clear your browser cache before testing your URLs.
RewriteEngine On
RewriteRule ^author/(.*)/?$ /user/$1? [NC,R=301,L]
RewriteRule ^user/(.+)/?$ index.php?param=$1 [QSA,NC,L]

Your complete .htaccess rules file will be:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^author/(.*)/?$ /user/$1? [NC,R=301,L]
</IfModule>

<IfModule mod_alias.c>
RedirectMatch 403 \,
RedirectMatch 403 \:
RedirectMatch 403 \;
RedirectMatch 403 \=
RedirectMatch 403 \[
RedirectMatch 403 \]
RedirectMatch 403 \^
RedirectMatch 403 \`
RedirectMatch 403 \{
RedirectMatch 403 \}
RedirectMatch 403 \~
RedirectMatch 403 \"
RedirectMatch 403 \$
RedirectMatch 403 \<
RedirectMatch 403 \>
RedirectMatch 403 \|
RedirectMatch 403 \.\.
RedirectMatch 403 \%0
RedirectMatch 403 \%A
RedirectMatch 403 \%B
RedirectMatch 403 \%C
RedirectMatch 403 \%D
RedirectMatch 403 \%E
RedirectMatch 403 \%F
RedirectMatch 403 \%22
RedirectMatch 403 \%27
RedirectMatch 403 \%28
RedirectMatch 403 \%29
RedirectMatch 403 \%3C
RedirectMatch 403 \%3E
RedirectMatch 403 \%3F
RedirectMatch 403 \%5B
RedirectMatch 403 \%5C
RedirectMatch 403 \%5D
RedirectMatch 403 \%7B
RedirectMatch 403 \%7C
RedirectMatch 403 \%7D
# COMMON PATTERNS
Redirectmatch 403 \_vpi
RedirectMatch 403 \.inc
Redirectmatch 403 xAou6
Redirectmatch 403 db\_name
Redirectmatch 403 select\(
Redirectmatch 403 convert\(
Redirectmatch 403 \/query\/
RedirectMatch 403 ImpEvData
Redirectmatch 403 \.XMLHTTP
Redirectmatch 403 proxydeny
RedirectMatch 403 function\.
Redirectmatch 403 remoteFile
Redirectmatch 403 servername
Redirectmatch 403 \&rptmode\=
Redirectmatch 403 sys\_cpanel
RedirectMatch 403 db\_connect
RedirectMatch 403 doeditconfig
RedirectMatch 403 check\_proxy
Redirectmatch 403 system\_user
Redirectmatch 403 \/\(null\)\/
Redirectmatch 403 clientrequest
Redirectmatch 403 option\_value
RedirectMatch 403 ref\.outcontrol
# SPECIFIC EXPLOITS
RedirectMatch 403 errors\.
RedirectMatch 403 config\.
RedirectMatch 403 include\.
RedirectMatch 403 display\.
RedirectMatch 403 register\.
Redirectmatch 403 password\.
RedirectMatch 403 maincore\.
RedirectMatch 403 authorize\.
Redirectmatch 403 macromates\.
RedirectMatch 403 head\_auth\.
RedirectMatch 403 submit\_links\.
RedirectMatch 403 change\_action\.
Redirectmatch 403 com\_facileforms\/
RedirectMatch 403 admin\_db\_utilities\.
RedirectMatch 403 admin\.webring\.docs\.
Redirectmatch 403 Table\/Latest\/index\.
</IfModule>
#AIOWPS_ADVANCED_CHAR_STRING_FILTER_END
#AIOWPS_BLOCK_SPAMBOTS_START
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
RewriteCond %{HTTP_REFERER} !^http(s)?://domainname\.com [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule .* http://127.0.0.1 [L]
RewriteRule ^author/(.*)/?$ /user/$1? [NC,R=301,L]
RewriteRule ^user/(.+)/?$ index.php?param=$1 [QSA,NC,L]
</IfModule>

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

<ifModule mod_headers.c>
Header set X-Frame-Options DENY
Header set Referrer-Policy: no-referrer-when-downgrade
</ifModule>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>


text:
Q: Httpd error: not accessible symlink with -D FOREGROUND I'm trying to setup virtual host in Fedora18.
Configuration is following:

*

*httpd version is 2.4

*user/group - apache/apache

*global document root is /var/www/html

*vhost symlink: /var/www/html/vhost/domain.name -> /project/www.

*all directories from / to /project/www have +x permission

When I start httpd manually (sudo httpd -k start) everything works fine. ps aux output for this case:

apache   23827  0.0  0.0 531040  7184 ?        S    17:16   0:00 httpd -k start

But once i switch to systemctl (sudo systemctl start httpd) subdomain returns 403 error (Symbolic link not allowed or link target not accessible). ps aux:

apache   23556  0.0  0.0 428700  7676 ?        S    17:00   0:00 /usr/sbin/httpd -DFOREGROUND

So I assume the difference is in -D flag but cannot find any useful info.

A: Finally found the solution. SELinux blocks some permissions of httpd process. This and this were helpful.


text:
Q: I2C concurrent access on Linux, mutex I'm writing a multithread C program in embedded Linux that accesses from userspace a number of I2C devices (slaves). Also, I access the same I2C device from multiple threads. I'm using SMBUS functions (i2c_smbus_write_byte_data, i2c_smbus_read_byte_data, i2c_smbus_read_i2c_block_data,...).
Is there any protection from concurrent access built in or do I need to add mutexes myself?
For instance: I have a Read function that read data from one sensor over I2C. But the same function can be called from another thread as well, resulting in possible concurrent access. Do I have to use some static mutex in that function or is it already in the I2C access functions?

A: I2C is a shared bus with multiple devices, which could be accessed from multiple processes as well as threads. So the Linux I2C driver code uses a mutex to manage access to each I2C bus.
For SMBus functions, see the Linux kernel function i2c_smbus_xfer() in i2c-core-smbus.c. It gets a lock for the I2C adapter before beginning a transfer (look at the source code, and see the call to __i2c_lock_bus_helper()). All SMBus transactions are based on that function.
For I2C functions, see the Linux kernel function i2c_transfer() in i2c-core-base.c. It gets a lock for the I2C adapter before beginning a transfer. All I2C transaction are based on that function.
So yes, there is protection from concurrent access built-in.
(links are for Linux kernel 5.13)

A: Use a mutex in your program. The driver has no way to know the operations that each thread is going to do.


text:
Q: Rearrange javascript object - keys using .sort() are not kept as on the array which is being sorted var tagged={"tagged":[
{"positionX":11,"positionY":13},
{"positionX":12,"positionY":18},
{"positionX":10,"positionY":20}
]};

So I have this object,
I need to reconstruct it so that it ends up looking as follows:
var tagged={"tagged":[
{"positionX":10,"positionY":20},
{"positionX":11,"positionY":13},
{"positionX":12,"positionY":18}
]};

Sorted by positionX ASC.
I have tried:
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
        var tagged={"tagged":[
        {"positionX":11,"positionY":13},
        {"positionX":12,"positionY":18},
        {"positionX":10,"positionY":20}
        ]};

        tagged=tagged.tagged;

        var newtagged=new Array();
        for (var i = 0; i < tagged.length; i++) {
        newtagged[i]=tagged[i].positionX;
        }

        var sorted=newtagged.sort(function(a,b){return a-b});

        $(sorted).each(function(k,v){
        alert(v);
        });
</script>

There indeed is a successful sort but the keys are incorrect in the new "sorted" array.
So  I am unable to retrieve all the correct values in the original object based on the original reading of the keys, I mean, without the original key of sorted I don't know to what belongs the sorted "positionX", that way I am unable to retrieve its corresponding positionY in array tagged. .sort(function(){}); assigns new keys to sorted array.

A: If I understand your question correctly you wish to sort tagged according to the value of positionX. If that's the case you can simply pass a function to sort that compares the attributes.
var sorted=tagged.sort(function(a,b){return a.positionX-b.positionX});


text:
Q: Change the url for search input I have a search form on a Drupal page (A custom view) that searches all my articles:
URL: www.site.com/articles
<form>
  <input type="text" placeholder="Search Library" class="searchbox">
  <button type="submit" id="edit-submit" name="op" value="Search" class="form-submit">Search</button>
</form>

When a user submits this form I get a string appended to the end of the url like this:
www.site.com/articles?search_fulltext=SEARCHTERM&op=Search

The problem is that it's not working, and to get it to work I have to search from a different page like here:
www.site.com/search?search_fulltext=SEARCHTERM&op=Search

So ultimately I would like to have my search box on a page, but when a user submits I want it to reference another url:
www.site.com/search?search_fulltext=SEARCHTERM&op=Search

I basically want to have a search box on a different page that is being searched. If that makes any sense. :)

A: Use the <form> tag's action attribute to submit the form to the search page like:
<form action="http://www.site.com/search">

I also just realized that you are probably only looking to search specific content types so you may wish to look into the Custom Search module (http://drupal.org/project/custom_search).


text:
Q: How to enable NSZombie in Xcode? I have an app that is crashing with no error tracing. I can see part of what is going on if I debug, but can't figure out which object is "zombie-ing".
Does anybody know how to enable NSZombie in Xcode 4?

A: As of Xcode 3.2.5 and Snow Leopard (Mac OS X 10.6), you can run your code through the Zombies instrument: Run > Run with Performance Tool > Zombies. That allows you to see particular objects and their retain counts on a timeline.

A: Environment variables are now part of the "scheme".
To edit the scheme and turn on zombies:

*

*In the "Product" menu, select "Scheme" > "Edit Scheme...".

*Go to the "Run Foo.app" stage in the left panel, and the "Arguments" tab on the right.

*Add NSZombieEnabled to the "Environment Variables" section and set the value to YES, as you could in Xcode 3.

In Xcode 4.1 and above, there's also a checkbox on the "Diagnostics" tab of the "Run" stage to "Enable Zombie Objects".

With Xcode 6.4:

A: Product > Profile will launch Instruments and then you there should be a "Trace Template" named "Zombies". However this trace template is only available if the current build destination is the simulator - it will not be available if you have the destination set to your iOS device.
Also another thing to note is that there is no actual Zombies instrument in the instrument library. The zombies trace template actually consists of the Allocations instrument with the "Enable NSZombie detection" launch configuration set.

A: In Xcode 4.5.2 goto Product -> Edit Scheme -> and Under the Diagnostics tab check the check box in between Objective C and Enable Zombie Objects and Click on OK

A: To enable Zombie logging double-click the executable in the executables group of your Xcode project. At this point click the Arguments tab and in the Variables to be set in the environment: section, make a variable called NSZombieEnabled and set its value to YES.

A: In XCode 4.0: To detect NSZombie in Instruments, select the Simulator as your target (can't detect NSZomboe on device). Run Instruments (CMD+I) and select "Zombies" trace template. Enjoy.

A: It's a simple matter of setting an environment variable on your executable (NSZombieEnabled = YES), and then running/debugging your app as normal.If you message a zombie, your app will crash/break to debugger and NSLog a message for you.
For more information, check out this CocoaDev page:  http://www.cocoadev.com/index.pl?NSZombieEnabled
Also, this process will become much easier with the release of 10.6 and the next versions of Xcode and Instruments.  Just saying'.  =)

A: Product > Profile will pop up Instruments. Select zombies from the panel and go nuts.

A: In the preferences of your executable add the environment variable NSZombieEnabled and set the value to YES.

A: in ur XCODE (4.3) next the play button :) (run)
select : edit scheme
the scheme management window will open
click on the Arguments tab
you should see : 1- Arguments passed on launch
                 2- environment variables
inside the the (2- environment variables) place
Name: NSZombieEnabled
Value: YES
And its done....

A: Go to Product - Scheme - edit scheme - Arguments - Environment Variables set NSZombieEnabled = YES

A: I encountered the same problem with troubleshooting EXC_BAD_ACCESS and had hard time to find the setting with Xcode 4.2 (the latest one that comes with iOS5 SDK). Apple keeps on moving things and the settings are no longer where they used to be.
Fortunately, I've found it and it works for the device, not just Simulator. You need to open the Product menu in the Xcode, select Edit scheme and then choose the Diagnostics tab. There you have "Enable Zombie Objects". Once selected and run in debugger will point you to the double released object! Enjoy!
In short
Product->Edit Scheme->Diagnostics-> Click Enable Zombie Objects

A: In xcode 4.2
Goto, Product -> edit scheme -> click Run yourappname.app -> Diagonostics -> Enable Zombie object.

A: Here's a video and explaination how to use Instruments and NSZombie to find and fix memory crashes on iOS:
http://www.markj.net/iphone-memory-debug-nszombie/

A: NSZombieEnabled is used for Debugging BAD_ACCESS,
enable the NSZombiesEnabled environment variable from Xcode's schemes sheet.
Click on Product⇒Edit Scheme to open the sheet and set the Enable Zombie Objects check box
this video will help you to see what i'm trying to say.


text:
Q: How to get screenshot for all hidden list items of a list in WPF I have an issue in a WPF Application, I want to get a screenshot for a ListBox.
The list contain more than 100 items, some of items are hidden by scrolling down. Only get the items which are not hidden in scroll when take a screenshot.
Could you please help me out in getting all the items of list for one screenshot?

A: If the ListView is to be visible while rendering it to an image you can put it (preferably temporarily) inside a ScrollViewer, which will give it an infinite layout space, so the ListViewItems aren't virtualized away from the render, then you can use RenderTargetBitmap on the ListView.
If you don't have to show the ListView you can render it off-screen as this answer shows, like so:
var listView = new ListView{ ItemsSource = ... etc }
listView.Measure(new Size(10000, 20000));
listView.Arrange(new Rect(new Size(10000, 20000)));

RenderTargetBitmap bmp = new RenderTargetBitmap(listView.ActualWidth, listView.ActualHeight, 96, 96, PixelFormats.Pbgra32);

bmp.Render(control);

var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
encoder.Save(somewhere);


text:
Q: Floating on both sides separately without interfering I would like to decorate and shape the left and right borders of my text using float and clear properties. To start I have this markup which looks like the left and right stair steps should both start at the top of the page. However, the stairs aren't vertically aligned; the second stairs seem to always start drawing at the second-to-last step on the other side.

Left

Left Two

Left Number Three

Right

Right Two

Right Number Three

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... .

The result (same in Chrome + Firefox):

I'd like the stairs to both start at the beginning, as they seem like they should, since I'm only clearing floats on the side they're on. Note that I'm not just shaping the borders, I'm also showing important things on the shaped sides.

A: A floated element isn't positioned independently of the document flow - it's vertically placed wherever the preceding element is (be it a block, floated or not, or inline content) - in the flow of elements inside the document.
So what you are looking for (floated elements with content floating around it, but independently left and right independent from the document flow) is basically impossible.
EDIT:
Here's the code from the comment below, with some longer text in it to show what I mean:

div,
p {
  font-size: 24px;
  margin: 0;
  text-align: center;
}

Left

Right

Some text in between

Left Two

Right Two

Some more text in between. Some more text in between,  in between,  in between. Some more text in between.

Left Number Three

Right Number Three

And again less text in between.

So a workaround like that can only work with a very little amount of content/text (or none) in between. (Note also that I set the p's margins to 0, otherwise there would be whitespace between the "steps".)

A: You could fake this with clearing the float on the 3 last items and use direction to get the right alignement for the last 3 items too.
example from a list:

/* required */

.stairCcase {
  direction: rtl;
}

.stairCcase li {
  float: left;
  clear: left;
  direction: ltr;
}

.stairCcase :nth-child(3)~li {
  float: none;
  clear: none;
  display: table; /* or width:max-content instead display */
}

/* reset & styles for demo*/

* {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

ul {
  width: 10em;
  margin: auto;
}

li {
  background: green;
  padding:0.25em;
}

li:nth-child(3)~li {
  background: red;
}

0

0 0

 0 0 0

1

1 1

1 1 1

a few ressources about float : https://css-tricks.com/?s=float&orderby=relevance&post_type=post%2Cpage%2Cguide & direction https://css-tricks.com/?s=direction&orderby=relevance&post_type=post%2Cpage%2Cguide

for such a layout, you should consider using the grid display.
Example below

ul {
  display: grid;
  grid-template-areas:
  "left    .     .   .   .      .    right "
  "left2 left2   .   .   .    right2 right2"
  "left3 left3 left3 . right3 right3 right3"
}

li {
  grid-area: left;
  border:solid;
}

li:nth-child(2) {
  grid-area: left2
}

li:nth-child(3) {
  grid-area: left3
}

li:nth-child(4) {
  grid-area: right
}

li:nth-child(5) {
  grid-area: right2
}

li:nth-child(6) {
  grid-area: right3
}

* {
  margin: 0;
  padding: 0;
  list-style: none;
}

ul {
  counter-reset: lis
}

li:before {
  counter-increment: lis;
  content: counter(lis);
}

https://css-tricks.com/snippets/css/complete-guide-grid/#prop-grid-template-areas

A: The easyest way to solve the problem,
just to change places the rows like this:
green, red, green, red, green, red.
This code works properly:

Left

Right

Left Two

Right Two

Left Number Three

Right Number Three


text:
Q: Pass multiple variable values through ajax to php file, run mysql query and retrieve data UPDATE: I want to retrieve student full name from mysql table based on the roll number, course and semester values entered by the user.
The user types in the roll number in a text field while selects the course and semester from the select list. I want to retrieve the student name in a text field when user selects the semester from the select list after entering the roll number and selecting the course.
I am now able to retrieve student's first name in the text-box. Is there anyway I can retrieve student's middle and last name and display them in two different text boxes? Please help.
Following is the code I am using:
HTML Code:
    <form id="formname1" action = "" method= "post">

                Roll No.*
                <input type = "text" id = "roll_number" name = "roll_number">

                Course:*

                    <select name ="course_name" id = "course">
                        <option value = "">Select</option>
                        <option value = "B.Ed">B.Ed</option>
                        <option value = "M.Ed">M.Ed</option>
                    </select>

                Semester:*

                    <select name ="sem" id = "sem">
                        <option value = "">Select</option>
                        <option value = "1">1</option>
                        <option value = "2">2</option>
                        <option value = "3">3</option>
                        <option value = "4">4</option>

                    </select>

                Student Name:*
                <input type = "text" id = "f_name" name = "s_name">

                <input type = "text" id = "m_name" name = "m_name">

                <input type = "text" id = "l_name" name = "l_name">

    </form>

AJX code:

PHP File:
      <?php

        $con=mysqli_connect("$host", "$username", "$password", "$db_name");

$rows1 = array[];

$sql = "select first_name, middle_name, last_name from students s, students_in_courses sin
where s.roll_number = sin.roll_number
AND s.roll_number = '$roll'
AND sin.course_name = '$course'
AND sin.semester = '$sem' ";

$result = mysqli_query($con,$sql);

if(!$result)
    {
        echo "No records matching your query were found.";
    }
    else
    {
        while ($rows = mysqli_fetch_array($result))
        {
            //echo $rows[first_name];
            //echo $rows[middle_name];
            //echo $rows[last_name];
            $rows1[]= $rows;
        }
    }
    ?>

A: An input can't be a content parent tag.
Change :
$("#s_name").html(data);

To :
$("#s_name").val(data);

A: Here is the correct script code :-
$(document).ready(function () {

            $("#sem").change(function(){

             var roll_no = $("#roll_number").val();
             var course = $("#course").val();
             var sem = $("#sem").val();
             $.post("test.php",{
             r_no:roll_no,cname:course,semester:sem},
             function(data){
             $("#s_name").val(data);
             });
             });
 });


text:
Q: YouTube Direct - Getting Started - Failure after running eclipse i get crazy. I wanna use the google youtube direct and i have followed exactly the instruction of code.google.com/p/youtube-direct/wiki/GettingStarted
but in the end, when i´d try to run (debug) the YTD in eclipse for testing it local, i get the following failur code instead the message, that the server is available under
(localhost:8080/)
I have installed - jdk 1.6.0.38  & jdk 1.7.0.10
also the latest google eclipse plugin
i have adapted the appengine-web.xlm file as mentioned with my id and the developer key
i am totally lost for the moment. may you can help. thanks
11.01.2013 22:41:39 com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
11.01.2013 22:41:39 com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\Users\martin\workspace1\ytd\war\WEB-INF/appengine-web.xml
11.01.2013 22:41:39 com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed C:\Users\martin\workspace1\ytd\war\WEB-INF/web.xml
11.01.2013 22:41:39 com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value 'D:\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.4\appengine-java-sdk-1.7.4\config\sdk\logging.properties' with value 'WEB-INF/logging.properties' from 'C:\Users\martin\workspace1\ytd\war\WEB-INF\appengine-web.xml'
11.01.2013 22:41:39 com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
11.01.2013 22:41:40 com.google.apphosting.utils.jetty.JettyLogger warn
WARNUNG: failed com.google.appengine.tools.development.DevAppEngineWebAppContext@4a1c2f8c{/,C:\Users\martin\workspace1\ytd\war}: java.lang.UnsupportedClassVersionError: com/google/ytd/guice/GuiceServletConfig : Unsupported major.minor version 51.0
11.01.2013 22:41:40 com.google.apphosting.utils.jetty.JettyLogger warn
WARNUNG: failed JettyContainerService$ApiProxyHandler@75b657: java.lang.UnsupportedClassVersionError: com/google/ytd/guice/GuiceServletConfig : Unsupported major.minor version 51.0
11.01.2013 22:41:40 com.google.apphosting.utils.jetty.JettyLogger warn
WARNUNG: Error starting handlers
java.lang.UnsupportedClassVersionError: com/google/ytd/guice/GuiceServletConfig : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:213)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.mortbay.jetty.handler.ContextHandler.loadClass(ContextHandler.java:1101)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfiguration.java:630)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfiguration.java:368)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration.java:289)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.configure(WebXmlConfiguration.java:222)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXmlConfiguration.java:180)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1247)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:205)
    at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:232)
    at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:157)
    at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:333)
    at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
    at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:269)
    at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:245)
11.01.2013 22:41:40 com.google.apphosting.utils.jetty.JettyLogger info
INFO: Started SelectChannelConnector@127.0.0.1:8888
11.01.2013 22:41:40 com.google.appengine.tools.development.DevAppServerImpl start
INFO: The server is running at http://localhost:8888/
11.01.2013 22:41:40 com.google.appengine.tools.development.DevAppServerImpl start
INFO: The admin console is running at http://localhost:8888/_ah/admin

A: Have you checked the port of the server in which it was running, your eclipse console message says that it is running on http://localhost:8888/ and you are trying to run it on http://localhost:8080/
And you can see the YTD admin under http://localhost:8888/admin


text:
Q: Ocultar o mostrar al hacer scroll Estoy intentando hacer una animación simple: Cuando se scrollee hacia abajo en un RecyclerView que se oculte la barra superior, y cuando se scrollee hacia arriba y se llegue al item #1 que se vuelva a mostrar. Lo hago de esta forma:
RecyclerView vRecyclerView = FindViewById<RecyclerView>(Resource.Id.RecyclerNewsFeedI);
vRecyclerView.ScrollChange += delegate
            {
                OcultarMostrarSuperiores();
            };

Ocupo una variable global publica llamada VarGlobal.gFlagoScroll1 que toma el Id del position en el OnBindViewHolder() para que me diga cuando la (position > 2) y (position < 2).
OcultarMostrarSuperiores()
{
            if (VarGlobal.gFlagoScroll1 >= 2)
            {
                vxLinearLayout = FindViewById<LinearLayout>(Resource.Id.linearLayoutTNF);
                vxLinearLayout.Visibility = Android.Views.ViewStates.Gone;

                vxLinearLayout = FindViewById<LinearLayout>(Resource.Id.LayoutNFB);
                vxLinearLayout.Visibility = Android.Views.ViewStates.Gone;
            }
            else
            {
                vxLinearLayout = FindViewById<LinearLayout>(Resource.Id.linearLayoutTNF);
                vxLinearLayout.Visibility = Android.Views.ViewStates.Visible;

                vxLinearLayout = FindViewById<LinearLayout>(Resource.Id.LayoutNFB);
                vxLinearLayout.Visibility = Android.Views.ViewStates.Visible;
            }
}

Funciona bien cuando scrolleo hacia abajo, el problema es que cuando quiero scrollear hacia arriba funciona solo cuando estoy muy abajo, (como por el item 8) debido a que de lo contrario aun no se ha reciclado el CardView del item 2 y no gatilla el OnBindViewHolder el item 2 por lo que no se me actualiza la variable VarGlobal.gFlagoScroll1.
Alguna idea de como lograrlo de una manera mas fiable?

A: Listo.
Queda de la siguiente forma:
vRecyclerView.ScrollChange += delegate
            {
                OcultarMostrarSuperiores();
            };

OcultarMostrarSuperiores()
{

    int PrimerElementoActualVisible = linearLayoutManager.FindFirstVisibleItemPosition();

                if (PrimerElementoActualVisible > 0) //Condicion opcional
                {
                    vxLinearLayout = FindViewById<LinearLayout>(Resource.Id.linearLayoutTNF);
                    vxLinearLayout.Visibility = Android.Views.ViewStates.Gone;

                    vxLinearLayout = FindViewById<LinearLayout>(Resource.Id.LayoutNFB);
                    vxLinearLayout.Visibility = Android.Views.ViewStates.Gone;
                }
                else
                {
                    vxLinearLayout = FindViewById<LinearLayout>(Resource.Id.linearLayoutTNF);
                    vxLinearLayout.Visibility = Android.Views.ViewStates.Visible;

                    vxLinearLayout = FindViewById<LinearLayout>(Resource.Id.LayoutNFB);
                    vxLinearLayout.Visibility = Android.Views.ViewStates.Visible;
                }
}


text:
Q: Full screen modal view controller not covering status bar area I'm having a UISplitViewController as root in my story board. The detail view controller is showing an pop over with a view controller embedded in a navigation controller.
I have a button in the pop over view controller that is showing the UIImagePickerController with UIImagePickerControllerSourceTypeCamera as source:

[self.controller presentViewController:self.imagePickerController animated:YES completion:nil];

The status bar disappears but there is still a black bar in the status bar area and the UIImagePickerController starts below the status bar. But it is still in full screen height so it is getting cut in the toolbar Here is an image:

If I rotate the screen it jumps to full screen, but then when I dismiss the UIImagePickerController the UISplitViewController is suddenly behind and partly covered by the status bar. But when I rotate it again, the UISplitViewController jumps back to being below the status bar and everything is fine again.
If I instead of the view controller in the pop over present the UIImagePickerViewController from the root view controller like this:

[self.window.rootViewController presentViewController:self.imagePicker animated:YES completion:nil];

Then it gets full screen like it should, but the pop over appears in front of the UIImagePickerViewController.
(1) Why isn't the full screen presentation of the UIImagePickerViewController working like it should?
(2) Why is the pop over above the UIImagePickerViewController when I show it from the root view controller?
(3) What is the proper way to solve this?


text:
Q: How to use image as subtitle in toolbar? I use the Toolbar as an ActionBar. I can set a subtitle, however is it possible to have e.g. an ImageView as a subtitle instead of text only?

A: The Toolbar is just a ViewGroup,so you can define your favorite views inside it.
For example:
<android.support.v7.widget.Toolbar
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:id="@+id/toolbar"
    android:minHeight="?attr/actionBarSize">

        <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:orientation="vertical">

              <TextView android:id="@+id/textView"..../>

              <ImageView
                  android:id="@+id/imageView"
                  android:layout_height="wrap_content"
                  android:layout_width="wrap_content" />

        </LinearLayout>

</<android.support.v7.widget.Toolbar>

Then in your code:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
TextView title = mToolbar.findViewById(R.id.textView);
ImageView image = mToolbar.findViewById(R.id.imageView);

A: Toolbar behaves just like any other view. So you could into the xml definition of the toolbar, split it vertically (with weight sum) to accommodate your ImageView container, and place an ImageView there.
Then, in your Activity, you could set the image:
ImageView subtitleImage = mToolbar.findViewById(R.id.subtitle_imageview);
subtitleImage.setImageResource(R.drawable.your_image_view);


text:
Q: Appending a char w/ null terminator in C perhaps a lil trivial, but im just learning C and i hate doing with 2 lines, what can be done with one(as long as it does not confuse the code of course).
anyway, im building strings by appending one character at a time. im doing this by keeping track of the char index of the string being built, as well as the input file string's(line) index.
str[strIndex] = inStr[index];
str[strIndex + 1] = '\0';

str is used to temporarily store one of the words from the input line.
i need to append the terminator every time i add a char.
i guess what i want to know; is there a way to combine these in one statement, without using strcat()(or clearing str with memset() every time i start a new word) or creating other variables?

A: Simple solution: Zero out the string before you add anything to it. The NULs will already be at every location ahead of time.
// On the stack:
char str[STRLEN] = {0};

// On the heap
char *str = calloc(STRLEN, sizeof(*str));

In the calloc case, for large allocations, you won't even pay the cost of zeroing the memory explicitly (in bulk allocation mode, it requests memory directly from the OS, which is either lazily zero-ed (Linux) or has been background zero-ed before you ask for it (Windows)).
Obviously, you can avoid even this amount of work by defering the NUL termination of the string until you're done building it, but if you might need to use it as a C-style string at any time, guaranteeing it's always NUL-terminated up front isn't unreasonable.

A: Declare a char array:
char str[100];

or,
char * str = (char *)malloc(100 * sizeof(char));

Add all the character one by one in a loop:
for(i = 0; i<length; i++){
    str[i] = inStr[index];
}

Finish it with a null character (outside the loop):
str[i] = '\0';

A: I believe the way you are doing it now is the neatest that satisfies your requirement of
1) Not having string all zero to start with
2) At every stage the string is valid (as in always has a termination).
Basically you want to add two bytes each time. And really the most neat way to do that is the way you are doing it now.
If you are wanting to make the code seem neater by having the "one line" but not calling a function then perhaps a macro:
#define SetCharAndNull( String, Index, Character )  \
{                                                   \
    String[Index] = (Character);                    \
    String[Index+1] = 0;                            \
}

And use it like:
SetCharAndNull( str, strIndex, inStr[index]);

Otherwise the only other thing I can think of which would achieve the result is to write a "word" at a time (two bytes, so an unsigned short) in most cases. You could do this with some horrible typecasting and pointer arithmetic. I would strongly recommend against this though as it won't be very readable, also it won't be very portable. It would have to be written for a particular endianness, also it would have problems on systems that require alignment on word access.
[Edit: Added the following]
Just for completeness I'm putting that awful solution I mentioned here:
*((unsigned short*)&str[strIndex]) = (unsigned short)(inStr[index]);

This is type casting the pointer of str[strIndex] to an unsigned short which on my system (OSX) is 16 bits (two bytes). It is then setting the value to a 16 bit version of inStr[index] where the top 8 bits are zero. Because my system is little endian, then the first byte will contain the least significant one (which is the character), and the second byte will be the zero from the top of the word. But as I said, don't do this! It won't work on big endian systems (you would have to add in a left shift by 8), also this will cause alignment problems on some processors where you can not access a 16bit value on a non 16-bit aligned address (this will be setting address with 8bit alignment)


text:
Q: Unknown 'DataDriver' library while using excel file Implementing a datadriven framework using .xlsx file as external data source for a robot datadriven framework.
I have added the code as -
Library    DataDriver  ../TestData/Login.xlsx  sheet_name=Sheet1
but throwing error as - "Unknown 'DataDriver' library. Try to use Quick Fix (Ctrl+1) or add library to red.xml for proper validation"
I have added the library to red.xml file as given - C:/Python/Lib/site-packages/DataDriver/init.py and I have used pip install --upgrade robotframework-datadriver to install. Am i missing anything else? Python version is 3.10.1

A: It worked by rebuilding the project. (Project > Build Automatically)


text:
Q: How to remove the background colour of HTML page? I'm creating a web app for a side project and not sure how to remove the grey background-colours behind each of the images. To test the back-end, I have implemented my HTML page with CSS and JavaScript. I'm not sure certain whether I need to change it from CSS or JavaScript code..

I tried everything by making the background-colour as white or transparent, but it doesn't seem to work properly.
HTML
<!doctype html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">

  <title>Good Cop, Bad Cop</title>

  <link rel="stylesheet" href="../css/landing.css" />
  <link rel="stylesheet" href="../css/coach_selection.css" />

  <link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/4.6.1/firebase-ui-auth.css" />

      <button type="button" id="dog-button" class="btn btn-light">

      </button>

      <button type="button" id="mother-button" class="btn btn-light">

      </button>

      <button type="button" id="soldier-button" class="btn btn-light">

      </button>

      <button type="button" id="teacher-button" class="btn btn-light">

      </button>

Other

    Confirm

CSS
.image {
  display: grid;
  grid-template-columns: 50% 50%;
  grid-template-rows: 50% 50%;
  margin-top: 40px;
  margin-left: 50px;
}

.image img {
  cursor: pointer;
}

.image img:hover {
  border: solid 2px #1e88e5;
  border-radius: 2px;
}

.image #mother img:hover {
  border: solid 2px #1e88e5;
  border-radius: 2px;
}

.image img {
  width: 100px;
  height: 100px;
  text-align: center;
  padding: 10px;
  margin-left: 30%;
}

.button{
  width: 80px;
  height: 40px;
  margin: 10px auto 0px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 8px;
  padding-bottom: 8px;
  background-color: rgb(43, 43, 219);
  cursor: pointer;
  border-radius: 2px;
}

.button:hover{
   background-color: #242424;
}
.button:active{
   background-color: #121212;
}

.button > span{
  color: #eeeeee;
  text-align: center;
}

JavaScript
var elementSelected = null;
var typeSelected = false;

$(document).on('click', '.image > img', function(){
  $('.image > img').each(function(){
    $(this).removeClass('active');
  })
  $(this).addClass('active');
  elementSelected = $(this);
  typeSelected = false;
});

$(document).on('input', '#text-src', function(){
  $('.image > img').each(function(){
    $(this).removeClass('active');
  })
  elementSelected = $(this);
  typeSelected = true;
})

$(document).on('click', '#button-confirm', function(){
  $('.image').hide();
  if(typeSelected == true){
    $('.view-image > img').attr('src', elementSelected.val());
    $('.button').hide();
  }
  else{
    $('.view-image > img').attr('src', elementSelected.attr('src'));
  }
  $('.view-image').fadeIn('high');
})

$(document).on('click', '#button-other', function(){
  $('.view-image').hide();
  $('.image').fadeIn('high');
})

A: The light grey is provided by the class btn-light on the respective button elements. This class is defined in bootstrap.min.css. If you remove it, the buttons are styled as default, without background color.

A: it is from your css for the button element.
.button{
  width: 80px;
  height: 40px;
  margin: 10px auto 0px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 8px;
  padding-bottom: 8px;
  background-color: rgb(43, 43, 219);
  cursor: pointer;
  border-radius: 2px;
}

just remove the background-color.
I think you want to have hover effect on your round image. you just need to add the radius to the image and button elements.


text:
Q: acts_as_taggable not filtering by tag I am following along the acts_as_taggable screencast but cannot seem to get the tag pages to filter by tag (instead it just shows all the posts).
Here is my posts#index:
def index
if params[:tag]
 @posts = Post.tagged_with(params[:tag])
else
 @posts = Post.order("created_at desc")
end
end

my routes.rb:
 get 'tags/:tag', to: 'posts#index', as: :tag

the link to the tags page:
Tags: <%= raw post.tag_list.map { |t| link_to t, tag_path(t) }.join(', ') %>

and the posts model:
acts_as_taggable


text:
Q: Chage configurable setting's object outside Revealing Module Pattern I am trying to practice different module patterns. Below is IIFE pattern for a scroll function that can be used for different elements in different pages (not sure this is the right pattern for the purpose).
My question is
1. how to replace the config = {} options outside IIFE module?
2. I name every single functions, not sure if this is an overkill or suggested way in write this kind of code.
3. What would be a better module pattern for the purpose?
  ;(function($, ScrollToTop, undefined) {
    'use strict';

    var clickedElem = $('[data-scroll]');
    var config = {
      scrollDistance: 500,
      speed: 300
    };

    var _scrollToTargetAnimation = function () {
      $('body').animate({
        scrollTop: $($(this).data('scroll')).offset().top
      }, config.speed);
      return false; //stop bubbling
    };

    var _showHideAnimation = function () {
        if ($(this).scrollTop() > config.scrollDistance) {
          clickedElem.fadeIn(config.speed);
        } else {
          clickedElem.fadeOut(config.speed);
        }
    };

    ScrollToTop.showHide = function() {
      if ($('.top-bar').length) return;
      $(document).scroll( _showHideAnimation );
    };

    ScrollToTop.clickBtn = function() {
      clickedElem.on('click', _scrollToTargetAnimation );
    };

    ScrollToTop.init = function (config) {
      $.extend(this.config, config);
      ScrollToTop.showHide();
      ScrollToTop.clickBtn();
    };

  })(jQuery, window.ScrollToTop = window.ScrollToTop || {});

  $(function() {
    config = {
      scrollDistance: 500,
      speed: 300
    };
    ScrollToTop.init(config);
  });

A: First, what you have isn't a module pattern. A module pattern is concerned with creating an object from scratch and hiding some of its properties and methods. Your example is a decorator -- you pass in an object ScrollToTop and decorate it with additional methods. Some of the techniques are similar to that of the module pattern -- the use of an IIFE, using closure to hide private variables -- but the intent is different. I'd recommend that you read this post to understand the difference between the module pattern variants.
As I understand your question, you have a default config object inside your decorator you'd like to modify. Since your decorator function accomplishes it objective using a side effect, you can use your decorator to return a configManager which you can use to mutate the inner default config.
var configManager = (function($, ScrollToTop, undefined) {

  var clickedElem = $('[data-scroll]');
  var defaultConfig = {
    scrollDistance: 500,
    speed: 300
  };

  var _scrollToTargetAnimation = function () {
    // ...
  };

  var _showHideAnimation = function () {
    // ...
  };

  ScrollToTop.showHide = function() {
    // ...
  };

  ScrollToTop.clickBtn = function() {
    // ...
  };

  ScrollToTop.init = function (config) {
    // ...
  };

  return {
    setConfig: function(config){
        defaultConfig = config;
    }
  };
})(jQuery, window.ScrollToTop = window.ScrollToTop || {});

$(function() {
  config = {
    scrollDistance: 500,
    speed: 300
  };
  ScrollToTop.init(config);
});

configManager.setConfig({
  scrollDistance: 400,
  speed: 200
});

ADDED in response to OP's question: The reason why $.extend doesn't work in
ScrollToTop.init = function (config) {
  $.extend(this.config, config);

is because the parameter config is hiding the closure's config and this.config doesn't point to anything at all. This is easily changed by renaming the parameter so it doesn't hide the closure's config
ScrollToTop.init = function (config2) {
  $.extend(config, config2);


text:
Q: calculating $C_G(a)$ when $a\in G=S_3$ Let $G$ be a group and $a\in G$. $C_G(a)=\{g\in G | ga=ag\}$ is called the center of $a$ in $G$.
In order to understand this theorem I'm trying to find $C_G(a)$ for all $a\in G=S_3$.
As I understand:
$$ C_{G}\left(\begin{pmatrix}1 & 2 & 3\\
1 & 2 & 3
\end{pmatrix}\right)=\left\{ g\in G\,:\,g\begin{pmatrix}1 & 2 & 3\\
1 & 2 & 3
\end{pmatrix}=\begin{pmatrix}1 & 2 & 3\\
1 & 2 & 3
\end{pmatrix}g\right\} =S_{3}$$
I understand the logic behind it but what would be the way to prove it formally?
How to calculate formally:
$$ C_{G}\left(\begin{pmatrix}1 & 2 & 3\\
1 & 3 & 2
\end{pmatrix}\right)=\left\{ g\in G\,:\,g\begin{pmatrix}1 & 2 & 3\\
1 & 3 & 2
\end{pmatrix}=\begin{pmatrix}1 & 2 & 3\\
1 & 3 & 2
\end{pmatrix}g\right\}$$

A: The first part, that $C_{S_3}(e)=S_3$ follows from the fact that $e$ commutes with everything.
$S_3=\{e,(12),(13),(23),(132),(312)\}$.
You can check that $C_{S_3}(23)=\{e,(23)\}$.  For instance,  $(12)(23)\neq(23)(12)$.  There are three more to check.


text:
Q: how to add spinner before loading Images in recyclerview item I am using Data Binding to Getting Layout and Glide Library to load Images from Adapter class. Now I want to attach progress spinner before loading images on each row but currently, I don't know how to load ?? Thanks
Here is my Adapter class
public class ImageSetAdapter extends RecyclerView.Adapter<ImageSetAdapter.PictureItemHolder> {

    List<HouseModelSet> data;
    HousesListener housesListener;

    public ImageSetAdapter(List<HouseModelSet> data) {
        this.data = data;
    }

    @Override
    public PictureItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
         /*View v = inflater.inflate(R.layout.item_home_picture, parent, false);
            ItemHomePictureBinding itemHomePictureBinding = DataBindingUtil.inflate(inflater, R.layout.item_home_picture, parent, false);*/

        ItemHomePictureBinding binding = ItemHomePictureBinding.inflate(inflater, parent, false);

        return new PictureItemHolder(binding.getRoot());
    }

       @Override
    public void onBindViewHolder(PictureItemHolder holder, final int position) {
       HouseModelSet houseSetModel = data.get(position);
       List<PostModel> postModels = houseSetModel.getHouseModels();
       if (postModels.size() > 4) {
           final PostModel hm1 = postModels.get(0);
           final PostModel hm2 = postModels.get(1);
           final PostModel hm3 = postModels.get(2);
           final PostModel hm4 = postModels.get(3);
           final PostModel hm5 = postModels.get(4);

           holder.binding.house1.setHouse(hm1);
           holder.binding.house2.setHouse(hm2);
           holder.binding.house3.setHouse(hm3);
           holder.binding.house4.setHouse(hm4);
           holder.binding.house5.setHouse(hm5);
           holder.binding.setHouses(houseSetModel);

           holder.binding.house1.getRoot().setOnClickListener(new View.OnClickListener(){
               @Override
               public void onClick(View v) {
                   if (housesListener != null) {
                       housesListener.onHouseClick(position, hm1);
                   }
               }
           });

           holder.binding.house2.getRoot().setOnClickListener(new View.OnClickListener(){
               @Override
               public void onClick(View v) {
                   if (housesListener != null) {
                       housesListener.onHouseClick(position, hm2);
                   }
               }
           });

           holder.binding.house3.getRoot().setOnClickListener(new View.OnClickListener(){
               @Override
               public void onClick(View v) {
                   if (housesListener != null) {
                       housesListener.onHouseClick(position, hm3);
                   }
               }
           });

           holder.binding.house4.getRoot().setOnClickListener(new View.OnClickListener(){
               @Override
               public void onClick(View v) {
                   if (housesListener != null) {
                       housesListener.onHouseClick(position, hm4);
                   }
               }
           });

           holder.binding.house5.getRoot().setOnClickListener(new View.OnClickListener(){
               @Override
               public void onClick(View v) {
                   if (housesListener != null) {
                       housesListener.onHouseClick(position, hm5);
                   }
               }
           });

       }
    }

    @BindingAdapter("app:imageUrl")
    public static void loadImage(ImageView imageView, String url) {
        Glide.with(imageView.getContext())
                .load(ApiHelper.BASE_URL + url)
                .thumbnail(0.5f)
                .crossFade()

                .into(imageView);
    }

    public void setHousesListener(HousesListener housesListener) {
        this.housesListener = housesListener;
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class PictureItemHolder extends RecyclerView.ViewHolder{

        ItemHomePictureBinding binding;

        public PictureItemHolder(View itemView) {
            super(itemView);
            binding = DataBindingUtil.bind(itemView);
        }

    }

    public void updateList(List<HouseModelSet> list) {
        this.data = list;
        notifyDataSetChanged();
    }

    public interface HousesListener{
        void onHouseClick(int pos, PostModel houseModel);
    }
}

A: maybe you can add listener to showing the spinner progress.
You can change your code to this :
Glide.with(imageView.getContext())
        .load(ApiHelper.BASE_URL + url)
.listener(new RequestListener<String, GlideDrawable>() {
    @Override
    public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
        yourSpinnerProgress.setVisibility(View.GONE);
        return false;
    }

    @Override
    public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
        yourSpinnerProgress.setVisibility(View.GONE);
        return false;
    }
})
.into(imageView);

And don't forget to use RelativeLayout for root of layout & add yourSpinnerProgress into your layout.


text:
Q: How to stopService when App is fired I got a problem puzzling me a long time
Activity A in Application APP
In onDestroy(), I need to call function B() to release some resource, but when I press Home and remove APP, onDestroy() can not be callback. What I should do? Do not call B() in onPause() or onStop()
PS: I am making a Android MusicPlayer, I need to stopService() when App is killed, help!