text:
Q: Jquery hover function not working HTML

 This is a paragraph

JS/Jquery
$("para").hover(function() {$(this).hide();}, function() {$(this).show();});

Now what i am trying to is when mouse is over the paragraph, the element should hide and when mouse leaves the element is should be visible again. However neither the paragraph is hiding and hence not appearing back. What's wrong here ?

A: You're missing the # ID selector, having just "para" is looking for a tag <para> (which of course doesn't exist in this case.
$("#para")

On a side note, you typically want to have some sort of div (of a set size let's say) etc wrapped around a situation like this, and there is where the hover event is taken from, and the inner div shown. Makes it less "skippy".
Also if you do it with a div it can be done with CSS:
div:hover #para { display:block; }

jsFiddle CSS example

A: You missed "#" for ID.
$("#para").hover(function() {$(this).hide();}, function() {$(this).show();});

A: Assuming the missing # as a typo in the OP.. your code is not going to work as desired.. because the mouse out will be triggered as the element is hidden.
DEMO: http://jsfiddle.net/s8cpz/

A: This code will never work. When you are hovering over it, it is supposed to vanish instantly, right? However, when it vanishes, the mouse is still over it, and thus the vanishing p will register it as a mouseleave, (all it sees is the cursor is separated from it, whether the cursor is the culprit, or is it itself, it doesn't care), effectively firing the mouseleave handler of the hover, and this will continue ad infinitum, leading to rapid blinking of the p. You can do $("p").css({opacity',0.01}) instead of $('p').hide(). Check the problem with this code:
<!DOCTYPE html>

 This is a paragraph

Keep your mouse on the p, after 10 seconds, when the p vanishes, you will see the alert poping up, signifying the firing of the mouseleave handler.

A: if you correct ('para') with ('#para') you can not get your goal because when you hide p tag immediately mouseout event activate and hide() method run and you p tag start blinking until mouse cursor over.
it
this some solution might helpful.
$("#body").hover(function(){
$("#para").css("visibility","hidden");},
            function()
            {$("#para").css("visibility","visible");
            }
           );

 This is a paragraph

DEMO

A: First, you missed the #, second, when an element hides, its css display property changes to none, so it occupies no space on page, so the mouse is not on it anymore, and it will show up again. This creates an infinite loop of a sort. Errors like these are purely logical and at times will even crash older versions of browsers.


text:
Q: how to get react function to update state with user input I have written a function in react that, through a rendered submit form, takes a user's input, uses it to query an api and updates p tag content in the form. This is the following code:
var textfield = ""
function Form (){
        const [ name, getNFT ] = useState("")
        let postName = (e) =>{
            let output
            async function getInfo(e) {
                e.preventDefault()
                try {
                    const resp = await axios.post("/hey_honey", {
                        name
                    })
                    console.log(resp.data)
                    output = resp.data
                    return output
                } catch (error) {
                    console.error(error)
                }
            }

        getInfo(e).then(output =>{console.log("output is outside of function scope", output)
        })
        textfield = output
        return textfield
    }

    return (

            <form onSubmit={postName}>
                <input type="text" value={name} onChange={(e) => getNFT(e.target.value)}/>
                <button type="submit" >Get Collection's Gallery</button>

{textfield}

            </form>

    )
}

I have successfully gotten the JSON string that I wanted. The problem is I seemingly have no way of updating the rendered form because it is either outside of postName's function scope or anything modified by postName even if instantiated outside of form cannot actually change the states.
At one point I thought that this was most likely because this is a more appropriate instance of using a class, I however can't use useState and therefore would have no way of storing the content written out in the submit form. What am I missing here?"
(Edit: after some research there are ways I can do this with a class. I technically don't need to utilize useState for a form but rather I could use setState and simply instantiate setState as the empty string.
It would look something like this, and say for the sake of things we just have a function that simply returns the input as opposed to the async function:
class NameForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {value: '', textfield: ''};

    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  handleChange(event) {
    this.setState({value: event.target.value});
  }

  handleSubmit(event) {
    this.setState({textfield: event.target.value})
  }

  render() {
    return (
      <form onSubmit={this.handleSubmit}>

          Name
          <input type="text" value={this.state.value} onChange={this.handleChange} />

        <input type="submit" value="Submit" />

{this.state.textfield}

      </form>

    );
  }
}

However we still run into the issue of updating the form itself.)
Edit
Is this a specific issue with forms elements? When someone is posting a comment on a blog is there a different component entirely that I should be using? I was drawn to forms because they take user input and then give you something that you can manipulate but is it maybe that they are immutable once you set them up?
At the time of writing this I am beginning to consider that this is when I should export a stored value, say textfield in my case, and just pass it into an entirely new component. Will update.

A:
The problem is I seemingly have no way of updating the rendered form because it is either outside of postName's function scope or anything modified by postName even if instantiated outside of form cannot actually change the states.

When it comes to React, at the end of the day, if you want to make it re-render you need to update React state. What you're doing here with textfield is updating a JS variable, but React doesn't have a way of knowing that that variable is different, so it won't know to re-render.
Notice what you're doing with your input. Because you've set value, it's a "controlled input" and therefore the only reason you can see the text you type is because you're updating React state and triggering a re-render with every key press.
You can do the same thing with the result of your network request. Once the request finishes, you can update a piece of state, which will trigger the re-render. Note that if you don't use that state (e.g. by rendering out some of it) you won't be able to tell that React has re-rendered just from looking at it the browser.
Here's a minimally different example that makes a network request based on your form input and renders the result. (The variable names don't make a ton of sense for this API, just wanted to keep the diff small).
function Form() {
  const [name, getNFT] = useState("");
  const [jokes, setJokes] = useState([]);

  let postName = (e) => {
    let output;
    async function getInfo(e) {
      e.preventDefault();
      try {
        // swapped this out to a free public API so we could see a result
        const resp = await axios.get(`https://icanhazdadjoke.com/search?term=${name}`, {
          headers: {
            // you need to tell this API you want the results as JSON, instead of HTML (the default)
            'Accept': 'application/json'
          }
        });
        console.log(resp.data);
        output = resp.data;
        return output;
      } catch (error) {
        console.error(error);
      }
    }

    getInfo(e).then((output) => {
      console.log("output is outside of function scope", output);

      // this is the big change!
      setJokes(output.results);
    });
  };

  return (

      <form onSubmit={postName}>
        <input
          type="text"
          value={name}
          onChange={(e) => getNFT(e.target.value)}
        />
        <button type="submit">Get Collection's Gallery</button>

{jokes[0]?.joke}

      </form>

  );
}

And here's a version that does the same thing but cleans it up a little bit, just to compare:

// this is a pure js function - no react! It just makes the request and returns the result
async function searchJokes(jokeTerm) {
  try {
    // swapped this out so we could see a result
    const jokesResponse = await axios.get(
      `https://icanhazdadjoke.com/search?term=${jokeTerm}`,
      {
        headers: {
          // you need to tell this API you want the results as JSON, instead of HTML (the default)
          Accept: "application/json"
        }
      }
    );

    console.log("jokes response", jokesResponse);
    return jokesResponse.data;
  } catch (error) {
    console.error(error);
  }
}

function Form() {
  const [searchTerm, setSearchTerm] = useState("");
  const [jokes, setJokes] = useState([]);

  return (

      <form
        onSubmit={async (e) => {
          e.preventDefault();

          // whereas the pure js function can just return its request normally, inside here we need
          // to take the result and stick it in React state.
          const jokesData = await searchJokes(searchTerm);
          setJokes(jokesData.results);
        }}
      >
        <input
          type="text"
          value={searchTerm}
          onChange={(e) => setSearchTerm(e.target.value)}
        />
        <button type="submit">Search Jokes</button>

{jokes[0]?.joke}

      </form>

  );
}

(Sandbox). To be clear, the above is definitely not perfect!

        getInfo(e).then(output =>{console.log("output is outside of function scope", output)
        })
        textfield = output
        return textfield

