text:
Q: CSS overflow:hidden with floats I read the following code on w3schools and do not understand how the overflow property would impact whether text appears to the right of the ul or not.

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

li {
  float: left;
}

a {
  display: block;
  width: 60px;
  background-color: #dddddd;
  padding: 8px;
}

Home

News

Contact

About

Note: overflow:hidden is added to the ul element to prevent li elements from going outside of the list.

I know that overflow:hidden is used to handle content that goes outside of the box but don't understand how it applies in this instance.

A: I try to end the confusion:
ul is a block-level element as is the p element (they stretch to 100% of the parent width). That is why per default the p will appear below the ul if no width or display is declared on those elements.
Now in your example the ul contains only floated elements. This makes it collapse to a height of 0px (It still has 100% width though as you can see in the example). The adjacent p will appear to the right of the floated lis because they are considered as normal floated elements.
Now declaring overflow (any value other than visible) establishes a new block formatting context, which makes the ul contains its children. Suddenly the ul "reappears", not having size 0px anymore. The p is getting pushed to the bottom. You could also declare position:absolute to achieve the same "clearing" effect (with the side effect that now the ul is taken out of the normal element flow - the ps will be overlapped by the ul.)
See the example fiddle
If you are into the technical stuff, compare the according paragraphs of the CSS spec:
§10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
and
§10.6.7 'Auto' heights for block formatting context roots. (Thanks to BoltClock for digging out the links).

ul{
    list-style-type:none;
    margin:0; padding:0;
    background-color:#dddddd;
    border:2px solid red;
}
li{
    float:left;
}
a{
    display:block;
    width:60px;
    background-color:#555;
    color:white;
}
p{
    margin:0;
    outline:2px dotted blue;
}
#two{
    clear:both;
    overflow:hidden;
}
No overflow:

Home

News

Contact

About

Notice the collapsed ul - no background-color visible, collapsed border and this paragraph treats the lis as regular floats

With overflow: hidden

Home

News

Contact

About

the ul reappeared - it now contains the child li's - the float is cleared

A: Setting overflow: hidden on an element causes a new float context to be created, so elements that are floated inside an element that has overflow: hidden applied are cleared.
http://www.w3.org/TR/CSS2/visuren.html#block-formatting

A: To quote from HTML & CSS Is Hard

To summarize, when you have an extra unfloated HTML element at the
  bottom of a container div, use the clear solution. Otherwise, add an
  overflow: hidden declaration to the container element. The underlying
  idea for both options is that you need a way to tell the browser to
  incorporate floats into the height of their container element

A: Instead of the overflow:hidden; use clear:both; for the
. here it is in use http://jsfiddle.net/Mvv8w/. Basically overflow:hidden will clear anything that is aside it just as clear:both; does.

A: This is why w3schools is not a reliable source for web designer/developers.  You are correct, it is a terrible example.
It doesn't because, in this example, the parent element does not have a fixed with. Furthermore, it's an un-ordered list tag, which is going to stretch to the size of it's children regardless.
http://jsfiddle.net/EhphH/
CSS
.parent {
    width: 150px;
    height: 100px;
    padding: 10px;
    background: yellow;
    overflow: hidden;

}
.child {
    float: left;
    width: 75px;
    height: 120px;
    margin: 10px;
    background: blue;

}
.baby {
    width: 200px;
    height: 25px;
    background: green;
}

Markup


text:
Q: Visual Studio replaces curly quotes by straight ones in XAML attributes If there is some way to prevent it? Even if managed to input something, it's getting replaced while Auto-Formatting.
I could use things like """, but it's not very comfortable (I use an app which allows to input those symbols using simple keyboard shortcuts; also, of course, readability of source code would be decreased).

A: If you really want to avoid the """ notation, you can avoid the auto-formatting either by using a Resx or by avoid using the inline property.
Resx:
<TextBlock Text="{x:Static resx:Resources.MyQuotedText}" />

Full property:
<TextBlock>
    <TextBlock.Text>"Something"</TextBlock.Text>
</TextBlock>

redpajama_set_name: RedPajamaStackExchange


text:
Q: Regex: How to capture second part of the url by regex and jQuery so these is my url which I need to split into two part.
1) http://localhost:8800/gb/

2) http://localhost:8800/gb/About.aspx

3) http://localhost:8800/gb/product.aspx?id=1&vref=201

4) http://localhost:8800/gb/Contact.aspx

now tell me which regex I should use to split the above url.
the second part will hold the url after from country code
suppose this is my url http://localhost:8800/gb/About.aspx
so second part will be About.aspx
I got one regex (https?:\/\/[^\/]+)\/(.*) which split url into two part but I want to get after from country code. thanks

A: One possible approach would be ^(?:\/\/|[^\/]+)*\/[a-zA-Z]{2}\/. This is simply based on Get relative URL from absolute URL with the addition to allow for a 2 character country code.
Demo: https://regex101.com/r/5fpRWX/1/

A: You can use split on 2 digit country code with / on either side:

var url = 'http://localhost:8800/gb/About.aspx?id=2&vref=3';
var arr = url.split(/\/[a-z]{2}\//);

console.log(arr[0]); //=> http://localhost:8800
console.log(arr[1]); //=> About.aspx?id=2&vref=3

RegEx Demo


text:
Q: Using Python (Selenium) to read, save, and then input a value from Web Page We are pretty new to using Python and Selenium. So please bear with us. As part of our effort on test automation for our website, we have used a helper class to show the Captcha used during new customer registration (works great). We are now trying to read that value, save it to memory (a string) and then input that saved value in the  correct page element. This is something entirely new for us and we're at a loss. Here is what we have so far.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
import urllib, urllib2

class NewAccountTests(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(5)
        self.base_url = "http://www.test.com/"
        self.verificationErrors = []
        self.accept_next_alert = True
        response = urllib.urlopen("http://www.test.com/")
        htmlSource = sock.read(id = "captcha")
        var.captcha = "htmlSource"
        sock.close()

#SIGN UP NEW USER

    def test_00_sign_up(self):
        driver = self.driver
        driver.get(self.base_url + "/")
        driver.find_element_by_id("name").send_keys("Foo")
        driver.find_element_by_id("email").send_keys("test@me.com")
        driver.find_element_by_id("screenname").send_keys("1234")
        driver.find_element_by_id("password").send_keys("xxx")
        driver.find_element_by_id("password2").send_keys("xxx")
        driver.find_element_by_id("option1").click()
        driver.find_element_by_id("option2").click()
        driver.find_element_by_id("captcha").click()
        >> I don't how to send the var string to the element "captcha"
        driver.find_element_by_id("registration_button").click()

I am certain someone knows this all too easily, so any assistance would be greatly appreciated.

A: I think you need to use send_keys():

send_keys(*value)
Simulates typing into the element.

driver.find_element_by_id("captcha").send_keys("test")


text:
Q: Make an image responsive with react-bulma-components I'm using react-bulma-components in an open source project, but I'm not able to make images responsive in mobile devices.
They should look like this:
Desktop-view
But they look like this:
Mobile-view
Here is the code from the parent component:
const Nomenclature = props => {

  const auth = useContext(AuthContext)

  return (
    <Columns.Column size= "half" breakpoint="desktop">
      <Box>
        <Media>
          <Media.Item renderAs="figure" position="left">
            {props.nomenclature.cards.slice(0, 1).map(card => (
              <Card
                key={card.id}
                alt={card.originalname}
                src={card.location}
                imageCount={props.nomenclature.cards.length}
                images={props.nomenclature.cards}
              />
            ))}
            {auth.isLoggedIn && (
            <Button
              renderAs={Link}
              to={`/nomenclature/${props.nomenclature.id}`}>
              Télécharger
            </Button> )}
          </Media.Item>

          <Media.Item>
            <Content>
            <Heading size={3}>
              {props.nomenclature.name ? props.nomenclature.name : 'sans nom'}
            </Heading>
            Par {props.nomenclature.author}
            <Tags tags={props.nomenclature.tags} />
            </Content>
          </Media.Item>
        </Media>
      </Box>
    </Columns.Column>
  );
};
export default Nomenclature;

And here is the code from the child component:
const Card = props => {
  const cardPreviewImages = props.images.map((image, index) => {
    return (

    );
  });
  return (

{cardPreviewImages}

      <Tag rounded size="large" className="nomenclature-image-count">
        {props.imageCount}
      </Tag>

  );
};

export default Card;

A: Just css is enough. If you can set sizes you can do this:
.container {
  width: 200px;
  height: 200px;
}

.container img {
  width: auto;
  height: auto;
  max-width: 200px;
  max-height: 200px;
}

It's an exemple of course, but if you provide an image 600x1200px, it will scale automatically to fit in your container. Maybe you can adapt it to your actual code.


text:
Q: How to tell typescript about functions "mixed in" from another module? I have this situation:
// Application.ts
import MicroEvent from 'microevent-github'

class Application {
  // stuff...
  something() {
    // It is also saying "trigger" is undefined,
    // but it IS defined, MicroEvent defined it.
    this.trigger('foo')
  }
}

// get the `bind`, `unbind`, and other methods from MicroEvent
MicroEvent.mixin(Application)

const app = new Application()

const handleFoo = () => console.log('foo')

// try to use them, get the squiggly errors saying
// `bind` doesn't exist on Application, etc.
application.bind('foo', handleFoo)
application.unbind('foo', handleFoo)

I have "mixed in" the MicroEvent to my application, which adds some methods to the object. However, VSCode is complaining that bind and unbind don't exist on the Application instance... But it does, how do I tell typescript to accept this?
Adding this doesn't work:
type Application = {
  bind: (eventType: string, callback: () => void) => void
  unbind: (eventType: string, callback: () => void) => void
  trigger: (eventType: string) => void
}

A: Typescript doesn't know that the mixin is modifying the class.
You can fill it in with declare statements, which tell typescript that some types exist, but without providing any implementation. This is a bit dangerous in that you are creating an interface where there is no type checking that it's implemented safely, but when using an untyped library, you may not have a choice.
class Application {
    declare bind: (eventType: string, callback: () => void) => void
    declare unbind: (eventType: string, callback: () => void) => void
    declare trigger: (eventType: string) => void

    //...
}

Playground

To reuse this, you could create an abstract base class that declare these methods, and inherit from that.
abstract class MicroEventBase {
  declare bind: (eventType: string, callback: () => void) => void
  declare unbind: (eventType: string, callback: () => void) => void
  declare trigger: (eventType: string) => void
}

class Application extends MicroEventBase {
  //...
}

Playground


text:
Q: How to write down formally number of occurrences? I want to write the following sentence formally:

The sequence $S$ contains elements of the set $A$. The probability value $P(a)$ for an element $a$ is defined as the number of its occurrences in the sequence $S$, divided by the count of all its elements.

I can write it the following manner:
$$ S = (s_1, s_2, ..., s_n) : s_i \in A.$$
$$ P(a) := {{ \left| \lbrace i \in \lbrace 1, 2, ..., n \rbrace : s_{i} = a \rbrace \right| } \over {n}}, \text{ given } n > 0\text{ and }a \in A. $$
It's, however, quite long and rather not elegant. Is there a simpler way to write this?

Edit:
There's always a solution, which involves breaking the formula to smaller parts:
$$ \text{Let } C(x) = \left| \lbrace i \in \lbrace 1, 2, ..., n \rbrace : s_i = x \rbrace \right|.$$
$$ P(a) := {C(a) \over n}. $$
It's more readable, but it's still not what I'm searching for...

A: It's also not quite correct. How about $|\{i\in\{1,\ldots,n\}\colon s_i=a\}|$ in the numerator? If you view the sequence $S$ as a function $S\colon\{1,\ldots,n\}\to A$, $i\mapsto s_i$, then you might even write $|S^{-1}(a)|$ for the numerator. And the denominator should simply be $n$ (which you implicitly defined for $S$). As $S$ is not (primarily) a set, $|S|$ looks strange.

A: Using the number symbol "#",
$$
\DeclareMathOperator*{\countif}{\#}
P(a) := \dfrac{\countif\limits_{i=1}^{n} (s_i=a)}{n}, \text{ given } n > 0\text{ and }a \in A.
$$
See John Fox, Applied Regression Analysis and Generalized Linear Models (3rd edition), Section 21.2.3

A: *

*If you are willing to use the "Iverson bracket notation", popularized by Knuth and others, you can say $$C(x) = \sum_{i=1}^n [s_i = x]$$
Here $[\ldots]$ are the Iverson brackets.  $[P]$ is defined to be 1 if $P$ is true, and 0 if it is false.

*People do sometimes use the Kronecker delta for this: $\delta_{ij}$ is defined to be 1 if $i=j$ and 0 if $i\ne j$, so you would have:
$$C(x) = \sum_{i=1}^n \delta_{xs_i}$$ or
$$C(x) = \sum_{i=1}^n \delta(x, s_i)$$
but I think the Iverson bracket is more straightforward.

*Most straightforward would be to write

Let $C(x)$ be the number of elements of $s_1,\ldots,s_n$ that are equal to $x$.  Then…

The idea that this is somehow less "formal" than something involving a bunch of funny symbols is a common misapprehension.

A: 2 ideas:
1) Using the hashtag or number symbol "#", e.g:
$$
\#(a \in S)
$$
It is fairly common within literature, see:
2008. Elements of Statistical Learning 2nd Ed, Chapter 9.2.2. Hastie, Tibshirani, Friedman
2)  Using the indicator function (returns 1 if condition true, else 0) in a sum, e.g:
$$
\sum\limits_{i=1}^{n}{\textbf{1}_{a_i \in S}}
$$
or
$$
\sum\limits_{i=1}^{n}{I({a_i \in S})}
$$
It is probably the most common and 'mathematical', see:
2008. Elements of Statistical Learning 2nd Ed, Chapter 9.2.3. Hastie, Tibshirani, Friedman

Usage example for original post:
$$
\mathbb{P}(a) = \frac{\sum\limits_{i=1}^{n}{\textbf{1}_{a_i \in S}}}{n} \forall \ a \in S \in A
$$
where
$n$ = number of elements in S
$\textbf{1}_a$ = indicator function that returns 1 if the element is a


text:
Q: Where are sessions stored in ASP.net MVC 5 applications? I'm working on an ASP.net 4 web application using MVC5.  I'm curious as to where sessions are stored in the default application scaffold running locally and whether there's any configuration available.

A: The session is configured on web.config. By default is saved on memory and a service that runs on server is handle that. Other way is to save it on a database...
This is the Session-State Modes...  from MSDN:
InProc mode, which stores session state in memory on the Web server. This is the default.
StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
Custom mode, which enables you to specify a custom storage provider.
Off mode, which disables session state.


text:
Q: How can I create a multiple wildcards with the single domain name? Is that possible to create wildcard records like *-demo.example.com,
    *-abc.example.com and *-xyz.example.com? all are pointing to different IP to CNAME.
Actually, I'm developing an application  and that is required to have the multiple wildcards with the single domain name.
*-demo.example.com
*-abc.example.com
*-xyz.example.com

And all records are pointing to different IP or CNAME.

A: No, it's not. Wildcards are by definition whole labels with the content "*", and they must be the leftmost label. See RFC 1034 section 4.3.3.


text:
Q: Element-wise shifting from smaller array to a larger array I am programming an ESP32 in the Arduino framework. For my application, I need to create a buffer which will store information from both the present and the last time it was accessed. Here is what I am attempting to do.
//first buffer
char buffer1[4];

//second buffer
char buffer2[8];

void setup {
    //setup
}

//buffer1 values will change with each iteration of loop from external inputs
//buffer2 must store most recent values of buffer1 plus values of buffer1 from when loop last ran

for example:

**loop first iteration**
void loop {
    buffer1[0] = {1};
    buffer1[1] = {2};
    buffer1[2] = {3};
    buffer1[3] = {1};

    saveold(); //this is the function I'm trying to implement to save values to buffer2 in an element-wise way
}
//value of buffer2 should now be: buffer2 = {1,2,3,1,0,0,0,0}

**loop second iteration**
void loop {
    buffer1[0] = {2};
    buffer1[1] = {3};
    buffer1[2] = {4};
    buffer1[3] = {2};

    saveold();
}

//value of buffer2 should now be: buffer2 = {2,3,4,2,1,2,3,1}

From what I've been able to understand through searching online, the "saveold" function I'm trying to make
should implement some form of memmove for these array operations
I've tried to piece it together, but I always overwrite the value of buffer2 instead of somehow shifting new values in, while retaining the old ones
This is all I've got:
void saveold() {
  memmove(&buffer2[0], &buffer1[0], (sizeof(buffer1[0]) * 4));
}

From my understanding, this copies buffer1 starting from index position 0 to buffer2, starting at index position 0, for 4 bytes (where 1 char = 1 byte).
Computer science is not my backround, so perhaps there is some fundamental solution or strategy that I am missing. Any pointers would be appreciated.

A: You have multiple options to implement saveold():
Solution 1
void saveold() {
    // "shift" lower half into upper half, saving recent values (actually it's a copy)
    buffer2[4] = buffer2[0];
    buffer2[5] = buffer2[1];
    buffer2[6] = buffer2[2];
    buffer2[7] = buffer2[3];
    // copy current values
    buffer2[0] = buffer[0];
    buffer2[1] = buffer[1];
    buffer2[2] = buffer[2];
    buffer2[3] = buffer[3];
}

Solution 2
void saveold() {
    // "shift" lower half into upper half, saving recent values (actually it's a copy)
    memcpy(buffer2 + 4, buffer2 + 0, 4 * sizeof buffer2[0]);
    // copy current values
    memcpy(buffer2 + 0, buffer1, 4 * sizeof buffer1[0]);
}

Some notes

*

*There are even more ways to do it. Anyway, choose the one you understand best.

*Be sure that buffer2 is exactly double size of buffer1.

*memcpy() can be used safely if source and destination don't overlap. memmove() checks for overlaps and reacts accordingly.

*&buffer1[0] is the same as buffer1 + 0. Feel free to use the expression you better understand.

*sizeof is an operator, not a function. So sizeof buffer[0] evaluates to the size of buffer[0]. A common and most accepted expression to calculate the size of an array dimension is sizeof buffer1 / sizeof buffer1[0]. You only need parentheses if you evaluate the size of a data type, like sizeof (int).

Solution 3
The last note leads directly to this improvement of solution 1:
void saveold() {
    // "shift" lower half into upper half, saving recent values
    size_t size = sizeof buffer2 / sizeof buffer2[0];
    for (int i = 0; i < size / 2; ++i) {
        buffer2[size / 2 + i] = buffer2[i];
    }
    // copy current values
    for (int i = 0; i < size / 2; ++i) {
        buffer2[i] = buffer1[i];
    }
}

To apply this knowledge to solution 2 is left as an exercise for you. ;-)

A: The correct way to do this is to use buffer pointers, not by doing hard-copy backups. Doing hardcopies with memcpy is particularly bad on slow legacy microcontrollers such as AVR. Not quite sure what MCU this ESP32 got, seems to be some oddball one from Tensilica. Anyway, this answer applies universally for any processor where you have more data than CPU data word length.

perhaps there is some fundamental solution or strategy that I am missing.

Indeed - it really sounds that what you are looking for is a ring buffer. That is, an array of fixed size which has a pointer to the beginning of the valid data, and another pointer at the end of the data. You move the pointers, not the data. This is much more efficient both in terms of execution speed and RAM usage, compared to making naive hardcopies with memcpy.


text:
Q: Python Syntax Non-ASCII character 'xe6' in file (added #-*-coding:utf-8 -*- ) I want to use Python to read the .csv.
At start I search the answer to add the
#!/usr/bin/python
#-*-coding:utf-8 -*-

so that  can avoid the problem of encoding, but it is still wrong, giving the syntax error:

SyntaxError: Non-ASCII character 'xe6' in file csv1.py on line2, but no encoding declared:

My code:
#!/usr/bin/python
# -*-coding:utf-8 -*-
import csv
with open('wtr1.csv', 'rb') as f:
    for row in csv.reader(f):
        print row

A: You've got two different errors here. This answer relates to the with warning. The other error is the ascii encoding error.
You appear to be using a very old version of python (2.5). The with statement is not enabled by default in python 2.5. Instead you have to declare a the top of the file that you wish to use it. Your file should now look like:
#!/usr/bin/python
# -*-coding:utf-8 -*-
from __future__ import with_statement

import csv
with open('wtr1.csv', 'rb') as f:
    for row in csv.reader(f):
        print row


text:
Q: Swift - Wait for a delegate function to finish a completion handler Suppose I have a function with completion handler and my AppDelegate extends from any notification delegate like this:
var flag = false
class AppDelegate: finishWorkingDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    }

    private func updateData(completion: () -> Void) {
        //wait for delegate
        completion()
    }

    //delegate function
    func finishWorking(workComplete: Bool) {
        flag = true
    }
}

So my updateData function needs to wait until finishWorking delegate method where called to launch completion.
finishWorking is triggered when a background task did finish at any time.
updateData can be used some where at any moment, like:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    updateData() {
        //do some other work
    }
}

I used a loop for wait until flag changes to true to launch completion
func updateData(completion: () -> Void) {
    while !flag {
        //...
    }
    completion()
}

But this method freezes the app. So, there is a better solution?
PD: I know that I can use the delegate function to do "some other work" but this is a particular case, I made this example code to explain the problem as clear as possible. It needs to be as described.