Setting aside React, one thing to remember is that the code inside the function inside then will run when getInfo(e) is done fetching its information from the internet, but the lines after run right away without waiting, because the getInfo call returns a Promise. In JS, async logic like that is non-blocking! You can see above how you use await to avoid needing a then and the nesting. (But, it's worth remembering that async/await is just fancy syntax for Promises and .then, so anything you can do with one you can do with the other).
Also, because of function scoping, you won't be able to access output outside of the then function. You'd have to do that variable assignment inside that function, or use async await to flatten things a bit.

At one point I thought that this was most likely because this is a more appropriate instance of using a class, I however can't use useState and therefore would have no way of storing the content written out in the submit form. What am I missing here?

In React, it used to be that you needed classes for more complex components, like ones with state, and could only use functions for presentational components. But ever since they introduced hooks, class components and functional components can do the same things in different ways, so what you're doing here is fine! I would stick with function components like you've got while you're learning.
Outside of React, classes are a good option when dealing with state (though you can also do equivalent things with nested functions). But you'd still need some way to map updates to your vanilla JS class state to React state. To start, I would focus mostly on storing state within React, and as you build bigger apps you can either spend some time learning how to tie them into your own custom classes, or bring in a state management library (Redux is probably the most well known) to handle that for you.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Finding out a directory's previous permissions I have root access in my Linux environment. I have a directory 'officestaff'; this directory permissions were changed to 775 and the modification date changed. How can I know the previous permissions of that directory before modification?
I have tried history but it does not show any chmod on the directory.

A: Past permissions of files are not recorded by default. Unless you had taken steps to set up some form of logging before the change happened (a variant of Is it possible to find out what program or script created a given file?), this information is not available. And even then logging would only tell you what changed, not what was there before.
Even if you did find the command that changed the permissions in some history, that wouldn't tell you what the previous permissions were.
Unless you had set up a way to track permission history, the only place where the historical information is available is your backups.


text:
Q: Using IBM EventStreams with C/C++ I need to use Event Streams from a C++ program. Looking for sample code.
Tried ./rdkafka_example from librdkafka, I dont get any error message but messages dont get through. It may an be authorization issue as I could not find where to supply credentials to the code.
Is there a sample c++ program anywhere?

A: Librdkafka comes with a few C++ examples that can be used with Event Streams.
For example, for Event Streams on Cloud, using the rdkafka_example_cpp sample:
To produce, run:
./rdkafka_example -P -t <TOPIC> -b <BOOTSTRAP_SERVERS> \
  -X security.protocol=SASL_SSL -X sasl.mechanisms=PLAIN -X sasl.username=<USERNAME> \
  -X sasl.password=<PASSWORD> -X ssl.ca.location=<CA_PATH> -X api.version.request=true \
  -X broker.version.fallback=0.10.2.1 -X log.connection.close=false

To Consume, run:
./rdkafka_example -C -t <TOPIC> -p 0 -b <BOOTSTRAP_SERVERS> \
  -X security.protocol=SASL_SSL -X sasl.mechanisms=PLAIN -X sasl.username=<USERNAME> \
  -X sasl.password=<PASSWORD> -X ssl.ca.location=<CA_PATH> -X api.version.request=true \
  -X broker.version.fallback=0.10.2.1 -X log.connection.close=false

Replace the placeholders between <> with your Event Streams credentials.
See how the arguments passed with -X are used in the example to build a Config: https://github.com/edenhill/librdkafka/blob/master/examples/rdkafka_example.cpp#L342-L375


text:
Q: How to change the default layout(activity_main) in android studio I want to create a login activity for my app but the default layout keeps showing up when i run my app on AVD.
i don't want any blue on my layout, all i want in the yellow part
below is my layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:paddingLeft="20dp"
android:paddingTop="20dp"
android:paddingRight="20dp"
android:paddingBottom="20dp"
android:background="@android:color/holo_orange_light">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:text="@string/mobile_money_market"
    android:layout_weight="0.05"
    android:textAlignment="center"
    android:inputType="text"
    android:textStyle="bold" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_weight="0.05"
    android:text="@string/free_advertising"
    android:textAlignment="center" />

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:ems="10"
    android:id="@+id/editText1"
    android:hint="Email..."
    android:layout_marginTop="30dp" />

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:ems="10"
    android:id="@+id/editText2"
    android:hint="Password..."
    android:layout_marginTop="20dp" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/item">

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="@string/sign_in"
        android:id="@+id/sign_in_button"
        android:layout_weight="1" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/sign_up"
        android:id="@+id/sign_up_button"
        android:background="@color/errorColor" />

</LinearLayout>
</LinearLayout>

I want to know how to remove the blue portion from my activity. I don't want the name Mobile Money Market to appear twice as show in the picture above.
I want to remove the default android Header(The portion in Blue) from the layout.
my layout as it appears on my AVD
I need help please. Can someone advice me on what to do or what not to do. Thanks in advance

A: You need to hide the action bar.
The simplest way to do that is to add a style in the style.xml file. Something like this:
<resources>
    <!-- No action bar theme -->
    <style name="NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/blueDark</item>
        <item name="colorPrimaryDark">@color/blueDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>

Did you notice the parent? "NoActionBar".
And then in your manifest change the theme of your activity:
<activity
        android:name="your.package.name.YourActivity"
        android:label="@string/application_name"
        android:theme="@style/NoActionBar" />

A: requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

Add these lines before setContentView

A: You can try to this code..
Mainactivity.java
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

  }
}

Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_orange_light"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@android:color/holo_orange_light">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="Home Activity"
        android:textSize="20sp" />
</LinearLayout>

and style.xml
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

A: You can access that BLUE BAR as per your requirement from the "Styles" resource file.
You Can change colour, theme, style etc as per ur need.
Go to XML files, Click:-
res -> values -> styles.


text:
Q: Validate textfield using Reactive Cocoa swift I am trying to validate UITextField if it has greater than 3 characters it should return true else return false. I tried using the below code but it is not working. What am I doing wrong?
 let validUserNameSignal = self.nameTextField.reactive.trigger(for: .valueChanged).observeValues {
        value in

    }.map { (value) in

        String(describing: value).characters.count > 3 ? true:false

    }
    print("user name valid result is \(validUserNameSignal)")

A: Here's how the code should look.
let validUserNameSignal =
        self.nameTextField
            .reactive
            .continuousTextValues
            .skipNil()
            .map { $0.characters.count > 3 }

validUserNameSignal.observeValues { value in
    print("user name valid result is \(value)")
}


text:
Q: how to use django authentication views.py
from django.contrib.auth import authenticate
def loginf(request):
    username = "ph"
    password = "mypassword"
    user = authenticate(username=username, password=password)
    if user is not None:
        print(user)
    else:
        print("not  found")

return render(request,'myapp/login.html',)

urls.py
from django.contrib import admin
from django.urls import path
from django.urls.conf import include
from . import views

urlpatterns = [

    path('',views.Home.as_view(),name='index'),
    path('signup/',views.SignUpView.as_view(),name='signup'),
    path('login/',views.loginf, name ='login')

]

it always return "not found". my username and password are valid, i have double checked username and password, and tried with many users, what i am doing wrong. password saved in database in pbkdf2_sha256 algorithm, how do i authenticate.

A: You may try replacing:

user = authenticate(username=username, password=password)

with
user = authenticate(request, username=username, password=password)


text:
Q: Using FileSystemWatcher to alert if multiple files change simulatenously I am very new to powershell. The following code is created by BigTeddy and he gets the full credit (I also made some Changes using the While Loop)
I want to know how can I create an if/else statement such that if more than one file is changed/edited/created/deleted at the same time (say ten files have been edited simultaneously) a log file will be created saying these list files has been edited simultaneously at this particular time.
The following powershell script BigTeddy created basically spits out a log file (and on the output of the powershell ISE) of when a change/edit/creation/deletion has been made, the time it was changed and what file(s) was edited.
 param(
        [string]$folderToWatch = "C:\Users\gordon\Desktop\powershellStart"
      , [string]$filter        = "*.*"
      , [string]$logFile       = 'C:\Users\gordon\Desktop\powershellDest\filewatcher.log'
    )

    # In the following line, you can change 'IncludeSubdirectories to $true if required.
    $fsw = New-Object IO.FileSystemWatcher $folderToWatch, $filter -Property @{IncludeSubdirectories = $false;NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'}
    $timeStamp           #My changes
    $timeStampPrev = $timeStamp         #My changes
# This script block is used/called by all 3 events and:
# appends the event to a log file, as well as reporting the event back to the console
$scriptBlock = {

  # REPLACE THIS SECTION WITH YOUR PROCESSING CODE
  $logFile = $event.MessageData # message data is how we pass in an argument to the event script block
  $name = $Event.SourceEventArgs.Name
  $changeType = $Event.SourceEventArgs.ChangeType
  $timeStamp = $Event.TimeGenerated
  while($timeStampPrev -eq $timeStamp) {     #My changes
  Write-Host "$timeStamp|$changeType|'$name'" -fore green
  Out-File -FilePath $logFile -Append -InputObject "$timeStamp|$changeType|'$name'"
  # REPLACE THIS SECTION WITH YOUR PROCESSING CODE
}
}

# Here, all three events are registered.  You need only subscribe to events that you need:
Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -MessageData $logFile -Action $scriptBlock
Register-ObjectEvent $fsw Deleted -SourceIdentifier FileDeleted -MessageData $logFile -Action $scriptBlock
Register-ObjectEvent $fsw Changed -SourceIdentifier FileChanged -MessageData $logFile -Action $scriptBlock

# To stop the monitoring, run the following commands:
#  Unregister-Event FileDeleted  ;  Unregister-Event FileCreated  ;  Unregister-Event FileChanged

#This script uses the .NET FileSystemWatcher class to monitor file events in folder(s).
#The advantage of this method over using WMI eventing is that this can monitor sub-folders.
#The -Action parameter can contain any valid Powershell commands.
#The script can be set to a wildcard filter, and IncludeSubdirectories can be changed to $true.
#You need not subscribe to all three types of event.  All three are shown for example.

A: Have you considered a hash table with timestamps and action(create/modify/delete) as keys and file name as value. You iterate through the dictionary after a specific wait interval and you flush the entries in the dictionary to a log file.


text:
Q: UITableView discloure indicator going nuts I have a UITableView (on a UIViewController) which is pushed via a navigationController. Along with pushing, I select with which array i want to populate the table. The code for pushing is like this:
if(self.newView == nil)
{
    NewView *viewTwo = [[NewView alloc] initWithNibName:@"Bundle" bundle:[NSBundle mainBundle]];
    self.newView = viewTwo;
    [viewTwo release];
}

[self.navigationController pushViewController:self.newView animated:YES];
newView.tableArray=newView.arrayWithOptionOne;
[newView.tableView reloadData];

All works well and the table gets reloaded every time. However in the last row of section 0, there is a switch which loads section 1.
The last row of section 1 is tappable (didSelect…) and it loads a modalView. On this last rod I added a disclosure indicator and also the blue background when tapping. The table has sliders, labels, etc. So the customization is quite long:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewCell *cell = nil;

static NSString *kDisplayCell_ID = @"DisplayCellID";

cell = [tableView dequeueReusableCellWithIdentifier:kDisplayCell_ID];

if (cell == nil)
    {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:kDisplayCell_ID] autorelease];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    }
else
    {

    UIView *viewToRemove = nil;
    viewToRemove = [cell.contentView viewWithTag:1];
    if (viewToRemove)
        [viewToRemove removeFromSuperview];

    UIView *viewToRemove2 = nil;
    viewToRemove2 = [cell.contentView viewWithTag:2];
    if (viewToRemove2)
        [viewToRemove2 removeFromSuperview];

 }

    if (indexPath.section==0) {
        UIControl *cellValueS = [[[arrayTable objectAtIndex:indexPath.section] objectForKey:kViewKey] objectAtIndex:indexPath.row];
        [cell.contentView addSubview:cellValueS];
    }

    if (indexPath.section==0 && indexPath.row==3) {
        UIControl *cellValueL = [[[arrayTable objectAtIndex:indexPath.section] objectForKey:kViewLabel] objectAtIndex:0] ;
        [cell.contentView addSubview:cellValueL];
    }

    if (indexPath.section==1 && indexPath.row==0){
        UIControl *cellValueS = [[[arrayTable objectAtIndex:indexPath.section] objectForKey:kViewKey] objectAtIndex:indexPath.row] ;
        [cell.contentView addSubview:cellValueS];
    }

    if (indexPath.section==1 && indexPath.row==1) {
        UIControl *cellValueS = [[[arrayTable objectAtIndex:indexPath.section] objectForKey:kViewKey] objectAtIndex:indexPath.row] ;
        [cell.contentView addSubview:cellValueS];

        UIControl *cellValueL = [[[arrayTable objectAtIndex:indexPath.section] objectForKey:kViewLabel] objectAtIndex:0] ;
        [cell.contentView addSubview:cellValueL];
    }

    if (indexPath.section==1 && indexPath.row==2) {
        cell.selectionStyle = UITableViewCellSelectionStyleBlue;
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    }

    return cell;
}

So far also works ok.
The problem is that when I go back to the previous view and select another option to populate the table, when it's pushed again, I see the disclosure   indicator and blue selection background on other rows on the same section. I've observed that it depends on where the table is scrolled.
I've tried to understand why does it happen, but i can't. I've somehow solved the problem by setting newView to nil and releasing it and then allocating it again before it gets pushed again.
Am I doing something wrong here? or why is the disclosure indicator and tapping background appearing where they are not supposed to be?
Thanks in advance!
action of the switch
-(void)extraOptionsSwitchAction:(id)sender{

 switch(extraOptionsSwitch.isOn) {

 case 1:

 // [self.tableView beginUpdates];
 [self.tableView insertSections: [NSIndexSet indexSetWithIndex:1]  withRowAnimation:UITableViewRowAnimationAutomatic];
 [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];

 //[self.tableView reloadData];
 //  [self.tableView endUpdates];

 break;

 case !1:

 //   [self.tableView beginUpdates];
 [self.tableView deleteSections: [NSIndexSet indexSetWithIndex:1]  withRowAnimation:UITableViewRowAnimationAutomatic];
 // [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];

 [self.tableView reloadData];
 // [self.tableView endUpdates];

 break;

 }
 }

A: It has to to with reusing cells. You probably don't differentiate between the different cell types in your cell creation method - so one cell that went offscreen can easily be reused for another (different type) cell. Further, you seem to add subviews over and over again - only do that when you instantiate the cell (with alloc/int), and not when configuring.
Also, for different cell types, use different identifiers (you didn't show this code).
The programming guides have good example on table views and their cells and reuse pattern. It's worth reading a couple of times - it's easy to get wrong and is a main topic for performance tuning.
Edit
Now that you added more code, another problem seems to be here:
if (indexPath.section==1 && indexPath.row==2) {
    cell.selectionStyle = UITableViewCellSelectionStyleBlue;
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}

You are missing an else part. The selectionStyle and accessoryType are set to what they were set to before - you miss to configure the cells correctly for all other cells than that special one.
Each cell type should really get its own identifier though. If the adding/removing of subviews work as expected is hard to tell from that code.
One thought: As you aren't really reusing a lot of the cells here anyhow you could even disable the reuse by changing
static NSString *kDisplayCell_ID = @"DisplayCellID";
cell = [tableView dequeueReusableCellWithIdentifier:kDisplayCell_ID];

to
static NSString *kDisplayCell_ID = nil;

This would just always produce a new cell. I wouldn't recommend this in the general case, though.

A: This is due to cellReusability, and it has, for a long time, wasted so many developers' time  and effort. If you knew the concept of cell reusability, you would know that while scrolling, the index of the row and sections remain the same (although you expect it to be different for a different position on the uiTableView).
The only way is to subClass the UITableViewCell and create your own CustomUITableViewCell, and implement that with the disclosure indicator, or resist your input to just a small TableView that fits the screen and make scrollable = NO.


text:
Q: Is there a ONVIF Device Manager alternative for Ubuntu 16.04LTS Is there a ONVIF Device Manager like xeoma alternative for Ubuntu 16.04LTS?
sudo apt install xeoma from here does not work anymore.
Update
27/March/2017: Referring to the first answer about Zoneminder. It is up to date now. You can find them on github and docs here. I successfully paired 2 cameras with it running on Ubuntu Server 16.04.
Update: Available Full-featured CCTV Software for Ubuntu

*

*Xeoma and docs Tested paid version, ok for watching live feeds, archive playback buggy on Ubuntu 18.04LTS Server.

*Shinobi and docs

*Zoneminder and docs

*Feature list for some here

A: xeoma has a tar.gz installer. 32-bit and 64-bit. It only has 1 file and worked straight out of the box for me.
Mind though: it is payware (and monthly even, if I read the license correctly).
Open source and free: zoneminder They have a warning: don't use our repos since they are out of date and to use their PPA. Pity it has not been updated to 16.04 so is out of date as well ( :P ).

A: You can try Lingodigits' ONVIF Device Tool, has Ubuntu 16.04 64bit version
ONVIF Device Tool passed ONVIF Client Test Tool v16.01 and free to download.
http://www.lingodigit.com/onvif_nvc.html

A: You can try Shinobi:

*

*https://gitlab.com/Shinobi-Systems/ShinobiCE (Community Edition)

*http://shinobi.video/pro/ (Professional)


text:
Q: Why do I get "Avoid mutating a prop directly" when using NumericTextField? I have created a simple view component in VueJS and I'm getting a pretty common error:

void mutating a prop directly since the value will be overwritten
  whenever the parent component re-renders. Instead, use a data or
  computed property based on the prop's value. Prop being mutated:
  "value"

Here is my code:
<template>
    <numeric-text-field class="mx-auto" label="Head Mass" units="kg" v-model="turbine.head_mass" />
</template>

Oddly enough I get the error for modifying "value" but I don't have value in my code. I think this is caused by the indirection layer created by the numeric-text-field. This problem does not exist in my code when I use only normal input text. What is going on here? Is there another special way I'm supposed to hook up the model to my numeric-text-fields other than v-model?

A: This turns out to be, unbeknownst to me upon original posting, and issue in NumericTextField. I thought that was a standard Vueify component but was added by a coworker. It did not properly handle bidirectional input as pointed out by the comments on the original post.
The trick is to add this.$emit('input', value) from the NumericTextField component in @input like Ohgodwhy suggested.

A: It's important to understand how props work in Vue. The key aspect here is that props are utilized for one-way data flow. If you want it to be two-way data flow, you need to instead use v-model.
Having said that, there are a few different ways that you could go about doing this. I prefer to utilize computed properties for stuff like this! It's pretty clean, and easy to follow in the code.
Instead of modifying the prop directly, in your numeric-text-field component, you should instead emit an event when the
value is changed. This is how your Turbines.vue would look:
<template>
    <numeric-text-field class="mx-auto"
    label="Head Mass"
    units="kg"
    :headMass="turbine.head_mass"
    v-on:updateHeadMass="updateHeadMass"/>
</template>

You'll notice the v-on:updateHeadMass attribute. This is how we listen for emitted events from our child components. When the updateHeadMass even is emitted, we can call a specific function and update our data in the parent component accordingly. This will cause a reactive change in the child component, which is then updated.
Inside NumericTextField
Instead of modifying the prop directly, use a computed property, which emits an event, up to the parent component when the input is changed
This is how your NumericTextField component could look:
<template>

    Head Mass
    <input type="text" v-model="localHeadMass"  name="headMass"/>

</template>

If you don't care for the above approach, you could instead use a watcher like this:
<template>

    Head Mass
    <input type="text" v-model="localHeadMass" v-on:change="updateHeadMass" name="headMass"/>

</template>


text:
Q: Bower error tunneling socket could not be established, cause=Parse Error I'm behind a corporate proxy, I've set my HTTP_PROXY and HTTPS_PROXY env var to
http://username:password@proxyname:port/

doing console.log(process.env) output these var correctly. npm is working, I got bower with it and it(bower) was working fine but since I restarted windows XP I'm always getting :
bower error tunneling socket could not be established, cause=Parse Error

I don't think there's anything new on the proxy side. I've already tried reseting those vars, restarting everything... Any sugestion ?

A: If changing the proxy settings as pointed out by Vipul is not sufficient also change the registry:
npm config set registry http://registry.npmjs.org/

A: I really don't know why but clearing an .npmrc file in my home fixed it.

A: Following command work for me
npm config set proxy "http://domain\username:password@servername:port/"

A: I was getting the same issue with corporate proxy ON.
The solution is you just need to set system environment variables 'http_proxy' & 'https_proxy' to http://username:password@proxyname:port/
No need to clear .npmrc file.
Its a clear proxy issue and not a node issue. :)


text:
Q: . . skipping table while import in 9i When iam trying to import exp dump into 9i database its giving
imp ****/****@**** FULL=Y IGNORE=Y FILE=exp_****_4.dmp LOG=imp_****_4.log
export client uses WE8ISO8859P1 character set (possible charset conversion)
. importing SYSTEM's objects into ***
. importing OUTLN's objects into OUTLN
. importing PERFSTAT's objects into PERFSTAT
IMP-00003: ORACLE error 1435 encountered
ORA-01435: user does not exist

IMP-00000: Import terminated unsuccessfully

And when i tried to look into dump with show=y option
imp ****/****@**** FULL=Y IGNORE=Y FILE=exp_****_4.dmp LOG=imp_****_4.log **SHOW=Y**

It has given me all the table and object list and scripts that dump is going to import but with . . skipping table
I not getting why this is happening..
There is no indication as to why these tables were skipped and there are many of them.
I was able to load data into same DB from other dumps.