A: Whatever the work you do in finishWorking you shouldn't freeze the app , let the app opens the initial vc and show an activity/loading until the heavy work is done then refresh that vc


text:
Q: Не могу подключиться к БД MSSQL Добрый день
Буквально вчера всё работало. Сегодня же, после включения, пишет вот такое
Как я могу это исправить?
Спасибо

A: *

*Зайдите Windows служба сервиса (CMD -> services.msc).

*Лево находится кнопка запустите(Start) SQL Server(MSSQLSERVER) / SQL Server Browser.

Проверьте сервисы (который отмеченные в картине) -
дополнительный руководство.


text:
Q: Using getTileURL in Android Application with GeoServer We are just starting to work with Google Maps on Android and have a GeoServer set up to provide tiles which we would like to add as overlay on the map. So far, I have followed a few tutorials and references to get started.

*

*For getting MyLocation

*Setting up WMS on Android

*WMS Reference
The problem: While the url that I am generating in the getTileUrl function in the TileProviderFactory does indeed return a png image when I set a breakpoint and copy and paste the url into a browser, it does not load onto the map as an overlay on the Android device. There are no errors being thrown from what I can see and after reading this I am not sure if there will be any as they have indicated that the errors are being muted.
What I am wondering is if you can see any immediate issues in my code or have any suggestions for debugging where I will be able to tell if the application is actually communicating with my GeoServer to retrieve the image or not. I've looked at the log on the GeoServer and it seems as though only my browser requests are going through and it's not receiving any requests from Android (it's a bit difficult to tell because we have other applications using the server as well). The Android phone is connected by both wifi and cell and has gps enabled. As a last resort I have tried changing the tile overlay zIndex and setting it to visible but this didn't seem to make any difference.
EDIT: Android device is definitely NOT communicating with GeoServer at this point.
EDIT 2: Able to load static images from websites
(like this) as overlays and found that I am getting the following exception on testing out an HTTP Request to the formed URL:
W/System.err(10601): java.net.SocketException: The operation timed out
W/System.err(10601): at org.apache.harmony.luni.platform.OSNetworkSystem
     .connectStreamWithTimeoutSocketImpl(Native Method)
W/System.err(10601): at org.apache.harmony.luni.net.PlainSocketImpl
     .connect(PlainSocketImpl.java:244)
W/System.err(10601): at org.apache.harmony.luni.net.PlainSocketImpl
     .connect(PlainSocketImpl.java:533)
W/System.err(10601): at java.net.Socket
     .connect(Socket.java:1074)
W/System.err(10601): at org.apache.http.conn.scheme.PlainSocketFactory
     .connectSocket(PlainSocketFactory.java:119)

Thanks.
MapTestActivity
public class MapTestActivity extends FragmentActivity
    implements LocationListener, LocationSource{

    private GoogleMap mMap;
    private OnLocationChangedListener mListener;
    private LocationManager locationManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map_test);
        setupLocationManager();
        setupMapIfNeeded();
    }

    private void setupLocationManager() {
        this.locationManager =
            (LocationManager) getSystemService(LOCATION_SERVICE);

        if (locationManager != null) {
            boolean gpsIsEnabled = locationManager.isProviderEnabled(
                    LocationManager.GPS_PROVIDER);
            boolean networkIsEnabled = locationManager.isProviderEnabled(
                    LocationManager.NETWORK_PROVIDER);

            if(gpsIsEnabled) {
                this.locationManager.requestLocationUpdates(
                    LocationManager.GPS_PROVIDER, 5000L, 10F, this);
            }
            else if(networkIsEnabled) {
                this.locationManager.requestLocationUpdates(
                    LocationManager.NETWORK_PROVIDER, 5000L, 10F, this);
            }
            else {
                //Show an error dialog that GPS is disabled...
            }
        }
        else {
            // Show some generic error dialog because
            // something must have gone wrong with location manager.
        }
    }

    private void setupMapIfNeeded() {
        // Do a null check to confirm that we have not already instantiated the
        // map.
        if (mMap == null) {
            // Try to obtain the map from the SupportMapFragment.
            mMap = ((SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map)).getMap();
            // Check if we were successful in obtaining the map.
            if (mMap != null) {
                setUpMap();
            }
            mMap.setLocationSource(this);
        }
    }

    private void setUpMap() {
        // TODO Auto-generated method stub
        mMap.setMyLocationEnabled(true);
        TileProvider geoServerTileProvider = TileProviderFactory
            .getGeoServerTileProvider();
        TileOverlay geoServerTileOverlay = mMap.addTileOverlay(
            new TileOverlayOptions()
                .tileProvider(geoServerTileProvider)
                .zIndex(10000)
                .visible(true));
    }
    // Non-relevant listener methods removed
}

TileProviderFactory
public class TileProviderFactory {

    public static GeoServerTileProvider getGeoServerTileProvider() {

        String baseURL = "mytileserver.com";
        String version = "1.3.0";
        String request = "GetMap";
        String format = "image/png";
        String srs = "EPSG:900913";
        String service = "WMS";
        String width = "256";
        String height = "256";
        String styles = "";
        String layers = "wtx:road_hazards";

        final String URL_STRING = baseURL +
                "&LAYERS=" + layers +
                "&VERSION=" + version +
                "&SERVICE=" + service +
                "&REQUEST=" + request +
                "&TRANSPARENT=TRUE&STYLES=" + styles +
                "&FORMAT=" + format +
                "&SRS=" + srs +
                "&BBOX=%f,%f,%f,%f" +
                "&WIDTH=" + width +
                "&HEIGHT=" + height;

        GeoServerTileProvider tileProvider =
            new GeoServerTileProvider(256,256) {

            @Override
            public synchronized URL getTileUrl(int x, int y, int zoom) {
                try {

                    double[] bbox = getBoundingBox(x, y, zoom);

                    String s = String.format(Locale.US, URL_STRING, bbox[MINX],
                            bbox[MINY], bbox[MAXX], bbox[MAXY]);

                    Log.d("GeoServerTileURL", s);

                    URL url = null;

                    try {
                        url = new URL(s);
                    }
                    catch (MalformedURLException e) {
                        throw new AssertionError(e);
                    }

                    return url;
                }
                catch (RuntimeException e) {
                    Log.d("GeoServerTileException",
                        "getTile x=" + x + ", y=" + y +
                        ", zoomLevel=" + zoom +
                        " raised an exception", e);
                    throw e;
                }

            }
        };
        return tileProvider;
    }
}

GeoServerTileProvider
public abstract class GeoServerTileProvider extends UrlTileProvider{

    // Web Mercator n/w corner of the map.
    private static final double[] TILE_ORIGIN =
        {-20037508.34789244, 20037508.34789244};
    //array indexes for that data
    private static final int ORIG_X = 0;
    private static final int ORIG_Y = 1; // "

    // Size of square world map in meters, using WebMerc projection.
    private static final double MAP_SIZE = 20037508.34789244 * 2;

    // array indexes for array to hold bounding boxes.
    protected static final int MINX = 0;
    protected static final int MINY = 1;
    protected static final int MAXX = 2;
    protected static final int MAXY = 3;

    public GeoServerTileProvider(int width, int height) {
        super(width, height);
    }

    // Return a web Mercator bounding box given tile x/y indexes and a zoom
    // level.
    protected double[] getBoundingBox(int x, int y, int zoom) {
        double tileSize = MAP_SIZE / Math.pow(2, zoom);
        double minx = TILE_ORIGIN[ORIG_X] + x * tileSize;
        double maxx = TILE_ORIGIN[ORIG_X] + (x+1) * tileSize;
        double miny = TILE_ORIGIN[ORIG_Y] - (y+1) * tileSize;
        double maxy = TILE_ORIGIN[ORIG_Y] - y * tileSize;

        double[] bbox = new double[4];
        bbox[MINX] = minx;
        bbox[MINY] = miny;
        bbox[MAXX] = maxx;
        bbox[MAXY] = maxy;
        return bbox;
    }
}

A: This turned out to be a network issue and completely unrelated to my implementation which is "correct". I guess this question will serve well as an example for others who are getting started with Android + GeoServer implementation so I will leave it up.


text:
Q: Logback Play Framework 2.6 using incorrect configuration file I'm trying to set up basic logging with logback.xml with the scala-g8 template. The issue I'm having is that for some reason Play framework keeps using the logback file in the .ivy2 cache folder. I have a logback.xml in my conf directory, but it doesn't seem to be picking it up. Any ideas? Here's the log:
14:36:06,949 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [jar:file:/home/julian/.ivy2/cache/com.typesafe.play/play-openid_2.12/jars/play-openid_2.12-2.6.5.jar!/logback-test.xml]
14:36:06,961 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@4aeb1d4e - URL [jar:file:/home/julian/.ivy2/cache/com.typesafe.play/play-openid_2.12/jars/play-openid_2.12-2.6.5.jar!/logback-test.xml] is not of type file
14:36:07,060 |-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Added status listener of type [ch.qos.logback.core.status.NopStatusListener]
14:36:07,061 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
14:36:07,068 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
14:36:07,073 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
14:36:07,094 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to WARN
14:36:07,094 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
14:36:07,095 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
14:36:07,095 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@6d63c1fd - Registering current configuration as safe fallback point
14:36:06,949 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [jar:file:/home/julian/.ivy2/cache/com.typesafe.play/play-openid_2.12/jars/play-openid_2.12-2.6.5.jar!/logback-test.xml]
14:36:06,961 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@4aeb1d4e - URL [jar:file:/home/julian/.ivy2/cache/com.typesafe.play/play-openid_2.12/jars/play-openid_2.12-2.6.5.jar!/logback-test.xml] is not of type file
14:36:07,060 |-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Added status listener of type [ch.qos.logback.core.status.NopStatusListener]
14:36:07,061 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
14:36:07,068 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
14:36:07,073 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
14:36:07,094 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to WARN
14:36:07,094 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
14:36:07,095 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
14:36:07,095 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@6d63c1fd - Registering current configuration as safe fallback point
14:36:07,167 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@77ece54e - URL [jar:file:/home/julian/.ivy2/cache/com.typesafe.play/play-openid_2.12/jars/play-openid_2.12-2.6.5.jar!/logback-test.xml] is not of type file
14:36:07,169 |-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Added status listener of type [ch.qos.logback.core.status.NopStatusListener]
14:36:07,169 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
14:36:07,169 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
14:36:07,169 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
14:36:07,169 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to WARN
14:36:07,169 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
14:36:07,170 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
14:36:07,170 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@5aaa6c89 - Registering current configuration as safe fallback point

It's really odd since this is the right-out-of-the-box template. Thanks!

A: I am pretty sure they broke conf/logback.xml in 2.6.13 in this update.  If you are using that version, try going back to 2.6.12 and I suspect everything will work like you expect.
UPDATE: I believe the latest version 2.6.15 has a fix to this now.


text:
Q: Can one program a custom map view with custom map (eg map of floor of a mall, office) in android
Possible Duplicate:
How to build a mall map for Android

Can one program a custom map view with custom map (eg map of floor of a mall, office) in android ?
How do we do it?

A: You cannot do this using the standard toolset that Android supply you (MapView and the whole Google Maps package).
There are a few commercial thirdy-party solutions out there. Google for indoor positioning or indoor navigation.
As an alternative, you could adapt one of the open source map viewers and navigation systems that have been developed so far. Have a look at openstreetmap, for example:
http://wiki.openstreetmap.org/wiki/Main_Page
http://wiki.openstreetmap.org/wiki/Software/Mobile


text:
Q: Krypton Ribbon add items to the file tab Sure I am being a bit thick but can anyone tell me how I can add a save button to the Krypton Ribbon file tab. For all other tabs I can drag from the toolbox but I cant for the life of me figure out how to add a button or anything else to the file tab. I'm using vb.net and cant find anything on google explaining how to do this at all
Many Thanks
Gibbo

A: Figured it out, was being daft, in the properties of the ribbon you can add a button in the RibbonAppButton to AppButton MenuItems/ AppButtonSpecs.
Then just add an onclick event in the code
Private Sub BtnSave_Click(sender As Object, e As EventArgs) Handles BtnSave.Click

Thanks for looking


text:
Q: Adjust line break when pressing ALT+Shift+F in VS-Code I'm actively using the keybinding ALT+Shift+F for auto formatting my code. I love it and it works well, despite that the line break is set too early.
For example:
I want MyThemes.light to be in the same line, not in the next.
There's still plenty of room to the right, that's just not used. So is there a way to adjust the value at which point the auto format inserts a line break?
Would really love to fix this, as VS-Code is my all time favorite code editor.

A: The right way to adjust this was setting the Dart: Line Length paramter in the VS-Code Settings.
The auto-formatter uses this for making proper line breaks.
The default value 80 seems a bit low on 16:9 monitors and bigger displays. Maybe someone else will find this useful.


text:
Q: VLOOKUP doesn't work with complicated URL as cell content I have the following situation.
I use the function VLOOKUP in Sheet2, using a table array from Sheet1:
=VLOOKUP(A4,Sheet1!$A$2:$B$81,2,FALSE)

I am comparing URLs written in cells formatted as "text".
I basically try to mass replace some URLs with others.
When the URL is a simple one, such as the one below, the formula works fine.
http://www.website.com/page/ that becomes http://www.website.com/newpage/
The formula works fine and returns http://www.website.com/newpage/ in the range cell
When the URL is a complicated one, such as the one below, the formula returns #VALUE!
http://www.website.com/configurator/?dimensiuni%5B%5D=100&toate-categoriile=1&orice-duritate=1&toti-producatorii=1&orice-buget=1&toate_236=1&toate_234=1&toate_235=1&toate_237=1&orice_buget_233=1&toate_216=1&toate_196=1&toate_191=1&toate_211=1&orice_buget_190=1&toate_246=1&toate_244=1&toate_245=1&toate_247=1&orice_buget_243=1&toate_261=1&toate_259=1&toate_260=1&toate_262=1&orice_buget_258=1&toate_281=1&toate_279=1&toate_280=1&toate_282=1&orice_buget_278=1&toate_294=1&toate_292=1&toate_293=1&toate_295=1&orice_buget_291=1

should return
https://www.website.com/magazin/?orderby=price&product_category=tipuri-saltele&dimensiune_saltea=160x190-ro&stock_status=in-stock%2Con-backorder&min_price=30&max_price=9000&lang

but it doesn't. It returns #VALUE!
Any idea what I could do to make this work?
I suspect it's probably because the long and complex URL that it doesn't know how to compute it...
Thanks!


text:
Q: Bootstrap scrollspy not working with jQuery plugin UPDATE: Seems like this only doesn't work on my computer, with any browser. On other computers it works just fine.
Demo: http://yosefw.me/2001/01/01/test.html
I'm using Jekyll & GitHub pages to host my personal website.
I wanted to add a 'Table of contents' functionality to my posts. I tried to use this jQuery plugin: https://github.com/ghiculescu/jekyll-table-of-contents
It seems it's somehow conflicting with Bootstrap's scrollspy, as it doesn't highlight (add ".active") to the relevant nav items as a I scroll. I think it's a problem with the plugin, because it worked fine when I removed it and hard-coded the table of contents.
Other files that might be relevant:

*

*My default template: https://github.com/yosefw/yosefw.github.io/blob/master/_layouts/default.html

*My post template: https://github.com/yosefw/yosefw.github.io/blob/master/_layouts/post.html

*My main JS file: https://github.com/yosefw/yosefw.github.io/blob/master/js/main.js
How can I solve this and make the scrollspy work?

A: Remove this unnecessary jquery plugin and use automatic toc generation provided with kramdown


text:
Q: How can I specify a custom icon for a Dock stack? I've created a folder in Finder with aliases of several apps. I want to add this to my dock so that those apps are grouped together and the dock isn't quite as messy. No problem; I added the folder to the dock and it's displaying as a stack. The only problem is, the icon displayed in the dock is the icon of the first app in the folder, rather than the custom icon I assigned to the folder in Finder. Is there a way to force the dock to display the custom icon?

A: Right click (or ⌃ ctrl-click) the folder in the Dock, and select Display as: Folder from the menu that appears.

A: You can't really.  What you can do is add another item to the folder that has the custom icon, and then give it a name that would make it show up alphabetically first.
For example, this is a set of icons that make your stacks look like the files are in a box:  http://t.ecksdee.org/post/19001860/stacks-overlays

A: I may be wrong, but Candybar should work.

A: Yes, you CAN do it. You don't have to use the "put the picture in the stack" option. The trick is HOW you copy and paste.

*

*Go to the folder enclosing the files of the stack. Open "info"

*OPEN the jpg you want as the folder icon

*Click "edit, COPY" (copying in finder WILL NOT WORK)

*Click on the icon of the folder in the INFO window

*PASTE

You're done. I've done this on multiple folders in my dock.

A: You need to change the icon of the folder that contains the items in the stack.  This can be done in several ways, but perhaps the easiest is to start by navigate to the folder of the stack, change that icon, and set the stack to display the folder instead of the contents.
Click the stack, click "Open in Finder" in the stack, and then press the keystroke ⌘ + ▲.  The key press will take you "one level up" in the directory hierarchy so that you are now looking at the folder that houses the items in the stack.
Next, select the folder (If it's not already selected), and "get info" on it, by typing ⌘ + I, or right-clicking and selecting "Get Info".  At the top of this window will be a miniature icon of a folder.  You can click on this and copy it via the keyboard shortcut (⌘ + C), or paste in an image that you copied from somewhere else.
Finally, you need to right-click on the stack and set it to display "folder" and not the stack contents.

A: The dock folder icon is taken from the first item in an alphabetical list of its contents. When the one you want isn't the first in the list change its name to begin with a space character. It then is moved to the top of the list and its icon is used on the dock folder. eg. here's my Video Live dock folder. I want the most used to appear at the top.


text:
Q: Hamilton's Rules for Quaternions contradict themselves I recently discovered quaternions and quickly stumbled across a to me contradictory statement. This contradiction already seems to lie in the definition (Hamilton's Rules):
$$i^2=j^2=k^2=ijk=-1$$
My issue is with the statement $ijk=-1$
If I just multiply the three squares I get something as follows:
$$i^2j^2k^2=-1$$
$$(ijk)^2=-1$$
Now if I try the same thing from the second equation $ijk=-1$ I get a somewhat contradictory statement:
$$ijk=-1$$
$$(ijk)^2=1$$
All of the operations should be legal as far as I'm concerned but this makes little sense to me. Any explanation is greatly appreciated!

A: Alright. That was very simple. I was not following legal algebraic operations.
$$(ijk)^2=-1$$
does not follow from
$$i^2j^2k^2=-1$$
because $(ijk)^2 = ijkijk \ne i^2j^2k^2$


text:
Q: Align the node labels radially in draw_hierarchy How is it possible to align the labels of nodes to oriente radially toward center using "draw_hierarchy"? The text file which contains my dataset about my network, in each row has the labels of two connected nodes (data).
This is my code:
for i in range(len(events["e"])):
    g = Graph(directed=False)
    vprop = g.new_vertex_property("string")
    eprop = g.new_edge_property("int")
    added_nodes=[]
    n=0
    for ii, row in data.iterrows():
        #if the node does not already exist in the node list labels
        if data['i'][ii] not in added_nodes:
           added_nodes.append(data['i'][ii])
           exec("vertex_%d=g.add_vertex()" %n)
           exec("vprop[vertex_%d] =%d"%(n  , data['i'][ii]))
           vertix_out=n
           n+=1
        else:
           indx= added_nodes.index(data['i'][ii])
           vertix_out=indx

        if data['j'][ii] not in added_nodes:
           added_nodes.append(data['j'][ii])
           exec("vertex_%d=g.add_vertex()" %n)
           exec("vprop[vertex_%d] =%d"%(n  , data['j'][ii]))
           vertix_in=n
           n+=1
        else:
           indx= added_nodes.index(data['j'][ii])
           vertix_in=indx
        exec("e=g.add_edge(vertex_%d,vertex_%d)"%(vertix_out,vertix_in))
        eprop[e] =data['t_sp'][ii]
    g.vertex_properties["name"]=vprop
    g.edge_properties["Timestamp"]=eprop
    state = minimize_nested_blockmodel_dl(g, deg_corr=True,  mcmc_args={'parallel':True},mcmc_equilibrate_args={'verbose':False, 'epsilon':1e-4}, verbose=True)
    L = len(state.levels)
    # ## block membership of each node on each level
    eventName = events["e"][i]
    for l in range(L):
         with open(os.path.join('/home/','nodes_blocks_level_%s_%s'%(l,eventName)),'w') as f:
              state_proj_l = state.project_level(l)
              blocks_proj_l = state_proj_l.get_blocks()
              for i_b,b in enumerate(blocks_proj_l.a):
                  f.write('%s \t %s \n'%(i_b,b))
    print state.entropy()

    t = get_hierarchy_tree(state)[0]
    tpos = pos = radial_tree_layout(t, t.vertex(t.num_vertices() - 1), weighted=True)
    cts = get_hierarchy_control_points(g, t, tpos,beta=.87)
    pos = g.own_property(tpos)
    #text rotation
    vtext_rotation = g.new_vertex_property('double')
    for v in g.vertices():
        if pos[v][0] >= 0:
           try:
               vtext_rotation[v] = math.atan(pos[v][1]/pos[v][0])
           except ZeroDivisionError:
               vtext_rotation[v] = 0
        else:
            vtext_rotation[v] = math.pi + math.atan(pos[v][1]/pos[v][0])
    g.vertex_properties['text_rotation'] = vtext_rotation
    """
    graph_draw(g, pos=pos,
               edge_control_points=cts,
               vertex_size=20,
               vertex_text=g.vertex_properties["name"],
               vertex_text_position=1,
               vertex_text_rotation=g.vertex_properties['text_rotation'],
               vertex_font_family='mono',
               vertex_font_size=5,
               vertex_anchor=0,
               output_size=[1024*2,1024*2],
               output="ScioPattern_%s.png"%(eventName))
    """
    draw_hierarchy(state, pos=pos,
               deg_order=True,
               edge_control_points=cts,
               vertex_size=20,
               vertex_text=g.vertex_properties["name"],
               vertex_text_position=1,
               vertex_text_rotation=g.vertex_properties['text_rotation'],
               vertex_font_family='mono',
               vertex_font_size=15,
               vertex_anchor=0,
               output_size=[1024*2,1024*2],
               output="hierarchy_%s.png"%(eventName))