A: SHOW=Y instructs IMP not to import anything (to skip the import and just show you on the screen what's in the import file).


text:
Q: Show php as plaintext in single directory I'm trying to disable php and show it as plain text in a single directory using lighttpd but I cannot get it to work. I have tried this but it doesn't disable php.
$HTTP["url"] =~ "^/u" {
    fastcgi.server = ()
}

I have also tried the below to no avail
$HTTP["url"] =~ "^/u" {
    mimetype.assign = (".php" => "text/plain")
}

I do know that the directory setting works because I can set things like below and it works fine.
$HTTP["url"] =~ "^/u" {
    server.dir-listing = "enable"
}

A: Somewhere else in your config (which you have not shared), you probably have assigned a handler to ".php".  At that location, you can make your exclusion instead of doing the assignment.

    $HTTP["url"] =~ "^/u" {
        server.dir-listing = "enable"
    } else {
        fastcgi.server = ( ".php" => (( ... )))
    }

(recent versions of lighttpd support the 'else' without requiring a condition)
You might also look to see if perhaps you are assigning the handler in a condition that is evaluated by lighttpd after the condition you posted, which attempts to disable fastcgi.


text:
Q: sql multiplication don't show properly total
There is strange multiplication in the script.
SUM(CAST(PurchLine.[Amount Including VAT]   AS decimal(10,2)))
OVER(PARTITION BY PurchLine.[Document No_])AS "TotalAmount"

Finding the Total Amount from above.
TotalAmount * TotalAmount * Discount AS PaymentAmount

Finding the discount and final Payment Amount from the above.

For example I have 24.80 * (24.80*0.015) = 24.42
Instead of that I receive 24.30.
Also for the discount 24.80*0.015 = 49.60 This is not correct again. The correct result would be 0.372
But the strange part this is not working only when TotalAmount is lower than 3 digits.  When the Total amount is below 100, always the discount is not correct.
I'm not sure what do I have to make so it would work all the time.

A: The problem was that the this table with column Discount was imported into the sql server from excel file. For some reason the column Discount was not Decimal.
All the column contain numbers like 0.0015, 0.010 and so on...
When I change the column datatype to decimal(10.4) for Discount everything start working fine.
But here is still the question, why this work for number bigger than 100 and for less than 100 don't work?


text:
Q: Spring Framework NullPointerException in controller JAVA I have this NullPointer. When i debuged the code i saw that u is null and model is { }. I guess that the modell is { } because of the exception but i do not know why i have null on user ?
controller
@Controller
@RequestMapping(value = "/home")
public class HomeController {

    @Autowired
    private DomainManager domainManager;

    @RequestMapping(method = RequestMethod.GET)
    public String showPage(HttpSession session, Model model) {
        User u = (User) session.getAttribute(User.SESSION_PROPERTY);

        Domain domain = domainManager.getDomain(u.getDomainId());
        Quota used = domainManager.getQuotaUsage(u.getDomainId());
        boolean active = domainManager.isDomainActive(u.getDomainId());

        model.addAttribute("domain", domain);
        model.addAttribute("active", active);
        model.addAttribute("used", used);

        return "home";
    }

stack
java.lang.NullPointerException
        bg.abv.saas.admin.controller.HomeController.showPage(HomeController.java:27)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke(Method.java:497)
        org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
        org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
        org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
        org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
        org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
        org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
        org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)


text:
Q: mousewheel.js is not working on mobile devices I'm designing a site which uses mousewheel.js. It renders awesomely when I load it in the desktop browsers. But when I load that page in mobile devices it is not working. Does anybody know why or an alternate solution for this.
Thanks in advance!


text:
Q: Ubuntu with x86_64 binaries installation on Apple-Silicon I teach a "Computer Architecture and Assembly Language" course. The assembly I teach in the course is Intel x86_64 but apparently many students have Mac M1/M2 (Apple-Silicon) laptops.
My question is: is there any way to install Ubuntu OS with x86-64 bit binaries on Apple-Silicon using VirtualBox?
VirtualBox 7 has a (beta) version for Apple-Silicon but when students try to run a pre-made Ubuntu VirtualBox image with binaries for x86-64 it crashes.
I read about Rosetta 2 which should running x86-64 binaries on Apple-Silicon. I assume it doesn't take effect because although the Ubuntu binaries are x86-64, the VirtualBox process (under which they Ubuntu is launched) is arm64 binaries. Should it be possible to run VirtualBox 7 x86_64 binaries using Rosetta 2 and then launch Ubuntu x86-64 binaries?
(note: I also found QEMU which is both emulation and virtualization software, but I couldn't figure out how to set it up with Ubuntu even on my PC desktop)

A: Rosetta only works on userland binaries, you cannot use it to emulate entire x86_64 VMs.
Moreover, Rosetta on macOS only works for Mach-O binaries. The kernel needs to have explicit support for loading x86_64 binaries, handling x86_64 thread states, etc.
What you can do:

*

*Build and run your x86_64 assembly on macOS. Then you can use Rosetta. This is likely going to take a bit of work (leading underscores in symbol names, slightly different function ABI, different syscall numbers), but back when I was a student, I was perfectly able to run all Linux code we got on macOS instead.

*Use Rosetta for Linux. The big caveat of this is that it's only supported inside Virtualization.framework, which VM hypervisors generally can't use because the options it exposes are far too crude and limiting for their needs. (And they can't reimplement the Rosetta bits either, because it requires kernel support that Apple keeps exclusive to Apple-signed processes, it's a long story.) There are some third-party projects that use it, but I have not tested them and have no idea how stable or feature-complete they are.

*Use QEMU inside an arm64 Linux VM, for individual binaries. That should be far simpler than trying to emulate a whole VM.


text:
Q: How to read a Chinese text file from C#? How can I read a Chinese text file using C#, my current code can't display the correct characters:
try
{
    using (StreamReader sr = new StreamReader(path,System.Text.Encoding.UTF8))
    {
        // This is an arbitrary size for this example.
        string c = null;

        while (sr.Peek() >= 0)
        {
            c = null;
            c = sr.ReadLine();
            Console.WriteLine(c);
        }
    }
}
catch (Exception e)
{
    Console.WriteLine("The process failed: {0}", e.ToString());
}

A: You need to use the right encoding for the file. Do you know what that encoding is? It might be UTF-16, aka Encoding.Unicode, or possibly something like Big5. Really you should try to find out for sure instead of guessing though.
As leppie's answer mentioned, the problem might also be the capabilities of the console. To find out for sure, dump the string's Unicode character values out as numbers. See my article on debugging unicode issues for more information and a useful method for dumping the contents of a string.
I would also avoid using the code you're currently using for reading a file line by line. Instead, use something like:
using (StreamReader sr = new StreamReader(path, appropriateEncoding))
{
    string line;
    while ( (line = sr.ReadLine()) != null)
    {
        // ...
    }
}

Calling Peek() requires that the stream is capable of seeking, which may be true for files but not all streams. Also look into File.ReadAllText and File.ReadAllLines if that's what you want to do - they're very handy utility methods.

A: If it is simplified chinese usually it is gb2312 and for the traditionnal chinese it is usually the Big5 :
// gb2312 (codepage 936) :
System.Text.Encoding.GetEncoding(936)

// Big5 (codepage 950) :
System.Text.Encoding.GetEncoding(950)

A: Use Encoding.Unicode instead.
I think you need to change the OutputEncoding of the Console to display it correctly.

A: I just encountered the same problem as yours and I solve it now. I think the main problem would be from txt editor. When you save text in .txt format using notepad, you can choose the encoding at the bottom. The default encoding is ANSI which does not support Chinese stream reading (depends on your computer) while Unicode works for Chinese text. I hope this will help you :)
Cheers,
Ronald


text:
Q: input during for-loop in comprension data=[]
for i in range(int(input())):
    name=input()
    point=float(input())
    data.append([name,point])

how i can convert this code to comprehension or is there any other way to reduce runtime.
for comprehension i tried this code below:
data=[[input() float(input())] for i in range(int(input()))]

i dont know is there  any special ways to do list opearations and inputs during for-loop in comprensions.
As i know for statements, they should be mentioned after loop but operations for list before loop. But for my version it gives syntax error.

A:
how i can convert this code to comprehension or is there any other way to reduce runtime.

Do the items of your outer list need to be more lists? Why not make a list of tuples? Anyways your code gave you a syntax error because you forgot to include a comma.
data = [(input(), float(input())) for i in range(int(input()))]

I'm also not sure why you are trying to find speed improvements on code that takes user input. No human is every going to provide input fast enough to notice any performance increase from one solution to another. Do you have another program providing input automatically through stdin or something?


text:
Q: using setTimeout to repeat a function with a slider to control the speed hi there I am having problems getting my function (which is a circle) to repeat. The code is for a house with smoke coming out from the top. the smoke is supposed to be a set of several circles, which will blow out of the chimney. These circles are controlled by the setTimeout method, which is connected to a slider in the html script which controls the speed at which the smoke is blowing out of the chimney.
my problem is that i can get the circle to animate once but it does not return back to it's original position and continue the loop. What am I doing wrong? any help would be appreaciated. here is the code:
javascript:
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.lineWidth = 4;
ctx.strokeLinecap = 'round';
var a = 1;
var speed = 100;
var posY = 100;
var posX = 200;

function foundation() {

    //grass
    ctx.fillStyle = "green";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(25, 375);
    ctx.lineTo(125, 325);
    ctx.lineTo(471, 325);
    ctx.lineTo(400, 375);
    ctx.lineTo(25, 375);
    ctx.fill();
    ctx.stroke();

    //front face ground
    ctx.fillStyle = "#873600";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(25, 375); //top left
    ctx.lineTo(25, 425); //bottom left
    ctx.lineTo(400, 425); //bottom right
    ctx.lineTo(400, 375); //top right
    ctx.lineTo(25, 375); //top line
    ctx.fill();
    ctx.stroke();

    //east face ground
    ctx.fillStyle = "#872000";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(475, 325); //top right
    ctx.lineTo(475, 375); //bottom right
    ctx.lineTo(400, 425); //bottom line
    ctx.lineTo(400, 375); //top left
    ctx.lineTo(475, 325); //top right
    ctx.fill();
    ctx.stroke();

}

function house() {

    //front face
    ctx.fillStyle = "#2980B9";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(110, 365);
    ctx.lineTo(110, 200);
    ctx.lineTo(375, 200);
    ctx.lineTo(375, 365);
    ctx.lineTo(110, 365);
    ctx.fill();
    ctx.stroke();

    //east face
    ctx.fillStyle = "#1760B4";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(375, 200); //lower left
    ctx.lineTo(415, 180); //
    ctx.lineTo(415, 340);
    ctx.lineTo(375, 365);
    ctx.lineTo(375, 200);
    ctx.fill();
    ctx.stroke();

    //roof front face
    ctx.fillStyle = "#B41717";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(95, 210);
    ctx.lineTo(160, 140);
    ctx.lineTo(395, 140);
    ctx.lineTo(365, 210);
    ctx.lineTo(365, 210);
    ctx.lineTo(95, 210);
    ctx.fill();
    ctx.stroke();

    //roof east face
    ctx.fillStyle = "darkred";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(365, 210);
    ctx.lineTo(425, 190);
    ctx.lineTo(395, 140);
    ctx.lineTo(365, 210);
    ctx.fill();
    ctx.stroke();

    //door
    ctx.fillStyle = "darkred";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(300, 365);
    ctx.lineTo(300, 295);
    ctx.lineTo(250, 295);
    ctx.lineTo(250, 365);
    ctx.lineTo(300, 365);
    ctx.fill();
    ctx.stroke();

    //doorknob
    ctx.fillStyle = "yellow";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.arc(290, 335, 5, 0, 2 * Math.PI, false);
    ctx.fill();
    ctx.stroke();

    //walkway
    ctx.fillStyle = "gray";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(250, 365); //left point
    ctx.lineTo(240, 375); //left side
    ctx.lineTo(290, 375);
    ctx.lineTo(300, 365);
    ctx.fill();
    ctx.stroke();

    //window living room
    ctx.fillStyle = "blue";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(143, 347);
    ctx.lineTo(143, 295);
    ctx.lineTo(212, 295);
    ctx.lineTo(212, 347);
    ctx.lineTo(143, 347);
    ctx.fill();
    ctx.stroke();

    //window top left
    ctx.fillStyle = "blue";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(143, 275);
    ctx.lineTo(143, 225);
    ctx.lineTo(212, 225);
    ctx.lineTo(212, 275);
    ctx.lineTo(143, 275);
    ctx.fill();
    ctx.stroke();

    //window top right
    ctx.fillStyle = "blue";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(263, 275);
    ctx.lineTo(263, 225);
    ctx.lineTo(332, 225);
    ctx.lineTo(332, 275);
    ctx.lineTo(263, 275);
    ctx.fill();
    ctx.stroke();

    //chimney front
    ctx.fillStyle = "#B41717";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(170, 130); //top left
    ctx.lineTo(170, 180); //left side line
    ctx.lineTo(200, 180); //bottom line
    ctx.lineTo(200, 130); //right side line
    ctx.lineTo(170, 130); //top side line
    ctx.fill();
    ctx.stroke();

    //chimney east
    ctx.fillStyle = "darkred";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(200, 130); //top left
    ctx.lineTo(215, 123); //top side line
    ctx.lineTo(215, 170); //right side line
    ctx.lineTo(200, 180); //
    ctx.fill();
    ctx.stroke();

    //chimney top
    ctx.fillStyle = "black";
    ctx.strokeStyle = "#000000";
    ctx.beginPath();
    ctx.moveTo(170, 130); //top left
    ctx.lineTo(185, 122); //left side
    ctx.lineTo(210, 122); //top side
    ctx.lineTo(200, 130);
    ctx.fill();
    ctx.stroke();

}

function smokeMed() {

    ctx.beginPath();
    ctx.arc(190, 90, 11, 0, Math.PI*2, true);
    ctx.closePath();
    ctx.lineWidth = 5;
    ctx.fillStyle = 'lightgrey';
    ctx.fill();
    ctx.strokeStyle = 'gray';
    ctx.stroke();
}

function smokeBig() {

    ctx.beginPath();
    ctx.arc(210, 70, 15, 0, Math.PI*2, true);
    ctx.closePath();
    ctx.lineWidth = 5;
    ctx.fillStyle = 'lightgrey';
    ctx.fill();
    ctx.strokeStyle = 'gray';
    ctx.stroke();
}

function animate2() {

    var speed = document.getElementById('speedCont').value;
    posY += -1;
    posX +- 1;

        ctx.fillStyle = "aqua";
        ctx.fillRect(0,0, 220, 120);

        ctx.fillStyle = "rgba(0,0,0,0.5)";
        ctx.beginPath();
        ctx.arc(posX, posY, 15, 0, Math.PI*2, true);
        ctx.fill();

    window.setTimeout(animate2, speed);
}

/**   if (a == 1) {
        ctx.clearRect(0, 0, 260, 105);
        smoke();
        a++;
    } else if (a == 2) {
        ctx.clearRect(0, 0, 260, 105);
        smokeMed();
        a++;
    } else if (a == 3) {
        ctx.clearRect(0, 0, 260, 105);
        smokeBig();
        a = 1;
    } else {
        ctx.clearRect(0, 0, 260, 105);
    }
    window.setTimeout(animate2, speed);
}
**/

window.onload = function all() {

    foundation();
    house();
    animate2();

}

window.addEventListener("load", all, false);
//window.setInterval(animate2, 1000);
//window.setTimeout(animate2, speed);

html:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8"/>
    <link rel="stylesheet" href="style.css"/>

</head>
<body>
    <canvas id="canvas" width="500" height="500">Get a new Browser!</canvas>

    <script src="script.js" ></script>

    <form>
    <input type="range" min="10" max="250" value="100" id="speedCont"/>

</form>

</body>
</html>

css:
#canvas {
    background-color: aqua;
    border: 1px solid black;
    margin-bottom: 10px ;
}
body {
    background-color: gray;
}

input[type=range] {
    -webkit-appearance: none;
    border: 3px solid black;
    width: 500px;
    border-radius: 20px;
}
input[type=range]::-webkit-slider-runnable-track {
    width: 500px;
    height: 10px;
    background: #ddd;
    border: none;
    border-radius: 20px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    border: 3px solid black;
    height: 30px;
    width: 30px;
    border-radius: 50%;
    background: red;
    margin-top: -8px;
}
input[type=range]:focus {
    outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
    background: #ccc;
}

A: If you add the following line to the animate2 function:
if (posY < -13) posY = 100;

then when the smoke has left the canvas at the top it will restart again from its original location.


text:
Q: i keep having [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) #0 MethodChannel._invokeMethod package:flutter/…/services/platform_channel.dart:175 #1 MethodChannel.invokeListMethod package:flutter/…/services/platform_channel.dart:363 #2 MethodChannelFirebase._initializeCore package:firebase_core_platform_interface/…/method_channel/method_channel_firebase.dart:31 #3 MethodChannelFirebase.initializeApp package:firebase_core_platform_interface/…/method_channel/method_channel_firebase.dart:73 #4 Firebase.initializeApp

A: delete the application on your emulator (or wherever you work)
execute

flutter clean

in your working directory and rebuild the app.
flutter sometimes does not recognize plugins automatically.

A: I had this error and deleting app on device/simulator and installing it again helped me


text:
Q: Sass library in Next JS My company use a Sass library that includes mixins and such. I have done an NPM install into my Next JS project.
My next.config.js file looks like this:
const path = require('path')

module.exports = {
  sassOptions: {
    includePaths: [path.join(__dirname, 'styles')],
  },
}

In _app.js I have import '../styles/main.scss'
What I don't understand is how do I get NextJS to include my library?
In other projects we would add an npm script "build:css": "npx fe-styleguide-build" but I want to benefit from Next JS hot reloading for seeing styling updates as soon as they are made.

A: Next.js supports sass natively, all you have to do is npm install sass into your project and change .css to .scss, no need to tweak config file for that. With npm dev your sass will be compiled in real-time.

A: You can import the styles directly from the node_modules. Import the file inside pages/_app.js, so that all other components can also access it:
// pages/_app.js
import 'your-library/dist/css/path-to-your-css.css'

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />
}

Read more about it in the docs.


text:
Q: (Updated) Geometric Illustration of Monotone and Maximal Monotone Maps I am writing a note about the Monotone and Maximal Monotone maps from the following book
http://link.springer.com/book/10.1007%2Fb97594
In this book we read a map $T:\mathbb{R}^n\rightrightarrows\mathbb{R}^n$ is called monotone, if it's graph is monotone, namely,
$$\langle u-v,x-y\rangle\ge0,\forall u\in T(x),\forall v\in T(y)$$
and is maximal if its graph is not properly contained in the graph of any other monotone operator
$$\langle u-v,x-y\rangle\ge0,\forall v\in T(y),y\in \text{dom}\;T\Rightarrow u\in T(x).$$

So at least for $n=1,2,3$, I want to have a geometric illustration, for example the function $f(x)=x,\mathbb{R}\to\mathbb{R}$ is monotone, since for every $x_1<x_2$ we have $f(x_1)<f(x_2)$, But now here our maps are set valued so I want to know for example for $n=1$ this definition of monotone maps means that for $x_1<x_2$, $\sup T(x_1)<\sup T(x_2)$($\sup T(x_1)>\sup T(x_2)$), if so then how? But for $n=2,3,...$ $x_1<x_2$ is not meaningful?! and similarly for Maximal Monotone I don't know even for functions such $f:\mathbb{R}\to\mathbb{R}$ what does this definition mean?

I searched to find some nice geometric graph of such maps and could not find anything!
Also I need some nice or new examples of such maps, So if you have some examples of these type of maps in your researches, any lecture or book, it would be appropriate to refer me to them.
Thanks in advanced!

A: For $n=1$ the structure of the graph of a maximal monotone operator is known.
First the domain and range of such an operator are (possibly degenerate) intervals. If the domain is just one value then the graph is a vertical line passing through that value (similarly for the range being degenerate).
If the domain is a non-degenerate interval ($(a,b)$ or $(a,b]$ or $[a,b)$ or $[a,b]$ or $(a,+\infty)$ or $[a,+\infty)$ or $(-\infty,b)$ or $(-\infty,b]$ or $\mathbb{R}$) an operator $T:D(T)\subset\mathbb{R}\rightrightarrows\mathbb{R}$ is maximal monotone iff $T$  is monotone; $T$ has closed convex (interval) values; the graph is increasing in the sense that, for every $t\in[a,b)\cap\mathbb{R}$, $\inf T((t,+\infty))=\sup T(t)$ and, for every $t\in(a,b]\cap\mathbb{R}$,  $\sup T((-\infty,t))=\inf T(t)$; and a condition at the boundary: $T(a)=T(a)+\mathbb{R}_{-}$ whenever $a\in D(T)$ and $T(b)=T(b)+\mathbb{R}_{+}$ whenever $b\in D(T)$. Here $(a,b)$  is the interior of $D(T)$ the domain of $T$.
For a general $n\ge2$, the following recent result of Lohne holds: an operator $T:D(T)\subset\mathbb{R^n}\rightrightarrows\mathbb{R^n}$ is maximal monotone iff $T$  is monotone; $T$ has convex values; $D(T)$ is nearly-convex in the sense that there is a convex set $C$ such that $C\subset D(T)\subset\overline{C}$; $T=T+N_{D(T)}$; and $T$ has a closed graph.
Here $N_{D(T)}$ denotes the normal cone to $D(T)$.
Some references from where I took these results:
MR2465513 (2010c:47121) Löhne, Andreas, A characterization of maximal monotone operators. Set-Valued Anal.  16  (2008),  no. 5-6, 693–700.
MR2899842 Voisei, M. D., Characterizations and continuity properties for maximal monotone operators with non-empty domain interior. J. Math. Anal. Appl.  391  (2012),  no. 1, 119–138.

A: You can find the source of maximal monotone mappings in the following and the references therein:

*

*Variational Analysis, Rockafellar, R. Tyrrell, Wets, Roger J.-B.
http://www.springer.com/gp/book/9783540627722

*Maximal Monotone Operators in Banach Spaces, Viorel Barbu
http://link.springer.com/chapter/10.1007%2F978-1-4419-5542-5_2

*Lectures on Maximal Monotone Operators, R. R. Phelps
http://arxiv.org/pdf/math/9302209.pdf

*Convex Functions, Monotone Operators and Differentiability, R. R. Phelps
http://link.springer.com/book/10.1007%2F978-3-540-46077-0


text:
Q: How to implement a notification queue for push notificatoins in backend? Let's say I have users who create events of different time periods(max: 7days), and I have to send notifications to users when their event has ended. In between the time of each event, a user can cancel that event.
To accomplish this I had the following implementation in mind:

*

*Mimic a priority queue using a database:
Put the events in a database indexed and sorted by end time of events and erase events on deletion by the user or when it becomes the topmost event and current time is greater than its end time.