The labels get align radially when I use "graph_draw" but they become randomly orientated when I use "draw_hierarchy". Why is this happening?

I am also wondering how I could build a layered blockmodel? Should I use LayeredBlockState class? Is it possible that someone provides an example of how it works?

A: Just pass the option vertex_text_position="centered" to draw_hierarchy().
There is an example of using layered SBMs in the HOWTO: https://graph-tool.skewed.de/static/doc/demos/inference/inference.html#layered-networks


text:
Q: Run same java program twice having static variable in class (I do not know whether i should ask this here or not)
I want to run the same java program twice which has most of the variables static.
if i ran this twice(concurrently) will these static variables have same values or different?
As the static variables are class variables, this is confusing me.

A: The static values are per-class and if you run the same java program twice, then it will create two JVMs (you'll see two java processes in the task list), which will load the class twice (once per JVM), so the static variables will not be shared.

A: Each run will have its own JVM instance so static variables will not collide.

A: If you are starting the application two times, for example, via:
java Your.MainClass

Then the values for the 2nd run will not be influenced by the first run. It's an entirely new process.
If, however you are running a static method two times, in the lifecycle of a single application, then, what I wrote above doesn't hold anymore.


text:
Q: Modal Window with HTML5 and CSS I am following a tutorial found here and I can't seem to get it to show up. I am using a bootstrap enabled website so I am not sure if that is the problem. I've been at it for two hours and can't seem to get anywhere. My button that I want users to click on in order to bring up the popup looks like this: Contact Me The framework for the popup looks like this:

        X

Title

Content

The CSS document looks like:
.contactus {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}

.contactus:target {
opacity:1;
pointer-events: auto;
}

.contactus > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}

.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}

.close:hover { background: #00d9ff; }

I have JavaScript enabled on my browser it if you click on it, you can't scroll up on the page unless you press "Esc" so I think it's puling up, you just can't see it. I was thinking it had something to do with z-index: 99999; but I don't know what that does exactly.
Any ideas??


text:
Q: Conceptual Understanding of Zero Curl in Ampere's Law I understand that Ampere's law tells us that the current density times $\mu_0$ at some location must be equal to the curl of $\mathbf{B}$ at that location. However, conceptually this is troubling me.
In particular, in my mind I am imagining a long wire with some current density $J$ running through it. Then out side this wire, $B$ should be proportional to $s^{-1}$, where $s$ is the distance from the wire (the integral of $\mathbf{B}$ over any loop around the wire should, however, be $\mu_0$ times I enclosed). At all locations outside the wire $J$ is zero, so $\text{curl}(\mathbf{B})$ must also be zero.
$\text{curl} = 0$ at some point implies that placing a paddle wheel at that point won't cause the paddle wheel to turn. However, let's look at a cross section of the wire with the $B$ field spinning around it. Then if we place a paddle wheel (+ shaped) at the 12 o clock point in the configuration, the bottom part of the wheel should be pushed on harder than the top part (since $B$ falls off with $s$ and the top is farther from the wire than the bottom).
So there SHOULD be a curl, or at least that's what I would reason without the mathematics. But since the maths isn't wrong, where is my reasoning wrong?

A: Your reasoning is wrong because you are fixing the wheel in space. Of course it is going to spin. If we abstract the field as flow lines, the $1/s$ circular flow is irrotational, but the paddle wheel needs to move with the fluid for that to work.
The imaginary paddle wheel is now orbiting at some distance $s$ from the center. It central field is:
$$ B_0 = \frac 1 s$$
while the top and bottom paddles feel
$$ B_{\pm} = \frac 1 {s \pm ds} = B_0( 1 \mp ds)$$
so in the rotating frame moving at $B_0$ it rotates backwards at exactly the rate of revolution, leaving it irrotational in the fixed frame.

A: For a very long, thin wire along the z-axis with current $I$, the magnetic field is given in cylindrical coordinates $(\rho,\phi,z)$ by
$$\mathbf B=\frac{\mu_0I}{2\pi\rho}\hat\phi$$
Let's calculate the curl of this field. In cylindrical coordinates the curl of a vector field with only a $\phi$ component is given by
$$\nabla\times\mathbf B=-\frac{\partial B_\phi}{\partial z}\hat \rho+\frac{1}{\rho}\left(\frac{\partial}{\partial \rho}(\rho B_\phi)\right)\hat z$$
Given that $B_\phi=\frac{\mu_0I}{2\pi\rho}$, we have
$$\frac{\partial B_\phi}{\partial z}=0$$
$$\frac{\partial}{\partial \rho}(\rho B_\phi)=0$$
Therefore, we have $\nabla\times\mathbf B=0$ at all points in space except where $\rho=0$ where the $1/\rho$ part gives us some trouble. However, you can do some tricky math to show that the curl on the z-axis results in a Dirac Delta distribution, so we end up with
$$\nabla\times\mathbf B=\frac{\mu_0I}{2\pi\rho}\delta(\rho)\hat z=\mu_0\mathbf J$$
as expected. So everything works out fine.

$\text{curl} = 0$ at some point implies that placing a paddle wheel at that point won't cause the paddle wheel to turn. However, let's look at a cross section of the wire with the $B$ field spinning around it. Then if we place a paddle wheel (+ shaped) at the 12 o clock point in the configuration, the bottom part of the wheel should be pushed on harder than the top part (since $B$ falls off with $s$ and the top is farther from the wire than the bottom). So there SHOULD be a curl, or at least that's what I would reason without the mathematics. But since the maths isn't wrong, where is my reasoning wrong?

Your paddle wheel needs to be infinitely small. You could put a similar paddle wheel in certain charge distributions for the electric field and get them to spin when we know the curl of the electrostatic field must always be $0$. The issue is that the curl is a deferential operator that works with infinitesimal quantities. Therefore, you need to think in terms of an infinitesimal paddle wheel. Then you will see that you don't get any spinning at points not on the z-axis.

A: According to my understanding divergence and curls are to be taken at a point in space, (just like we take derivative of a function at a point). Loosely speaking, we can call them as point operations. Differential form of Amperes law says, wherever the source exist ( current density) then curl of B exist. You can verify this. But source of current can produce magnetic field  outside the region of current density also (Biot-Savart Law). Don't forget we derived Amperes law using Biot-Savart Law.

A:
Then if we place a paddle wheel (+ shaped) at the 12 o clock point in the configuration, the bottom part of the wheel should be pushed on harder than the top part (since B falls  off with s and the top is farther from the wire than the bottom).

To the OP: This bothered me for quite some time, so I sympathize with you.
You show a + shaped paddle wheel with four vanes. You are right the bottom part of the wheel would be pushed harder than the top part. Your intuition is having a problem here because unknowingly it is ignoring the other two vanes of the paddle to the left and right. If the bottom vane is getting pushed toward an anti-clockwise rotation, the other three are getting pushed toward a clockwise rotation, not just the top one. Try drawing the + shaped paddle wheel on top of the circular field.
Now, it is amazing that with a B field that falls of as 1/distance, the bottom vane gets exactly balanced by the other three vanes! (Intuition satisfied, I trust to the math that it will work out)
One can question why a paddle wheel with four vanes... but I think it should be possible to show that any other configuration of vanes is equivalent to the four vane wheel.
PS: This is called a curl-free macroscopic circulation over here:
https://mathinsight.org/curl_subtleties#curlfreecirc


text:
Q: How to retrieve hotspot from KRPANO using Javascript I wan't to retrieve a hotspot from KRPANO using a javascript call.
With the below content I retrieve undefined.
KRPANO XML snippet:
<hotspot name="spot0" style="hotspot_ani_white" ath="-25" atv="-10" />
<hotspot name="spot1" style="hotspot_ani_white" ath="-25" atv="-10" />

External javascript file loaded via index.html:
$(function() {

  var krpano = $('#krpanoSWFObject')[0];
  var spotName = 'spot0';
  curSpot = krpano.get(hotspot[spotName]);
  console.log(curSpot)

});

Any help is welcome. Thanks in advance!

A: You are close to it. But I'm not sure your can get the element as you wrote it.
First, you should grab the KRPano plugin as an object and not as HTML DOM element:
    var myKRPano = $('#krpanoSWFObject'); // First way, no need of "[0]"
    var otherKRPano = document.getElementById("krpanoSWFObject"); // Another way

Now you got your JS object, just call "get" method. BUT you should know that "get()" executes internal code: thus you have to place your request as a string! For instance, and with your own code:
    var spotname = "spot0";
    var query = "hotspot['"+spotname+"']"; // i.e. "hotspot['spot0']"
    var myHotspot = myKRPano.get(query); // or myKRPano.get("hotspot['spot0']");

This will provide you with something like:
    Object { _type="hotspot",  DATA={...},  plugin={...},  plus...}

From there, you can ask for
    > myHotspot.atv
      -10.5868612
    > myHotspot.name
      "spot0"

Don't hesitate to use a debug tool for your browser when working with KRPano, as a general advice. Then you can directly try your code and get the issue.
If you do so, you would see that "$('#krpanoSWKObject').get()" is set while "$('#krpanoSWKObject')[0].get()" is not. :)
Regards,

A: what are you supposed to do by getting the hotspot?
If you need to get some hotspot attribute via javascript you can call a js method in the xml   < action > tag and get the attributes directly from the xml hotspot:

in the javascript file, gets the ath and atv attributes of a hotspot and
  returns an array

function getspotcoords(ath,atv){
  var spotcoords = [ath,atv];
  return spotcoords
}

in the xml call the function in the < action /> tag, triggered when click on the hotspot

<hotspot name="myhotspot" onclick="myaction"/>

<action name="myaction">

  //js() method is required!
  js(getspotcoords(get(hotspot[0].ath), get(hotspot[0].atv)));

</action>

you can get the hotspot itself in the same way, and store it in a variable in the javascriptfile.
Hope it works!