This would mean I would have to poll the database every time to check for completed events. Considering that, I am not sure whether this is the right way to do this.
So my question is are there any better methods or better, existing technologies that help to accomplish this sort of behavior?
PS: Currently my backend is in django, so technologies easily integratable with django would be preferred.


text:
Q: Angular 5 - what's the benefit in having component variables as type Observable? I am new to Angular 6 and have been reading about the http process in the below link:
https://angular.io/tutorial/toh-pt6#create-herosearchcomponent
I notice that in the component the type of the heroes array is Observable.
I'm not sure if this always needs to be the case inside components or not.
In my own code, I was able to data bind a non-observable:
export class UserInfoComponent implements OnInit {

    data: object;

    constructor(private userInfoService: UserInfoService) {}

    ngOnInit() {

        this.userInfoService
            .getEmployeeInfo()
            .subscribe((response) => {
              this.data = response;
            });
    }
}

I am not sure what the best practice is or what the pros and cons of each method are.

A: You can have your variable as Observable in this case - you have some chaining of RxJS operators and in your code you want to subscribe to the chaining flow many times. So for don't combining these operator every time, you can hold them in the property and add just one .susbcribe to it.
this.heroes$ = this.searchTerms.pipe(
  // wait 300ms after each keystroke before considering the term
  debounceTime(300),

  // ignore new term if same as previous term
  distinctUntilChanged(),

  // switch to new search observable each time the term changes
  switchMap((term: string) => this.heroService.searchHeroes(term)),
);

inOneMethod() {
   this.heroes$.subscribe(data => this.first = data);
}

inAnotherMethod() {
   this.heroes.subscribe(data => this.second = data);
}

A: Observable as a class variable is not compulsory.
Observable is based on the concept of using streams, wherein subscribers subscribe to whatever is emitted by this stream.
Whereas, in this case the HTTP response here by default is an observable to which you subscribe and further use whatever is emitted by this response stream.


text:
Q: Equivalence of categories: example I would like to prove that the  the category whose object class is the set of $K^n$ where $K$ is a field and the morphisms are the K-linear transformations is equivalent to the category of finite dimensional vector spaces whose morphisms are K-linear transformations.
Any hint to define a fully faithful and essentially surjective functor?
Thanks!

A: Let $\mathcal{C}$ be the first category, $\textbf{Vect}_k$ the second one. Then the functor you are looking for is the obvious one
$$F:\mathcal{C}\longrightarrow\textbf{Vect}_k$$
given by seeing $\mathcal{C}$ as a subcategory.


text:
Q: Background for radio button for Django form I found some peaces of code solving the issue, but all of those are using input tag and label tag which placed near each other. Django forms placed input inside label, that's why the code is ineffective in my case.
One of variant I tried here
Any advices or thoughts.
Thanks all!
input[type=radio] {
display:none;
}

input[type=radio] + label
{
background: #999;
height: 16px;
width: 16px;
display:inline-block;
padding: 0 0 0 0px;
}
input[type=radio]:checked + label
{
background: #0080FF;
height: 16px;
width: 16px;
display:inline-block;
padding: 0 0 0 0px;
}

A: Solved the issue customized form template and applied the  solution on css above.
{% for field in form %}
    {% for item in field %}
        <input id="id_name_{{ forloop.counter0 }}" name="name" type="radio" value="{{ item.choice_value }}">
        {{ item.choice_label }}
    {% endfor %}
{% endfor %}

A: I haven't check if my solution is right yet.
but you can write like this:
{% for field in form %}
    {% for radio in field %}
    {{ radio tag }}

    {% endfor %}
{% endfor %}

For more information,
 you can read the official doc.


text:
Q: Custom upload folder I have custom post type and I would like that when admin/user uploads images (for example featured image) to this custom post type, the image would be uploaded to custom folder. As default they go wp-content/uploads/ but I would want them to go wp-content/uploads-post-type-name or wp-content/mu-plugins/my-plugin/uploads/
Got it done

A: Use something like this function, you need to set condition for if(user==admin) and then if(post-type=='some-post-type'):
function wpse_16722_type_upload_dir( $args ) {

    // Get the current post_id
    $id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : '' );

    if( $id ) {
       // Set the new path depends on current post_type
       $newdir = '/' . get_post_type( $id );

       $args['path']    = str_replace( $args['subdir'], '', $args['path'] );         //remove default subdir
       $args['url']     = str_replace( $args['subdir'], '', $args['url'] );
       $args['subdir']  = $newdir;
       $args['path']   .= $newdir;
       $args['url']    .= $newdir;
    }
    return $args;
}
add_filter( 'upload_dir', 'wpse_16722_type_upload_dir' );


text:
Q: php - isset button i try to solve a problem but didnt succeed. I retrieve datas from google analytics and i have to send start and end date. I have two textbox and user select start and end date.However, but before user select start and end date. The problem occurs..
The place that i use isset is here,
This is my full html
<?php
define('ga_email','mertmetinbjk@gmail.com');
define('ga_password','************');
define('ga_profile_id','*******');

require 'gapi.class.php';
require 'connectDB.php';

$ga = new gapi(ga_email,ga_password);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>İçerik</title>

    <form action="#" method="post" name="formDates" id="form1" >

        <table width =""

    Başlangıç Tarihi

      <input type="text" name="txtStartDate" id="txt1" value="" />

    Bitiş Tarihi

      <input type="text" name="txtEndDate" id="txt2" />

    </form>

             <input type="submit" name="btnSubmit" value="Gönder"

    Kanal Adı
    Kategori Adı

Event Adı
    Toplam

            <?php

            if(isset($_POST['submit'])){
                $startDate = $_POST['txtStartDate'];
                $endDate = $_POST['txtEndDate'];
             }

             $arrDates = explode("-",$startDate);
             $startDate=$arrDates[2]."-".$arrDates[1]."-".$arrDates[0];
             $arrDates = explode("-",$endDate);
             $endDate = $arrDates[2]."-".$arrDates[1]."-".$arrDates[0];

             echo $startDate;
             echo $endDate;

            $ga->requestReportData(ga_profile_id,array('eventCategory','eventAction'),array('totalEvents'),$sort_metric=null,$filter='eventAction==InitPlayer',$start_date='2012-02-02',$end_date='2012-02-16');
            foreach($ga->getResults() as $result2);
            {
                echo $result2->geteventCategory();
                echo $result2->geteventAction();
                echo $result2->gettotalEvents();
            }

            $ga->requestAccountData();
            $mysql = new mysql();
            $mysql->connect();
            $counter = 0;

            foreach($ga->getResults() as $result)
            {
                 echo $result . ' (' . $result->getProfileId() . ")
";
                 echo "
";
                 $counter++;
            }

            $result = mysql_query("select profile_id from profiles");
            $num_rows = mysql_num_rows($result);

            if($counter != $num_rows)
            {
                $mysql->query("delete from profiles");

                foreach($ga->getResults() as $result)
                {
                   $mysql->query("insert into profiles values(".$result->getProfileId().",'".$result."')");
                }
            }

            ?>

what is wrong?
if a choose start and end date problems is solved , problems occurs before that i choose

A: It must be isset($_POST["btnSubmit"]) NOT submit
submit = type
btnSubmit = name of the button

A: Undefined index txtStartDate, ...

It seems that your form may not be conforming to the same variable name specification with the one that you use in this php file. Make sure field names are matching within the form and here.
And also you should make these checks in your php file after submission success: if(!isset($_POST['submit']))

A: I think it should be:
if(isset($_POST['submit']))

instead of:
if(!isset($_POST['submit']))

The exclamation mark in front of isset means not. Also I would check for the actual fields you want to use, not for $_POST['submit']:
if(isset($_POST['txtStartDate']) && isset($_POST['txtEndDate']))
{
    // Do something with $_POST['txtStartDate'] and $_POST['txtEndDate']
}

The reason you were getting the error is that $_POST['submit'] does not exist. There is not input element with a name attribute called submit. Beware of the difference between type and name.

A: When your page is loading and $_POST['submit'] is not set, your $_POST['txtStartDate'] and $_POST['txtEndDate'] are not set so $arrDates is not set too. You need to check if these $_POST vars are set or not, to work with them.

A: You have to use isset() on every variable, not just one variable. $_POST['txtStartDate'] and $_POST['txtEndDate'] and other variables are simply not defined, this means that they were not sent with the POST request.

A: if(!isset($_POST['submit']))

This means that if the submit button was NOT pressed. You should check if the $_POST['submit'] is set, as a result of the form submission, like so:
if(isset($_POST['submit']))

A: I guess it should be if(isset($_POST['submit'])) instead of if(!isset($_POST['submit'])) as ! in the start means a negation


text:
Q: What are some metrics to compare which line is more "curved"? Let's say we have two lines.  I want to compare which line is more "curved" over the same interval.  For example, let's say:
$f1(x) = x^2$
$f2(x) = sin(3x)$
Over the interval x = [0, 1], it is arguable, that f2(x) is more "curved".  What are some metrics to measure which two lines are more curved?  Curved can be a function of range(f(x)), how much f(x) changes direction, etc...
Are there any good ones out there?


text:
Q: How much space does iPod Touch video take? I'm thinking about getting a mounting bracket so I can record more video with my iPod Touch (4gen), but I wonder if I'll have enough space on it to hold very much.
How much space does recorded video take up on an iPod Touch, in gigabytes per hour (or whatever the appropriate units would be)?

A: The recording is HD (720p) up to 30 frames per second with audio - but since both the audio and video are compressed using lossy algorithms, you might sometimes get significantly storage depending on the source.
In practice the iPhone 4 uses 4.8 GB / hour with the same HD (720p) up to 30 frames per second - but the few recording I've seen from the iPod touch have data rates about half as high (which use about half the space). My iPhone usually records between 2 and 10 Mbit/s. The lower end is for static, mostly black images and if things are moving or detailed, you get to the higher end of the range pretty easily.
You can make some test recordings and open them in QuickTime Player where the inspector window will show you the details for the video you are shooting. A little pen and paper or a spreadsheet will convince you of how much time you can expect to capture before your device runs out of space.


text:
Q: Determine degree rotation in 3D space This is a programming issue. I need to understand the math before I program it though.
This is an issue that has vexed me before and I was not happy many years ago with the result. When I solved it many years ago it was in 2D and I had tight control of starting and ending locations. I used a whole bunch of if, then, else statements to determine what quadrant the final point location was in. I hated the solution.
The problem is pretty simple:

*

*I have points in 3D space.

*The points can be orientated in any
orientation.

*In essence the three points are all on a single plane
and the plane is oriented in 3D space.