text:
Q: What are the "Missing SQL property" here? When trying to execute the code:
function TDBClass.addNome(nome: String): String;
var
  rsnome: TADOQuery;
begin
  rsnome := TADOQuery.Create(nil);
  rsnome.Connection := connection;
  rsnome.Open();
  rsnome.SQL.Clear;
  rsnome.SQL.Text:='UPDATE enroll SET nome = "test" where id ="1"';
  rsnome.Parameters.ParamByName('nome').Value:= nome;
  rsnome.ExecSQL;
  rsnome.post();
  rsnome.Close();
  rsnome.Free();
end;

I'm receiving the error message "Missing SQL property". Where did I go wrong?
Thanks in advance!

A: You're calling rsnome.Open before setting the SQL by rsnome.SQL.Text := ....

A: I don't think you want to use Open at all, and you are using parameters incorrectly.
i.e. the SQL doesn't have any :PARAM placeholders in it.  I think it should be something like:  rsnome.SQL.Text:='UPDATE enroll SET nome = :NOME where id = :ID';
See this example:
AdoQuery Error using parameters

A: You have several errors. You're calling Open before you've assigned ths SQL (and without needing to do so).
You're trying to set a parameter value you haven't created a parameter to accept. (BTW, I'd make ID also a parameter, so you can use this to update more than one person's name.)
You're not handling making sure that things get cleaned up in case there's an error (which given the code you posted there certainly will be).
You're using Post, which isn't necessary with an SQL database.
Try something like this instead:
function TDBClass.addNome(nome: String): String;
var
  rsnome: TADOQuery;
begin
  rsnome := TADOQuery.Create(nil);
  try
    rsnome.Connection := connection;
    rsnome.SQL.Clear;
    rsnome.SQL.Text:='UPDATE enroll SET nome = :nome where id ="1"';
    rsnome.Parameters.ParamByName('nome').Value:= nome;
    rsnome.ExecSQL;
    rsnome.Close();
  finally
    rsnome.Free();
  end;
end;


text:
Q: OpenCV build error C2065? I seemed to get this OpenCV error C2065 'val' undeclared identifer out of nowhere with my opencv projects. It is an error in the opencv2\core\operations.hpp file which I have never touched. I have been using opencv for the past month with success and all the sudden this error popped out of nowhere when i just opened up my project to work on it.
I also tried re-downloading opencv and chose a different version of opencv and this same error pops up when I run the new opencv on a dummy program like the one below. I am very confused on what is happening.
#include<opencv2/core/core.hpp>

#include<iostream>

using namespace std;
using namespace cv;

int main(){
    cout << "test";

    return 0;
}

This is where the it says the error occurs in operations.hpp on lines with 'val'
template<> inline Vec<float, 3> Vec<float, 3>::cross(const Vec<float, 3>& v) const
{
    return Vec<float,3>(val[1]*v.val[2] - val[2]*v.val[1],
                     val[2]*v.val[0] - val[0]*v.val[2],
                     val[0]*v.val[1] - val[1]*v.val[0]);
}

template<> inline Vec<double, 3> Vec<double, 3>::cross(const Vec<double, 3>& v) const
{
    return Vec<double,3>(val[1]*v.val[2] - val[2]*v.val[1],
                     val[2]*v.val[0] - val[0]*v.val[2],
                     val[0]*v.val[1] - val[1]*v.val[0]);
}

Does anybody know why this could possibly be happening? I have no idea what is going on....any help would be appreciated. Thanks.


text:
Q: on minimum vertices in a graph satisfying some properties I was looking for minimal graphs (graphs with minimum number of vertices)  with following three conditions:
(1) Each vertex has degree at least $2$.
(2) Every cycle contains at least $4$ vertices.
(3) Graph has no automorphism except identity.
How can I proceed? This may be computational, but still in it, by some tricks, computations can be reduced. I don't have any clever idea for proceeding for this problem.
My partial answer: [This answer is wrong as pointed in comment by bof.] I thought following graph of six vertices is an example, but not sure about its minimality. Let $A$ be the square graph. Let $B$ be the square graph with one diagonal. Construct graph $G$ by gluing one side of $A$ with one side of $B$. Then $G$ has six vertices, and trivial automorphism. I was thinking, can there be example with five vertices?

A: Here's one way.
Brendan McKay provides data files with all simple graphs up to 10 vertices in graph6 format. A minimal example of your kind of graph must be connected, (otherwise a connected component would be a smaller example), so we can restrict our attention to the files with connected simple graphs on four or more vertices.
We can then feed these graphs to countg from the nauty gtools:
./countg -d2: -g4: -a1

to select minimum degree at least two, girth at least 4, and trivial automorphism group.
There are no such graphs with 4, 5, 6, or 7 vertices. There are three examples with 8 vertices. The third is the one bof mentioned in comments.


text:
Q: Silverlight - Exposing canvas within user control Given a custom user control having a canvas within.
<Grid>
    <Border BorderBrush="Black" BorderThickness="3">
        <Canvas x:Name="CanvasDropArea" Background="#FFF7BDBD"/>
    </Border>
</Grid>

Is there a way to expose the canvas to allow other controls to be append into the above said user control?
<CustomControlWithCanvas>
   <Canvas>
        <!--other user control-->
   <Canvas>
</CustomControlWithCanvas>

I have tried exposing it as a properties but that fails, as its be treated as a normal property instead of Collection which allow UIElements to be appended. However, i was able to append controls onto the element using code behind by retrieving the canvas and adding it manually.
So what should be the correct way of exposing the canvas? to allow it be alter during design time, and retain canvas TOP and left dependency property as well.

A: Try this - change the type of your control from UserControl to ContentControl, put  inside of your Canvas and bind the ContentPresenter's Content property to your control's Content property somehow - perhaps by naming your control and using .
In a more standard way - you would implement it as a templated/custom control instead of a UserControl, put the template in your Themes/Generic.xaml instead of MyControl.xaml, define DefaultStyleKey in your constructor, define TemplateParts etc.


text:
Q: In visualStudio cant find all the properties of an object This is a question about how to use Visual Studio to find out what the properties and methods of an object are - to help figure out how to use the object.
In the image below, in the watch window I can see all the properties of v2 including IsExpanded. However when I type a 'dot' the intellisense pops up with a different set of properties (and if I try to use v2.IsExpanded in my code I get an error).
Please can you keep the answer worded simply. (I'm not sure its a bug or I'm being ignorant.)
(I have also posted the code for my project (its a WPF app) but I dont think its relevant.)

<Window x:Class="ObjElements1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel>
            <TreeView Name="Tree1">
                <TreeViewItem Header="Tree1.1"></TreeViewItem>
                <TreeViewItem Header="Tree1.2">
                    <TreeViewItem Header="Tree1.2.1">
                        <TreeViewItem Header="Tree1.2.1.1">daslkjdlak</TreeViewItem>
                    </TreeViewItem>
                    <TreeViewItem Header="Tree1.2.1"></TreeViewItem>
                </TreeViewItem>
                <TreeViewItem Header="Tree1.3"></TreeViewItem>
            </TreeView>

        </StackPanel>
    </Grid>
</Window>

namespace ObjElements1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var v2 = Tree1.Items[0];

            //var v3 = v2.IsExpanded;
            //var v3 = v2.IsExpandedProperty;

        }
    }

}

A: I'm not familiar with WPF. In general, Visual Studio could not display intellisense for object.

In your case, Tree1.Items[0] is an object. If you want intellisense, you need to cast it to appropriate object first.
For example,

Note: Tree1.Items[0] might not be TreeViewItem, because I do not know WPF TreeView. I hope you get the idea.

A: You must remember that c# is typed at compiletime. And at that time it its type is Object.
When you look at runtime you see the current type that is in Tree1.Items[0], but for the compiler it could be any type that is an Object and he permits any Method and Property not defined on Object.

A: IntelliSense doesn't know what type the items in Tree1.Items are - they are all stored as objects. If you want to access the properties of an object stored there, you'll have explicitly cast them out of Object like this:
MyType v2 = (MyType)Tree1.Items[0];
v2. (...)

Where MyType is the actual type of Tree1.Items[0].
Addendum:
Best practice when dealing with a collection of objects you don't have full control over (some other component or method could add/remove something from Tree1), you should verify the type before you try to brute force it into a particular type. Either way works:
MyType v2 = Tree1.Items[0] as MyType;
if (v2 != null) {
    //Do something
}
else {
    //Error
}

Or:
if (Tree1.Items[0] is MyType) {
    v2 = (MyType)Tree1.Items[0];
    //Do something...
}
else {
    //Error
}

The first approach has the benefit of only calling the Items[] indexer once.


text:
Q: how to know that whether a network activity in another interface is complete or not? I have some Objective-C classes, with implementation and header files.
One class, which is subclass of AppDelegate, has a method which is like below to get data using API calling:
@implementation API
    - (NSMutableData *)set:(NSString *) API
    {
    NSURLRequest *request = [NSURLRequest requestWithURL:
                                 [NSURL URLWithString:GETString]];
    self.connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    }

I have some more classes, which is are subclass of UIViewController, from where I am calling like below:
- (void)viewWillAppear:(BOOL)animated
{
API *theInstance = [[API alloc] init];
    [theInstance set:@"&get=different&call=getAPIMethods"];
}

Now I want to get the Response Data in - (void)connectionDidFinishLoading:(NSURLConnection *)connection from the UIViewController extended class method - (void)viewDidAppear:(BOOL)animated
How can I get the return of the NSMutableData?

A: The object that is the delegate for NSURLConnection will need to adopt the NSURLConnectionDelegate protocol. The delegate object will need to implement the protocol method connection:didReceiveData: in order to save the received data.  When the connection is completed, connectionDidFinishLoading: will be called.  At this point you will need to communicate to the UIViewController the data. The easiest way to do this would be to send out a NSNotification.


text:
Q: Calculate dynamic range of rand with mod I want to create a rand() range between 1 and the dynamic value of bit_cnt.
After reading more about the rand() function, I understand that out of the box rand() has a range of [0, RAND_MAX]. I also understand that RAND_MAX's value is library-dependent, but is guaranteed to be at least 32767.
I had to create a bit mask of 64 0s.
Now, I am trying to left shift the bit mask by a dynamic value of bit_cnt anded with the a randomly generated number of bits between 1 and the dynamic value of bit_cnt.
For example, when bit_cnt is 10, I want to randomize the lowest 10 bits.
Originally, I had
mask = (mask << bit_cnt) + (rand()% bit_cnt);

which caused a floating point exception. From what I am understanding, that exception occurred because the value of bit_cntbecame 0.
Therefore, I attempted to create an if statement like this:
if((rand()%bit_cnt))!=0){
 mask = (mask << bit_cnt) + (rand()% bit_cnt);
}

,but the floating point exception still occurred.
Then I tried the following thinking that the value not be 0 so increase the value to at least 1:
mask = (mask << bit_cnt) + ((rand()% bit_cnt)+1);

,but the floating point exception still occurred.
Afterwards, I tried the following:
mask = (mask << bit_cnt) + (1+(rand()%(bit_cnt+1)));

and the following 20 lines of 64 bits outputted:
0000000000000000000000000000000000000000000000000000000000000010
0000000000000000000000000000000000000000000000000000000000000011
0000000000000000000000000000000000000000000000000000000000000101
0000000000000000000000000000000000000000000000000000000000001010
0000000000000000000000000000000000000000000000000000000000010011
0000000000000000000000000000000000000000000000000000000000100011
0000000000000000000000000000000000000000000000000000000001000110
0000000000000000000000000000000000000000000000000000000010000100
0000000000000000000000000000000000000000000000000000000100001001
0000000000000000000000000000000000000000000000000000001000000010
0000000000000000000000000000000000000000000000000000010000000100
0000000000000000000000000000000000000000000000000000100000000111
0000000000000000000000000000000000000000000000000001000000000101
0000000000000000000000000000000000000000000000000010000000001001
0000000000000000000000000000000000000000000000000100000000000111
0000000000000000000000000000000000000000000000001000000000001111
0000000000000000000000000000000000000000000000010000000000001010
0000000000000000000000000000000000000000000000100000000000000101
0000000000000000000000000000000000000000000001000000000000001101
0000000000000000000000000000000000000000000010000000000000001100

What was the cause of the floating point exception? Is this how to dynamic create a range of the rand() function?
I appreciate any suggestions. Thank you.
UPDATE:
I changed the if statement to be the following:
if(bit_cnt !=0)

and then performed the rest of the logic.
I received the following output:
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000010
0000000000000000000000000000000000000000000000000000000000000100
0000000000000000000000000000000000000000000000000000000000001000
0000000000000000000000000000000000000000000000000000000000010010
0000000000000000000000000000000000000000000000000000000000100001
0000000000000000000000000000000000000000000000000000000001000100
0000000000000000000000000000000000000000000000000000000010000110
0000000000000000000000000000000000000000000000000000000100000011
0000000000000000000000000000000000000000000000000000001000000000
0000000000000000000000000000000000000000000000000000010000001000
0000000000000000000000000000000000000000000000000000100000000111
0000000000000000000000000000000000000000000000000001000000000110
0000000000000000000000000000000000000000000000000010000000000110
0000000000000000000000000000000000000000000000000100000000001100
0000000000000000000000000000000000000000000000001000000000000010
0000000000000000000000000000000000000000000000010000000000001101
0000000000000000000000000000000000000000000000100000000000000110
0000000000000000000000000000000000000000000001000000000000010000
0000000000000000000000000000000000000000000010000000000000000100

Is there any possible way to know if the range is correct? Like is there any possible way to know by looking at the output?
const int LINE_CNT = 20;
void print_bin(uint64_t num, unsigned int bit_cnt);
uint64_t rand_bits(unsigned int bit_cnt);

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

    int i;

    srand(time(NULL));
    for(i = 0; i < LINE_CNT; i++) {
        uint64_t val64 = rand_bits(i);
        print_bin(val64, 64);
    }

    return EXIT_SUCCESS;
}
void print_bin(uint64_t num, unsigned int bit_cnt) {

    int top_bit_cnt;

    if(bit_cnt <= 0) return;
    if(bit_cnt > 64) bit_cnt = 64;

    top_bit_cnt = 64;
    while(top_bit_cnt > bit_cnt) {
        top_bit_cnt--;
        printf(" ");
    }

    while(bit_cnt > 0) {
        bit_cnt--;
        printf("%d", (num & ((uint64_t)1 << bit_cnt)) != 0);
    }
    printf("\n");

    return;
}
uint64_t rand_bits(unsigned int bit_cnt) {
    uintmax_t mask = 1;
    if (bit_cnt != 0) {
        mask = (mask << bit_cnt) + (rand()% bit_cnt);
    }
    return mask;
}

I am trying to modify the function rand_bits to return all 0 expect for the lowest bits aka bit_cnt which are randomized.
Returns a 64 bit pattern with all zeros except for the lowest requested bits, which are randomized.  This allows for arbitrary length random bit patterns in a portable fashion as the C standard "rand()" function is only required to return
random numbers between 0 and 32767... effectively, a random 15 bit pattern.
Parameter, "bit_cnt":  How many of the lowest bits, including the lowest order bit (bit 0) to be randomized.
UPDATE: Added Barmar's newest suggestion of mask = rand() % (1 << bit_cnt);:
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000010
0000000000000000000000000000000000000000000000000000000000001000
0000000000000000000000000000000000000000000000000000000000001001
0000000000000000000000000000000000000000000000000000000000000010
0000000000000000000000000000000000000000000000000000000000010101
0000000000000000000000000000000000000000000000000000000001001111
0000000000000000000000000000000000000000000000000000000010000011
0000000000000000000000000000000000000000000000000000001010101001
0000000000000000000000000000000000000000000000000000010101101100
0000000000000000000000000000000000000000000000000000101011111000
0000000000000000000000000000000000000000000000000001001010101111
0000000000000000000000000000000000000000000000000011101011000101
0000000000000000000000000000000000000000000000000001001101111101
0000000000000000000000000000000000000000000000001111000000111010
0000000000000000000000000000000000000000000000000101100000001100
0000000000000000000000000000000000000000000000100111101000111111
0000000000000000000000000000000000000000000001010101011101000110

uint64_t rand_bits(unsigned int bit_cnt) {
            uintmax_t mask = 1;
    if (bit_cnt != 0) {
    mask = rand() % (1 << bit_cnt);
    }
    return mask;
    }

A: The problem is that anything % bit_cnt will get an error if bit_cnt is 0. You need to check bit_cnt before you try to perform the modulus.
if (bit_cnt != 0) {
    mask = (mask << bit_cnt) + (rand()% bit_cnt) + 1;
}

All your attempts performed the modulus and then tried to do something with the result, but that's after the error happens.

A: This uses the bit count to generate a mask. If you want a bit count greater than can be filled by RAND_MAX, implement another random function as I commented earlier.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void) {

    int bit_cnt = 10;
    unsigned mask = 0;
    int i;
    int num;
    srand((unsigned)time(NULL));

    for(i = 0; i < bit_cnt; i++)
        mask = (mask << 1) | 1;

    printf ("For bit_cnt=%d, mask=0x%X\n\n", bit_cnt, mask);

    for (i = 0; i < 5; i++) {
        num = rand() & mask;
        printf("Random number 0x%0*X\n", 1+(bit_cnt-1)/4, num);
    }
}

Program output:
For bit_cnt=10, mask=0x3FF

Random number 0x327
Random number 0x39C
Random number 0x1B1
Random number 0x088
Random number 0x26E


text:
Q: bootstrap, white line under navigation menu, active link I have this: _Layout.cshtml
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - LolaBikeMen</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

                </button>

                @Html.ActionLink("LolaBikeMen", "Index", "Home", null, new { @class = "navbar-brand" })

                    @*

                        @Html.Partial("_LoginPartial")

*@

                        @*
@Html.ActionLink("Home", "Index", "Home")
*@

                            @Html.ActionLink("WHO", "Index", "Account")

@Html.ActionLink("WHAT", "Index", "Student")

@Html.ActionLink("AGENDA", "Index", "Course")

@Html.ActionLink("PHILOSPY", "Index", "Instructor")

@Html.ActionLink("BUCKET-LIST", "Index", "Department")

@Html.ActionLink("LolaRiders", "Index", "LolaBiker")

@Html.ActionLink("bycicle", "Index", "Bycicle")

 @Html.Partial("_LoginPartial")

        @RenderBody()

© @DateTime.Now.Year - LolaBikeMen

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)

and this is my site.css:
/* Move down content because we have a fixed navbar that is 50px tall */
.container{
    /*background-color:MenuText;*/
}
.container2{

    width:100%;
    height:100%;
}

label
{
    color:white;

}

.add-on .input-group-btn > .btn {
  border-left-width:0;left:-2px;
  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
/* stop the glowing blue shadow */
.add-on .form-control:focus {
 box-shadow:none;
 -webkit-box-shadow:none;
 border-color:#cccccc;
}

body {

    margin-top:90px;

    /*padding-top: 90px;
    padding-bottom: 20px;*/

}

/*html {
            background: url(~/Images/Large.JPG) no-repeat center center fixed;
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
        }*/

.wrapper {
  background-image: url(../Images/Large.JPG);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  width: 100%;
  height: 100%;

}
.wide {
  width:100%;
  height:1000px;
  background-image:url('../Images/Large.JPG');
  background-size:cover;
}

.wide img {
  width:100%;
}

navbar{
    color:white;
}

.table-striped>tr>td:nth-child(odd)>td,
.table-striped>tr>td:nth-child(odd)>td {
    background-color:white;
}

.table.table-condensed tr th {
   border-top: 1px solid white;
}

.table.table-condensed tr th {
   border-bottom: 1px solid white;
}

.a:hover, a:focus {
        color:floralwhite;
        text-decoration: underline;
    }

a {
    color:floralwhite;
    text-decoration: none;
}

.table.table-condensed tr td {
   border-bottom: 1px solid white; /* Change the color you want to set */
}

.wrapper {
    width: 100%;
    background-color: lightcyan;
}

img {
    background-image: url('../Images/Large.JPG');
    background-repeat: no-repeat;
    background-position:top;
    background-size:cover;
    width: 100%;
    height: 100%;
}

/**/
#map {
        height: 100%;
        width: 100%;
}

#map img {
        max-width: 100%;
}

html, body {
        height: 100%;
        width: 100%;
}

.hallo{
     background-image: url('../Images/Large.JPG');

}

.fullscreen,
.content-a {
    width:100%;
    min-height:100%;
}

.background {
    background-image: url('../Images/Large.JPG');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: 100%;

}

.fill {
    top: -10px;
    left: 0;
    right: 0;
    bottom: 0;
    position:relative;
    /*overflow-x;*/
    width:100%;
    height:100%;
}

html,body{height:100%;}
.carousel,.item,.active{height:100%;}
.carousel-inner{height:100%;}
.fill{width:100%;height:100%;background-position:center;background-size:cover;}

.navbar {
        margin-bottom: 0;
}

/* Demo */
#map { background:black; }

/**/

/* Wrapping element
/* Set some basic padding to keep content from hitting the edges */
.body-content {
    padding-left: 15px;
    padding-right: 15px;

}

/* Override the default bootstrap behavior where horizontal description lists
   will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
    white-space: normal;
}

/* Set widths on the form inputs since otherwise they're 100% wide */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="select"] {
    max-width: 280px;
}

/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
    .jumbotron {
        margin-top: 20px;
    }
    .body-content {
        padding: 0;

    }
}