*I need to judge between multiple rotated points to determine which point is rotated less than the others so I need some sense of rotation direction and distance.

I need to determine the angle of rotation in degrees or radians. Rotation can be any value between 0 - 360 degrees.
The start place can be anywhere on the 360 degree circle:

The end can be anywhere on the 360 degree circle:

The direction of rotation can be either "direction" on the circle and the plane the two lines are on can be oriented in any location in 3D space:

My programming tools can give the angle between two lines (A-B) and (A-C) of between 0-180 degrees. It has no sense of direction. If I get two points that are rotated 170 degrees one is rotated 170 degrees and one 190 degrees. I can't tell the difference between the two programatically except (in my limited way of thinking) calculating where a 170 degree rotation and a 190 degree rotation is and compare those results to the trial points to determine rotation over 180 degrees.
When I look at this in the human sense my brain can't help but orient itself perpendicular to the plane and judge rotation in clockwise or counterclockwise. This construct seems to be getting in my way in this case.
Is there a mathematical solution that I am missing here?

A: First you have to define the vectors $AB$ and $AC$ by subtracting head - tail.  i.e. $\vec{AB} = B - A$ and $\vec{AC} = C - A$.  This should give you an array of three numbers.  i.e. $\vec{AB}= [x_{AB}, y_{AB}, z_{AB}]$ for each vector.
You will need the length (i.e. norm) of each vector.
We denote this as $\|\vec{AB}\|$ and $\|\vec{AC}\|$.  I assume you know how to do this.
You will need the dot product of the of the vectors which is just the component-wise multiplication of the x, y  and z elements together and then summed.
$$\vec{AB}\cdot \vec{AC} = x_{AB}x_{AC} + y_{AB}y_{AC} + z_{AB}z_{AC}$$
You can look that up.
Then the angle that you are looking for is:
$$ \theta = \cos^{-1}\left( \frac{\vec{AB}\cdot \vec{AC}}{\|\vec{AB}\| \|\vec{AC}\|} \right)$$


text:
Q: join two model from one model in cakephp i want to fetch record form 2 model (Booking and Message), both model don't have any relation.
i try a lot but its not working
i used that code ( http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#joining-tables )
    $options['joins'] = array(
    array('table' => 'books_tags',
        'alias' => 'BooksTag',
        'type' => 'inner',
        'conditions' => array(
            'Book.id = BooksTag.book_id'
        )
    ),
    array('table' => 'tags',
        'alias' => 'Tag',
        'type' => 'inner',
        'conditions' => array(
            'BooksTag.tag_id = Tag.id'
        )
    )
);

    $options['conditions'] = array(
        'Tag.tag' => 'Novel'
    );

    $books = $Book->find('all', $options);

A: Try this:
BookModel:
public $hasMany = array(
    'BooksTag' => array(
        'foreignKey' => 'book_id'
    )
);

TagModel:
public $hasMany = array(
    'BooksTag' => array(
        'foreignKey' => 'tag_id'
    )
);

BooksController:
$this->Book->Behaviors->load('Containable');
$this->Book->find('all', array(
    'contain' => array(
        'BooksTag' => array(
            'Tag',
        ),
    ),
));

A: I prefer to do this on many queries. First find the required tag:
    $this->loadModel('Tag');
    $tag = $this->Tag->find('first', array('conditions' =>  array('Tag.tag' => 'Novel')));
    $tag_id = $tag['Tag']['id'];

Then find book_ids:
    $this->loadModel('BookTag');
    $book_ids = $this->BookTag->find('list', array('conditions' => 'BookTag.tag_id' => $tag_id, 'fields' => 'book_id, book_id'));

Then find books:
    $this->Book->find('all', array('conditions' => array('Book.id' => $book_ids)));

It is a long code but runs fast and is easy to understand. Another way is to use sub-queries but they are ugly and may slow down your application


text:
Q: restrict root access for certain files or filesystems I want to store files for my users on encrypted filesystems. Every user would have his own filesystem with his own key. The user is able to log in to the system and mount his filesystem. When they are mounted, even the root is not able to access them.
The setup is:

*

*LVM -> dm_crypt -> xfs.

*when the user logs in, he mounts his filesystem in a way that the owner will be him

*he can start programs, they will have the same right as the user, so they can read the files

However I want root not to access any of my users mounted filesystem. First I thought of writing a VFS kernel module (compiled with the kernel) and hijack the filesystm specific commands if the root wants to access the file of a different user. The problem is a root can do something like:
# su -secureuser
and voila read the mounted filesystem.
I was told to look aroud posix file capabilities , PAM , SELinux , but I don't know these, and I'm sure, achieving my request is not convenient at all even with these things.
Here are some more, but they are about to restrict whole root access:
http://www.centos.org/docs/4/4.5/Security_Guide/s2-wstation-privileges-noroot.html
Do you have any ideas? Thanks for the answers! :)

A: You should be able to accomplish this using SELinux MLS (Multi-Level Security) policy as a base, and adapting it to your needs. This is not a simple task, and if you don't already know SELinux you will have to learn, or find someone who does.
This is also not a policy for a one-man operation, as it splits the security roles normally handed by root three (or more) ways and you therefore ideally should have three (or more) people who administer various aspects of the system.

A: First you have to realize that even if you limit root account the admins could have access to physical server and change the server configuration from a Live CD.
So you should start by trusting your admins.
I can see a few solutions. None is simple, but they are doable.
Here they are:

*

*use different bind namespaces. Use PAM to configure them. You might need to develop a PAM module.

*SELinux (as mentioned by Michael Hampton), AppArmor or some other kernel space "application firewall".

*Linux Containers, one for each user. I think this is the easiest solution.

*Virtual Machines (XEN, KVM), one for each user.

*a LD_PRELOAD library that will check the access for FS operations (open, getdents).

*develop a kernel module that will do the filtering (similar to SELinux...)

Please note that you will have to limit the root access separately, depending on the chosen solution. You need to limit also the access to the raw device.

A: In Unix/Linux, there is NO way you can restrict root from accessing a file mounted by user. It just doesn't work.


text:
Q: How to correct syntax error in SQL server? I am trying to use part of the stored procedure below but when I run it on a table in SQL Server, I get an error:
CREATE PROCEDURE USP_Query_1
    @sourcetype varchar(50),
    @datasource varchar(50),
    @queries varchar(50),
    @username varchar(50) NULL,
    @password varchar(50) NULL

AS
BEGIN
    DECLARE @SQL VARCHAR(50)
    SET @SQL = CASE WHEN @datasource = 'SQL Server'
                        THEN 'SELECT * FROM OPENROWSET
                        (''SQLNCLI'', ''Server='+@datasource +';Trusted_Connection=yes;'',
                         '''+@queries +''')'
...
END
    PRINT (@SQL)
    EXEC (@SQL)
  END
GO

The error says:

'SELECT * FROM OPENROWSET
(''SQLNCLI'', ''Server='+@datasource +';Trusted_Connection=yes;', Incorrect syntax near ','.

I really do not see the error here, can someone tell me where it is and any suggestions to fix this?


text:
Q: how can k8s on mesos proxy on slave node? k8s use kube-proxy and iptables to achieve loadbalance on slave node .
But on mesos, I remembered I am just install a kubemaster on meoso master and do nothing in mesos-slave . And how it can   proxy  well   without nothing installed on slave node ?

A: The kubernetes-mesos framework assumes responsibility for spawning both the kubelet and kube-proxy processes on mesos slaves to support the pods (tasks) running there. Please refer to the architecture docs here: https://github.com/kubernetes/kubernetes/blob/master/contrib/mesos/docs/architecture.md


text:
Q: How can I get the size of the video that is taken from UIimagePicker? I am using below code but it is not showing accurate size,Suppose my file size is 50Mb,But it is showing around 90MB.
NSError *error;
NSURL * mediaURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSDictionary * properties = [[NSFileManager defaultManager] attributesOfItemAtPath:mediaURL.path error:&error];
NSNumber * size = [properties objectForKey: NSFileSize];

and also i tried below code
NSDictionary *attribs = [[NSFileManager defaultManager] attributesOfItemAtPath:moviePath error:&error];
if (attribs) {
    NSString *string = [NSByteCountFormatter stringFromByteCount:[attribs fileSize] countStyle:NSByteCountFormatterCountStyleFile];
    NSLog(@"%@", string);
}

It is also same result.I want exact file size.Can any body help me.
Thank you

A: NSError *attributesError;
NSURL *videoUrl=[info objectForKey:UIImagePickerControllerMediaURL];

    NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[videoUrl path] error:&attributesError];
    NSNumber *fileSizeNumber = [fileAttributes objectForKey:NSFileSize];
    long long fileSize = [fileSizeNumber longLongValue];
    NSLog(@"SIZE OF VIDEO: %0.2f Mb", (float)fileSize/1024/1024);

This code is completely work


text:
Q: How was this value of ObjectGUID encoded? An application stores the objectGUID of a user's MSAD entry internally as:
msad://OBJECTGUID=\5c\78\33\6d\77\d8\df\44\80\07\d2\77\da\d5\c5\69?USER

Below are the Uids I see when I pull the user's details using ldapsearch command:
...
objectGUID:: XHgzbXfY30SAB9J32tXFaQ==
ibm-entryUuid: {base64binary}XHgzbXfY30SAB9J32tXFaQ==
objectSid:: AQUAAAAAAAUVAAAAJnYeL8CFOF0H5TsrNU0lAA==
employeeNumber: 502075089
...

Does anyone have an idea how the application is encoding the MSAD's objectGUID into msad://OBJECTGUID=\5c\78\33\6d\77\d8\df\44\80\07\d2\77\da\d5\c5\69?USER?
I basically have to decode the applications encoding of objectGUID.. to identify the corresponding MSAD entries.

A: It is exactly the same data displayed in hexadecimal instead of Base64.

In the LDIF format, which ldapsearch outputs, two colons means the following value is base64-encoded (usually because it has binary data). For example, these are equivalent:
greeting: Hello

greeting:: SGVsbG8=

So if you run XHgzbXfY30SAB9J32tXFaQ== (the value of objectGUID) through a base64 decoder, you will get:
$ echo XHgzbXfY30SAB9J32tXFaQ== | base64 -d | xxd
0000000: 5c78 336d 77d8 df44 8007 d277 dad5 c569  \x3mw..D...w...i

In your msad:// URI, the same GUID is stored in hexadecimal, each byte prefixed with a \.


text:
Q: Do I need to wrap SQlite calls with extern "C" in my C++ application? DO I need to wrap SQLite(http://www.sqlite.org/) library calls in my C++ application as :
extern "C" {

    //Wrapping SQLite C header
    #include "sqlite3.h"

    // Some example function definitions
    int sqlite3_open(const char *filename,sqlite3 **ppDb);
    void sqlite3_free(void*);
    int sqlite3_close(sqlite3*);
}

Or can I access the library directly (as most examples show in the website)? Would also love to know the reason behind the right answer.

A: sqlite3.h already includes an extern "C" wrapper. From the source:
/*
** Make sure we can call this stuff from C++.
*/
#ifdef __cplusplus
extern "C" {
#endif

…

#ifdef __cplusplus
}  /* end of the 'extern "C"' block */
#endif

As such, you don't need to wrap it yourself.


text:
Q: How do i set the max. amount of existing prefabs and also despawn Prefabs floors in Unity after the player passes them? So here is the code, right now i only spawn each frame x Prefabs (Its a simple Game im new to unity so the player is a ball and dodges stuff etc. So i have an amount of prefabs (Floors) that is spawning in front of the palyer)

    public static int numSpawned = 0;
    //Creates an Array to store PreFabs into it
    public static GameObject[] thePath;
    //Sets the x value of the spawning postion to 100
    public int SpawningDistance = 100;

    public int numToSpawn = 6;

//Calls the PreFabs Folder
    private void Start()
    {
        thePath = Resources.LoadAll<GameObject>("PreFabs");
    }
    //Sets the Spawn Position and ++ the numSpawned
    void SpawnRandomObject()
    {
        int withItem = Random.Range(0,6);

        GameObject myObj = Instantiate(thePath[withItem]) as GameObject;

        numSpawned++;

        myObj.transform.position = transform.position + new Vector3(0, 0, 0);
    }

    //Til now it Spawns every Frame so thats what you have to fix
    void Update()
    {   //compares the Values
        if (numToSpawn > numSpawned)
        {
            //where your object spawns from
            transform.position = new Vector3(SpawningDistance, 0, 0);
            SpawnRandomObject();

            SpawningDistance = SpawningDistance + 100;
        }
    }

Til now its the problem that i dont know how to controlle the spawning amount and speed so i need help for that. All Prefabs are beeing stored in an array and then spawned randomly out of it.

A: Instead of using method SpawnRandomObject() every frame, you could create coroutine and yield WaitForSeconds(value).
[SerializeField] private float delaySpawnInSeconds = 0.5f;

...

private void Start()
{
    thePath = Resources.LoadAll<GameObject>("PreFabs");
    StartCoroutine(SpawnFloors());
}

Our coroutine:
private IEnumerator SpawnFloors()
{
    while (numToSpawn > numSpawned)
    {
       //SpawnRandomObject();  //if U want to spawn object then wait
       yield return new WaitForSeconds(delaySpawnInSeconds);
       SpawnRandomObject();  //if U want to wait then spawn object
    }
}

Doc: https://docs.unity3d.com/Manual/Coroutines.html
To get spawning amount, you could use Captain Skyhawk's idea to:

Keep an array of spawned objects and check the count.

Arrays:
Doc: https://docs.unity3d.com/2018.4/Documentation/ScriptReference/Array-length.html
You can also use lists, for example:
private List<GameObject> exampleList = new List<GameObject>();
private int sizeOfExampleList;

...\\Add items to the list in the code.\\...

private void exampleMethod ()
{
    sizeOfExampleList = exampleList.Count;
}

...

I hope I helped You! :-)


text:
Q: Use Twilio SIP to dial custom number I'm building an app and in this app I must receive an SDP packet to process it and integrate with the rest of the application. I'm thinking of using Twilio SIP to achieve this.
I want to be able to dial a custom remote phone number and access the SDP and the way I'm thinking is by using Twilio SIP.
In my Java app I could connect to my Twilio SIP endpoint (using any java SIP library) and I'll be able to inspect the SIP information (an thus the SDP). Using this I'm able to create a call between my app and Twilio SIP endpoint.
What I want is: how to programmatically connect to my SIP endpoint and pass a custom TwiML with the custom phone number to dial?
The problem is: When creating a new SIP endpoint it asks for a Voice Url but it is a static Url and thus a static TwiML response.
Edit: I could set the Voice Url to an endpoint in my java web app and update the response from this endpoint before placing a call but it doesn't sound correct
Use case flow: a user visits the web app and has a webrtc connection to a Kurento media server. This user inputs a phone number in a form and sends it. The web app dials this number (via any service or api) and receives an SDP that can be used in the Kurento media server, bridging the webrtc user and the phone user in the same call


text:
Q: skip iteration based on value - postman I am working on a postman collection where I have written two get requests for APIs. I am using a single data file in the runner for both the requests when I run. My data file looks like below -

What I am trying to do is when I run request1 it should use Algo_id and use in the query parameter and for request2 it should use product_ids. When I run these request from the test runner using data file it runs the requests for the blank values as well, four requests each. I want to skip the runs for blank values and only run it when there is a value in the column for the request.
I want to run both the request two times and skip for the blank ones.
what I have tried so far, but had no success -
request1 Pre-request script -

request2 Pre-request script -

A: I think what you're trying to do is something that isn't currently supported which is basically if a test condition fails in the pre-request script then abort the current request and go to the next. In your case if there is an empty value found for the url parameter then don't execute.
https://github.com/postmanlabs/postman-app-support/issues/7166


text:
Q: Get TaskID for Case Activities I was getting TaskID for Case Activities  (Screen ID - SP203010) using Acumatica Web API. Now after upgrading it to version 6.0, I am not getting that. I have also tried different properties available but seems nothing is getting me that TaskID.
I am storing these activities into my database pulling from Acumatica Partner Portal and to avoid duplicate activities being imported, I was comparing it with TaskID.
Below is the code snippet I am using to get TaskID

SP203010WS.Screen context = new SP203010WS.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "https://sso.acumatica.com/Soap/SP203010.asmx";

PartnerPortalCreds loginCreds = GetCreds();
string username = loginCreds.PARTPRTUSE;
string password = loginCreds.PARTPRTPAS;

SP203010WS.LoginResult result = context.Login(username, password);

SP203010WS.Content content = context.GetSchema();
context.Clear();
string[][] export = context.Export
(
 new SP203010WS.Command[]
{
 new SP203010WS.Value
 {
  Value = currentAcumaticaCaseNo,
  LinkedCommand = content.Case.CaseID
 },

 content.Activities.Type,
 content.Activities.Summary,
 new SP203010WS.Field { FieldName="Body", ObjectName="Activities"},
 content.Activities.StartDate,
 content.Activities.CreatedBy,
 new SP203010WS.Field { FieldName="TaskID", ObjectName="Activities"},
},
 null,
 0, true, true
);

Let me know whether it has been moved or deprecated in newer version. What shall I be using instead of TaskID or where can I find that TaskID.

A: In Acumatica 6.0 table EPActivity was splitted on CRActivity, SMEmail and PMTimeActivity. Original table was renamed to Obsolete_EPActivity.
Now NoteID is the key field on all tables. SMEmail and PMTimeActivity contains RefNoteID field - foreign key from CRActivity.
You may find value pair TaskID and NoteID in table - Obsolete_EPActivity

A: @Krunal, as Ken mentioned, after upgrade to 6.0 value pair TaskID and NoteID is only available in the Obsolete_EPActivity table. One should use Obsolete_EPActivity table to replace obsolete TaskID integer values with actual NoteID GUIDs.
There is no way to access Obsolete_EPActivity table through Web Services. After upgrade to 6.0, Acumatica inserts new Activities only in the CRActivity table.
To avoid duplicate activities, you have to store actual NoteID GUIDs in your database instead of obsolete TaskID integer values and compare GUIDs while importing records.
For previously imported activities you will also have to replace TaskID values with actual NoteID GUIDs. Searching for CRActivity record based on CaseID, Subject and CreatedDateTime field values stored in your DB, you should find appropriate record and use its NoteID to replace legacy TaskID value.


text:
Q: Deleting an element in a database based on the HTML-element that is clicked I am creating a "Notes" web app. For every Note in my database, I am creating a div-container showing the text content stored in my database.
I want each div-container to have a delete-button, which is supposed to delete that specific Note immediately from my database. How can I accomplish this?
The Database function for deleting my Note ready. My source code is currently something like this:
// my delete-function in my database class
public Boolean DeleteNote(Note n) {

    // ... deletes Note n from db

}

// my HTML element displaying each Note in the database
.@foreach(Note n in myNotes) {

        <button onclick="**???????**">Delete Note</button>

@n.Text

}

PS. I am using C# and .NET MVC if that is relevant.

A: Assuming your delete note method is at the controller level, you would probably want to write a function that makes an Ajax call into your method and removes the div from the page of your method returns true.
Iirc .NET MVC comes with jQuery. That has some really good documentation.


text:
Q: Swift: open URL in a specific browser tab? With JavaScript, you can open a URL in a specific browser tab.
How do you accomplish the same thing with Swift from an iOS app, i.e., open URL in Safari/Chrome in a specific tab.
The UIApplication open function doesn't list information about the options parameter, which seems like it might let you specify a named tab in which to open the URL.

A: Change the protocol detail (HTTP or HTTPS) of the url to googlechrome and the application will open the link in Chrome:
let sUrl = "googlechrome://www.google.com"
UIApplication.shared.openURL(NSURL(string: sUrl) as! URL)

A: In the end I just got Google Chrome (on iOS) to do all the donkey-work (it appears willing to save the password for this website for future retrieval). I also submitted in the URL for the HTTPS version of the website and now all appear to work a little better.
if URL(string: fullURL) != nil {
    //let safariVC = SFSafariViewController(url: url)
    //self.present(safariVC, animated: true, completion: nil)
    UIApplication.shared.openURL(NSURL(string: fullURL)! as URL)
}

A: This is how I open links in Google Chrome:
var newLink: String = "http://www.apple.com"
newLink = link.replacingOccurrences(of: "http://", with: "googlechrome://")
if UIApplication.sharedApplication().canOpenURL(NSURL(string: newLink)!) {
UIApplication.sharedApplication().openURL(NSURL(string: newLink)!)
} else {
    let alertController = UIAlertController(title: "Sorry", message: "Google Chrome app is not installed", preferredStyle: .Alert)
    let okAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
    alertController.addAction(okAction)
    self.presentViewController(alertController, animated: true, completion: nil)
}

Opera Mini:
opera://open-url?url=http://

Opera Touch:
touch-https://

Firefox:
firefox://open-url?url=http://

Dolphin:
dolphin://

Brave:
brave://open-url?url=http://