How to make a white line under the active link in the menu bar? I triied with Active:IsActive, but how to make the white line under the active link.
Thank you
I have it now like this:

@Html.ActionLink("WHO", "Index", "Account")

@Html.ActionLink("WHAT", "Index", "Student")

@Html.ActionLink("AGENDA", "Index", "Course")

@Html.ActionLink("PHILOSPY", "Index", "Instructor")

@Html.ActionLink("BUCKET-LIST", "Index", "Department")

@Html.ActionLink("LolaRiders", "Index", "LolaBiker")

@Html.ActionLink("bycicle", "Index", "Bycicle")

 @Html.Partial("_LoginPartial")

and this for site:
.active {
            font-style:oblique ;
             border-bottom:1px solid white;

        }

But now all the items have a white stripe, and not onely the active link.
If I use this:
li.active > a {
    border-bottom:1px solid red;
}

then also all the items have red line
and if I just do this:

                            @Html.ActionLink("WHO", "Index", "Account")

                            @Html.ActionLink("What", "Index", "Student")

 @Html.Partial("_LoginPartial")

still both items are highlighted

A: A possible solution
li.<active-class> > a {
   border-bottom:1px solid white;
}

Replace '<active-class>' with the class name you are using. f.i. class name = active than it would be li.active > a
See JSFiddle for an example with a red underline (red to see the result)


text:
Q: Smoke detectors replacing - why? Lifetime of components? I often see that smoke detectors "should be replaced" every 5, 10 or 20 years. Like on this website for example: http://modernsurvivalblog.com/health/did-you-know-smoke-detectors-expire/

The U.S. Fire Administration says most smoke detectors installed today have a life span of about 8-10 years. After this time, the entire unit should be replaced.

I wonder why? It probably has nothing to do with half-life of Americium 241(because it is 432 years), so what is the reason? I though about electrolytic caps, but mine for example has only one and its lifespan is often much higher than 10 years(if it is not piece of crap). I don't see any other electronic-related problems with the circuit in this things, it is pretty easy and hardly anything can break inside if it just sits on the ceiling doing nothing 99% of the time.
Is there logical reason or is it "just in case"?

A: As you suspected, apparently it has nothing to do with the radioactive material in those alarms that use it.
According to the Reliability section for smoke detectors:

The NFPA strongly recommends the replacement of home smoke alarms
  every 10 years. Smoke alarms become less reliable with time, primarily
  due to aging of their electronic components, making them susceptible
  to nuisance false alarms. In ionization type alarms, decay of the
  241Am radioactive source is a negligible factor, as its half-life is
  far greater than the expected useful life of the alarm unit.

So it is just a matter of component reliability.  Although we are used to some electronic devices working for decades, we also accept that sometimes (but very infrequently) they just up and die, and perhaps on a statistical basis 10 years has been found to be a good marker for these alarms where one can be assured some large number of units (99% or higher?) will still be working.
Anecdotally, the house we are currently living in was built 20 years ago.  We bought it 10 years ago.  It has 10 smoke alarms in it.  I never knew about the "replace every 10 years" rule.  About two months ago, some of the alarms started to go off on their own (false alarms).  After this happened a couple of times, I replaced them all.

A: I think it's because the latest smoke alarms are sealed to prevent tampering.  You can't open them up to really blow the dust out of the ionization chamber with a vacuum cleaner.  Over time, dust accumulates in the ionization chamber making it less reliable.  That's why the NFPA tells you to replace the smoke alarm after ten years.


text:
Q: BigQuery + Angular + Firebase Functions results limited by oversize I'm using the @ google-cloud/bigquery library with a Firebase feature, so I can bring data from BigQuery in Angular
node library:
https://www.npmjs.com/package/@google-cloud/bigquery
My problem is that there are some fields that have a large number of bytes, and when I consult them, it does not bring them complete, it has a kind of limitation in this regard, I have already looked at the library documentation and have also been investigating the Google documentation and what I tried has not served, does anyone have any idea how I should proceed with this?
I do not find how to give more solution to this limitation, it would help me any kind of help


text:
Q: How to get WebView URL in W10 Mobile (UWP) (Xamarin forms) I'm developing an application for W10 Mobile (UWP) in Xamarin forms and I have implemented a WebView and I tried to get the URL of this but it is more complicated than I thought at first, I tried to get it through the source property, but not is possible, I would appreciate a help.

A: You could create an event handler to the navigation completed event.
With that you can check the URL
example:
WebView browser = new WebView();

browser.Navigated += OnNavigatedHandler;
public void OnNavigatedHandler (object sender, WebNavigatedEventArgs args){

Console.WriteLine ("Navigated to: " + args.Url);
}

A: I'm having trouble getting the URL of the browser in real time, the way you indicate I enter an infinite loop, I have a binding in my WebView on the SourceProperty in the view model called URL, when there is a change in the URL property I detect it thanks to PropertyChanged, the problem is that the event navigated only runs when updating the value of the URL property which causes the infinite loop to load the WebView infinitely. Is there any other way to get the URL?
I have uploaded in Pastebin the classes of the test project I am using:
View: pastebin.com/msyu9dJF
ViewModel: pastebin.com/LaCfC31c
BaseViewModel: pastebin.com/i6GCFbbe


text:
Q: App URL for +1 button How can I get URL to gogle play site for +1 button? That one:

Original adress doesn't direct to that. I mean something like that:
String URL = "https://play.google.com/store/apps/details?id=my.package.name";
mPlusOneButton.initialize(mPlusClient,
                URL , PLUS_ONE_REQUEST_CODE);

Could you give me some example google play app URL?

A: try this one:
https://market.android.com/details?id=my.package.name"
Hope it helps.

A: You need to replace "my.package.name" with the id of your app.
For example:
https://play.google.com/store/apps/details?id=tunein.player

This is the URL to TuneIn Radio on Google Play. TuneIn Radio has the app id: tunein.player
Does that sort of answer your question?


text:
Q: IE9 randomly popping Windows Security Dialog when I send down a binary blob as a .xlsx So on our website, we have multiple reports that can be downloaded as an Excel Spreadsheet, we accomplish this by reading in a blank template file from the harddrive, copying it into a MemoryStream, pushing the data into the template with DocumentFormat.OpenXml.Spreadsheet;  Then we pass the MemoryStream to a function that sets the headers and copies the stream into the Response.
Works GREAT in FF & Chrome, but IE9 (and 8, so my QA tells me) randomly pop a Windows Security login dialog asking you to log into the remote server.  I can either cancel the dialog, or hit ok (the credentials seem to be ignored), and get the Excel file as expected.  Looking at the queries (using CharlesProxy) I cannot get the login dialog to pop until I disable CharlesProxy again, so I cannot see if there's any difference in the traffic between my dev machine and the server.  It also doesn't happen when running debug from my local-host, just from the Dev/Test server.
Any help would be useful, the code in question follows.  This is called out of a server-side function in the code behind, hence the RespondAsExcel clears the response and puts in the xlsx instead.
            using (MemoryStream excelStream = new MemoryStream())
    {
        using (FileStream template = new FileStream(Server.MapPath(@"Reports\AlignedTemplateRII.xlsx"), FileMode.Open, FileAccess.Read))
        {
            Master.CopyStream(template, excelStream);
        }

    //Logic here to push data into the Memory stream using DocumentFormat.OpenXml.Spreadsheet;

        Master.RespondAsExcel(excelStream, pgmName);
    }

        public void RespondAsExcel(MemoryStream excelStream, string fileName)
{
    var contenttype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.Clear();
    Response.ContentType = contenttype;
    fileName = Utils.ReplaceWhiteSpaceWithUnderScores(fileName);
    Response.AddHeader("content-disposition", "inline;filename=" + fileName);
    Response.Cache.SetCacheability(HttpCacheability.NoCache);

    Response.BinaryWrite(excelStream.ToArray());
    //If that doesn't work, can try this way:
    //excelStream.WriteTo(Response.OutputStream);

    Response.End();
}

        public void CopyStream(Stream source, Stream destination)
{
    byte[] buffer = new byte[32768];
    int bytesRead;
    do
    {
        bytesRead = source.Read(buffer, 0, buffer.Length);
        destination.Write(buffer, 0, bytesRead);
    } while (bytesRead != 0);
}

A: A couple of ideas come to mind regarding that "extra authentication dialog" that can always be dismissed...won't promise this is your issue, but it sure smells like a first-cousin of it.
Office 2007 and later documents open HTTP-based repositories with the WebClient libraries, which do not honor any of IE's security zone filters when requests are made. If the file is requested by IE, and host URL contains dots (implying a FQDN), even if the site is anonymously authenticated (requiring no credentials), you'll get the "credential" dialog that can be cancelled or simply clicked three times and discarded. I was dealing with this problem just yesterday, and as best I can tell, there's no workaround if the file is delivered with IE. There's some quirk about how IE delivers the file that makes Office apps believe it has to authenticate the request before opening it, even though the file has already been delivered to the client!
The dialog issue may be overcome if the document is delivered from a host server in the same domain as the requesting server, eg some-server.a.domain.com to my-machine.a.domain.com.
The second idea is something strictly born of my own experience - that the openoffice vendor format types sometimes introduce their own set of oddness in document stream situations. We've just used a type of application/vnd.ms-excel and, while it seems it should map to the same applications, the problems don't seem to be as prevalent.
Perhaps that can give you some thoughts on going forward. Ultimately, right now, I don't think there's an ideal solution for the situation you're encountering. We're in the same boat, and had to tell our in-house clients that get the dialog to just hit "Cancel," and they get the document they want.

A: In your RespondAsExcel() method, change your content-dispositon response header from inline to attachment. This will force the browser to open the file as read only. See KB899927.
Response.AddHeader("content-disposition", "attachment;filename=" + fileName);

A: I had something similar with VBScript when using "Response.ContentType="application/vnd.ms-excel".  I simply added the following code and the Windows Security popup window no longer appeared:
Response.AddHeader "content-disposition","attachment; filename=your_file_name_here.xls"


text:
Q: Python: Dataframes FutureWarning: for list-likes to .loc or [] I have a dataframe which contains 4,000,000 records, I use it to apply rules and update a particular column with rule id
test_condition="(df['column_a']=='US' & df['column_b']=='GB')"
intermediate_df=df.loc[eval(test_condition),['column_a','column_b']]
intermediate_df.loc[:,'column_b']=str(variable1) + "-----" + str(variable2)

for the below line
intermediate_df=df.loc[eval(test_condition),['column_a','column_b']]

A warning message is popped
FutureWarning:
Passing list-likes to .loc or [] with any missing label will raise
KeyError in the future, you can use .reindex() as an alternative.
However, when i try to reindex() for example
intermediate_df=df.reindex([eval(test_condition),columns='column_a','column_b'])

I get completely different results (not same as loc)
Can someone suggest me how to modify from loc to reindex()