text:
Q: How to create sub folder with username in java I am making  a small project there is a one module, which is KYC update and In this module i am save AadharCard,PAN Card and Other documents in Folder.So I am using java IO and try to create directory which name is Document and i want to create a sub-directory with user name and for create unique a also append username,id concat.I write a code but the sub-directory didn't crate.
My code is
String uploadPath = context.getRealPath("") + "assets" + File.separator + "Document" + File.separator
            + userPojo.getFirstName();
    File file = new File(uploadPath);

    try {
        if (!file.exists()) {
            file.mkdirs();
            logger.debug("Make Dir");
        }

and I also try this
File file = new File(dir, userPojo.getUserName());

    if (!file.exists()) {
        file.mkdirs();
        logger.debug("Make Dir");
    }

A: I search and i solve my problem.So i want to give solution if anyone face this type of problem
File file = new File(uploadPath);
    File file2 = new File(uploadPath, dataPojo.getFirstName()));
    if (!file.exists()) {
        file.mkdirs();
        logger.debug(file.getAbsolutePath());
    }
    if (!file2.exists()) {
        file2.mkdirs();
        logger.debug(file.getAbsolutePath());
    }


text:
Q: Difference between these two lines? What is the advantage of using obj.loc++ instead of this.loc++ in the
fourth line?
var carlike = function(obj, loc) {
    obj.loc = loc;
    obj.move = function() {
        this.loc++;
    };
    return obj;
};

var amy = carlike({}, 1);
amy.move();

It was a little explained on this video, but the difference between these two still isn't clear to me. https://www.youtube.com/watch?v=9oi0NY8Pen8
In this video it's been said that when we use this.loc++, it gets bound to a new value, every time move is invoked. But when we use obj.loc++ then each time we call car carlike function, a new closure scope is created and therefore the obj variable will always refer to exactly one car object. What does it mean?

A: If you use this, you set its value when you call it:
amy.move();         // Called with this === amy
amy.move.call(foo); // Called with this === foo

If you use obj, it will always be obj, independently of how move is called.

A: That is a video from the Udacity Object Oriented JavaScript course. Some lessons before the instructor teaches us about this keyword.
this refers to the object/caller of the function/method. Usually it is the object that is left of the dot. (In the answer of @Oriol this is overwritten in the special call function as a parameter.)
And that is really the difference, @Oriol is right.

A: Firstly, you have understood it correct that there is no difference in result whether you use this.loc or obj.loc.
Short answer to your question is there is no real direct advantage or dis-advantage of using obj.loc++ instead of this.loc++.
Explanation: There are 2 important context in which you should understand this.

*

*Global context:  In the global execution context (outside of any function), this refers to the global object, whether in strict mode or not. Since it is not your case, so let's not dig.

*Function context:  Inside a function, the value of this depends on how the function is called. In non-strict mode, the value of this must always be an object so it defaults to the global object. In strict mode, the value of this remains at whatever it's set to when entering the execution context. If it's not defined, it remains undefined. It can also be set to any value, such as null or 42 or "I am not this".

Read this from MDN for more detailed explanation.
Now, in your case whether you run in strict mode or non-strict mode, whether you will use this or obj you will see same results, because when you use this then again it becomes your function context and you access loc on this.
Now, talking about convention, suppose there is another global variable named loc and when you use this.loc++; inside your carlike function then still this will run in function context and will increment loc of carlike function but there is poor readability, at-least for novice, that whether it will increment global loc or local loc.
So, to sum up using obj.loc++; is a better idea.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Python class Inheritance query I'm getting an error in python multilevel class inheritance.
This is my code:
class Animal():
    def __init__(self):
        print("Animal created")
    def whoAmI(self):
        print("Animal")
    def eat(self):
        print('eating')

class Dog(Animal):
    print("dog created")

class Cat(Dog):
    print("car created")

m = Cat()
Cat.eat()

This is the error I am getting:

A: Your code should be like this:
m = Cat()
m.eat()

m is an instance of class Cat and as such, you can call eat() on it. You cannot call eat on the Cat itself unless you say Cat().eat().
This has little to do with inheritance as this code also gives you an error:
Animal.eat()

Also, cat should inherit directly from Animal and not dog.


text:
Q: How to use svg marker icons on google map iOS? I'm using google maps in my iOS project. I'm currently using .png icons as my marker icons but those are blurred no matter what quality it is.
svg icons are the best to my understand in this case. Does anyone know better way or how to use svg in iOS goole maps??

A: Starting Xcode 12, iOS now supports SVG natively.
Based on this SVG, just create a UIImage and add it as an icon to your google map marker.

Asset Catalogs
Added support for Scalable Vector Graphic (SVG) image assets. These preserve their vector representation with deployment targets of macOS 10.15 or later, iOS 13 or later, and iPadOS 13 or later. (18389814)

ref: https://developer.apple.com/documentation/xcode-release-notes/xcode-12-beta-release-notes

A: Convert image file to pdf using an image editing tool. And add the pdf image to the 'assets catalog. Don't forget to enable the 'preserve vector data' option on the attributed inspector.


text:
Q: Speeding up DispatcherTimer when button is clicked I'm creating a practice application that plays a sound every so often seconds and as a button is pressed it decreases the time interval for the sound to play. For example at the start it plays a sound every 15 seconds and when I press the button it should now play the sound every 10 seconds. Basically every time the user presses the button it decreases the interval by 5 seconds. So I have a DispatcherTimer at the top of my class and created its interval and Tick method when the page loads like such. I also have an int variable for the seconds in the time span.
DispatcherTimer timer = new DispatcherTimer();
int interval = 15;

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
        timer.Interval = new TimeSpan(0, 0, interval);
        timer.Tick += new EventHandler(timer_Tick);
        timer.Start();
}

void btn_Click(object sender, RoutedEventArgs e)
{
        Button btn = sender as Button;

        interval -= 5;

        timer = new DispatcherTimer();
        timer.Interval = new TimeSpan(0, 0, interval);
}

But this makes the sound play crazily. Is there a proper way to do this?

A: Do you cancel the first dispatcher timer before you start the second?  Is it possible that after the first click you have two dispatcher timers firing?

A: if this is your actual code then Larry is quite right... u have to call timer.stop(); before starting the second.
also give some condition so as to disallow interval < 0


text:
Q: Linux creates a small icon while running c++ compiled binary file I have the below line to run a binary file in linux,
binaryFile $2 & > logfiles.txt

Whenever it is executed it creates a small icon on the left top corner of the screen (attached image),
I want to run the binary without the icon(the small line).
Is there anyway to do that?Please help.
EDIT:
I got to know XtRealizeWidget is creating that small icon,
In the code,
a topLevel window is created using XtAppInitialize and XtRealizeWidget(topLevel)is called which creates it.
Is there a way to disable the icon via code.


text:
Q: Possibility of having parameterized definitions in haskell? Is there a way to compactly write multiple definitions in haskell via case, without having to repeat, other than the input parameters, the exact same syntax?  The only possible solution I can imagine so far is a macro.
Below is an example of defining binary max and min functions.  Can we compress
max' x y
  | x > y = x
  | otherwise = y

min' x y
  | x < y = x
  | otherwise = y

into something like
(max',min') x y
  | x (>,<) y = x
  | otherwise = y

?
Edit:
I know this allows us to parametrize over the "grumpy face", but it seems like there still could be a more succinct form.
maxmin x y f
  | f x y = x
  | otherwise = y

max' x y = maxmin x y (>)
min' x y = maxmin x y (<)

A: Well, you can always do this:
select op x y
    | x `op` y  = x
    | otherwise = y

max' = select (>)
min' = select (<)

I.e. extract the common parts into a function and turn the differences into parameters.


text:
Q: Can't pass an initial array to a useState to modify it later I'm pretty new in React Development. I want to pass several temperature values that come from props as initialState (via openWeather api), and then use the setTemperature to change with an onClick the values to their farenheit equivalent.
My code looks like this, and while the initial receives the values, the hook doesn't:
    const initialState = [tempCelsius, minTemp, maxTemp];
    const [temperature, setTemperature] = useState(initialState)

    const celToFar = () => {
        setTemperature((parseInt(initialState) * 9) / 5 + 32);
    };

I tried several other ideas, including this, which returns object object:
    const initialState = [tempCelsius, minTemp, maxTemp];
    const [temperature, setTemperature] = useState(prevState => {
    return {...prevState, initialState}
})

    const celToFar = () => {
        setTemperature((parseInt(initialState) * 9) / 5 + 32);
    };

What am I doing wrong? I'm pretty certain I don't need useEffect and should be able to do it if I pass the array correctly to the hook, since in console.log the function works when applied to individual props.

A: Welcome to SO! :)
parseInt(initialState) will turn you array [1,2,3] to 1...
Change your function to this:
  const celToFar = () => {
      let farengeits = initialState.map(v => v * 9 / 5 + 32);
        setTemperature(farengeits);
    };

To render values you can use:
 return (

{temperature.map((f, idx) =>
{f} F
}

  )


text:
Q: Entity Framework Database errors I have problems with database in my project in .NET MVC in Visual Studio 2013. I couldn't update databse by migrations, I changed models and updated database, but nothing changed, so I deleted all databases and migrations rebuild project, but now when i type in console enable-migrations i have this

More than one context type was found in the assembly 'Ogloszenia'.
  To enable migrations for Ogloszenia.Models.UsersContext, use Enable-Migrations -ContextTypeName Ogloszenia.Models.UsersContext.
  To enable migrations for Ogloszenia.Models.Plik+BazaPlikow, use Enable-Migrations -ContextTypeName Ogloszenia.Models.Plik+BazaPlikow.
  To enable migrations for Ogloszenia.Models.Skarga+BazaSkarg, use Enable-Migrations -ContextTypeName Ogloszenia.Models.Skarga+BazaSkarg.
  To enable migrations for Ogloszenia.Models.SlowaZakazane+BazaSlowZakazanych, use Enable-Migrations -ContextTypeName Ogloszenia.Models.SlowaZakazane+BazaSlowZakazanych.
  To enable migrations for Ogloszenia.Models.Kategorie+BazaKategorii, use Enable-Migrations -ContextTypeName Ogloszenia.Models.Kategorie+BazaKategorii.
  To enable migrations for Ogloszenia.Models.Ogloszenie+BazaOgloszen, use Enable-Migrations -ContextTypeName Ogloszenia.Models.Ogloszenie+BazaOgloszen.
  To enable migrations for Ogloszenia.Models.Ustawienie+BazaUstawien, use Enable-Migrations -ContextTypeName Ogloszenia.Models.Ustawienie+BazaUstawien.
  To enable migrations for Ogloszenia.Models.Wiadomosc+BazaWiadomosci, use Enable-Migrations -ContextTypeName Ogloszenia.Models.Wiadomosc+BazaWiadomosci.`

What do?

A: First of all make a separate class MigrationDbContext with all DbSets from your DbContexts.

*

*Then enable migrations for it only. Skip enable-migrations for your
production DbContexts, because of EF natively doesn't support
migrations for several DbContexts.

*Then apply command add-migration.

*Then apply command update-migration.

Good and quick reference for the most commonly used command names and parameters is here


text:
Q: How can "unique" show duplicate values in a dataframe? Background: I am very confused by my dataframe (df), which when I do some simple analyses is producing random rows for a specific value within my column named 'ID' (specifically, when ID == 42). As a result, I have started to do some troubleshooting.
When I try to list all the rows where ID = 42, I do:
data=df.loc[df['ID'] == 42]

And the rows look correct in this new variable called 'data'. However, when I scroll manually through the original dataframe df (e.g., in the Variable Explorer on Spyder), I can see there are way more rows for ID=42 that are not being printed to 'data'.
Then, to double check why the 'ID' values are showing this weird behavior, I did
print(df['ID'].unique())

And, weirdly, I get this:
[ 20.  31.  42.  42.  84. 142. 198. 248. 280. 288. 352. 378. 459. 498.]
-- note that 42 is repeated!
My question is, how can there be two 42s when I use the .unique() function? I thought it was supposed to output all the unique values? If I could understand this better, I could start to understand the rest of the problems that ensue...
Am I missing something about how 'unique' works?
Ps. My files are big so I haven't included them, but if I need to provide more (numerical) context please let me know.
Thanks!

A: Moving my comment to an answer, as it solved the problem:
print(df['ID'].astype(int).unique())


text:
Q: How to remove extraneous vertical space between html elements I have a problem with spacing between form fields (and other HTML elements) as seen in the attached images. I've tried many things in the CSS but nothing has worked. I'm not sure if it's a paragraph marging-top setting.
thanks for the help.

 .post-content is the class here and div.post-share for the facebook like buttons.
here's my style.css code:
body {
background: #f2f2f2;
padding-top: 58px;
padding-bottom: 15px;
}

.postid-1699 { padding-top: 338px; }

a {
color: #9f9f9f;
}

a:hover {
color: #3f3f3f;
}

a, p, h1, h2, h3, h4, h5, h6, div {
word-wrap: break-word;
}

h1, h2, h3 { letter-spacing: -1px;
}

/* Masonry */
#masonry {
margin: 0 auto;
visibility: hidden;
}

#masonry .thumb {
background: #fff;
border: 1px solid #e5e5e5;
font-size: 0.9em;
float: left;
margin: 0 8px 14px 8px;
position: relative;
width: 250px;
-webkit-box-shadow: 0 5px 10px #D6D6D6;
-moz-box-shadow: 0 5px 10px #D6D6D6;
box-shadow: 0 5px 10px #D6D6D6;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}

#masonry .featured-thumb-link {
display: block;
min-height: 70px;
position: relative;
text-align: center;
width: 100%;
}

#masonry .featured-thumb-gif {
background: transparent url("img/gif_overlay.png") no-repeat;
height: 50px;
width: 50px;
left: 50%;
top: 50%;
margin-left: -25px;
margin-top: -25px;
position: absolute;
}

#masonry .sticky {
background: #ffd;
}

#masonry .masonry-actionbar {
display: none;
font-weight: normal;
height: 25px;
position: absolute;
text-align: center;
top: 5px;
width: 250px;
z-index: 999;
}

#masonry .masonry-actionbar button {
font-weight: normal;
}

#masonry .masonry-actionbar-mobile {
display: none;
}

#masonry .post-title {
line-height: 1.3em;
font-size: 1em;
margin: 3px 0 16px 0;
padding: 5px 10px 0 10px;
text-align: center;
}

#masonry .masonry-meta {
border-top: 1px solid #f5f5f5;
clear: both;
color: #888;
font-size: 0.9em;
line-height: 1.3em;
padding: 5px 10px 10px 10px;
}

#masonry .masonry-meta-author {
font-weight: bold;
}

#masonry .masonry-meta-comment-likes {
border-top: none;
padding-bottom: 5px;
padding-top: 0;
}

#masonry .masonry-meta-comment-likes span {
margin: 0 0.3em;
}

#masonry .masonry-meta-comment {
margin-left: 35px;
}

#masonry .masonry-meta-comment-content {
white-space: pre-wrap;
}

#masonry .masonry-meta-avatar {
float: left;
margin: 2px 0px 5px 0;
width: 26px;
}

#masonry .masonry-meta-avatar img {
height: 26px;
width: 26px;
}

#masonry #reply-title {
}

#masonry .masonry-meta textarea {
height: 27px;
margin-top: 2px;
padding-top: 2px;
resize: none;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

#masonry .masonry-meta form {
margin: 0;
}

#ajax-loader-masonry {
left: 50%;
margin-left: -12px;
position: absolute;
top: 400px;
}

#infscr-loading {
background: #000;
bottom: 0;
color: #fff;
left: 50%;
margin-left: -60px;
opacity: 0.3;
padding: 5px;
position: fixed;
text-align: center;
width: 120px;
z-index: 100;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
-webkit-text-shadow: none;
-moz-text-shadow: none;
text-shadow: none;
}

#infscr-loading img {
width: 43px;
}

#post-lightbox {
background: transparent;
bottom: 0;
left: 0;
margin: 0;
overflow-x: auto;
overflow-y: scroll;
position: fixed;
right: 0;
top: 0;
width: 100%;
}

#post-lightbox .post-wrapper {
position : static;
width: 570px;
margin: 25px auto;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.2);
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Post */
#post-masonry {
position: relative
}

.post-wrapper {
background: transparent;
border: 0px solid #e5e5e5;
margin-bottom: 45px;
-webkit-box-shadow: 0 0px 0px rgba(0,0,0,0.08);
-moz-box-shadow: 0 0px 0px rgba(0,0,0,0.08);
box-shadow: 0 0px 0px rgba(0,0,0,0.08);
z-index: 200;
}

.post-wrapper .h1-wrapper {
border-bottom: 1px solid #eee;
}

.post-wrapper .h1-wrapper h1 {
font-size: 1.5em;
line-height: 1.3em;
margin: 10px 25px;
text-align: center;
}

.post-wrapper .post-top-wrapper {
border-bottom: 1px solid #eee;
min-height: 48px;
padding: 20px 25px;
}

.post-wrapper .post-top-wrapper-header .follow {
font-weight: bold;
margin-top: 8px;
}

.post-wrapper .post-top-wrapper-header {
color: #999;
margin-left: 60px;
}

.post-wrapper .post-top-wrapper-author {
font-size: 1.5em;
font-weight: bold;
line-height: 1.2em;
}

.post-wrapper .post-top-wrapper-header a {
color: #000;
}

.post-wrapper .post-share {
position: absolute;
left: 50%;
margin-left: 320px;
}

.post-share-horizontal {
background: #fafafa;
display: block;
padding: 8px 8px 0 8px;
}

.post-share-horizontal #___plusone_0, .post-share-horizontal #___plusone_1 {
margin-left: -25px !important;
margin-right: -15px !important;
padding-bottom: 13px !important;
}

.post-share .fb_iframe_widget {
display: block;
height: 20px;
overflow: hidden;
width: 90px;
}

.post-share .fb_iframe_widget span {
width: 450px !important;
}

.post-comments-wrapper .fb_iframe_widget span, .post-comments-wrapper .fb_iframe_widget  {
width: 100% !important;
}

.post-share-horizontal .pinterest img, .post-share-horizontal .post-embed, .post-share-horizontal .post-email, .post-share-horizontal #post-email-board, .post-share-horizontal .post-report {
margin-top: -14px;
}

.post-wrapper .post-top-meta {
margin: 0 25px;
padding: 20px 0 0 0;
}

.post-wrapper .post-top-meta .pull-right {
color: #a1a1a1;
font-size: 0.9em;
}

.post-wrapper .post-top-meta .pull-right a  {
font-weight: bold;
}

.post-wrapper .post-actionbar {
font-weight: normal;
}

.post-wrapper .post-actionbar button {
font-weight: normal;
}

.post-wrapper .post-actionbar .btn {
margin-bottom: 4px;
}

.post-wrapper .featured-thumb {
position: relative;
}

.post-wrapper .post-featured-photo {
background: #f2f2f2;
margin: 24px;
position: relative;
text-align: center;
}

.post-wrapper .post-nav-next {
position: absolute;
margin-top: -10px;
top: 50%;
right: -18px;
}

.post-wrapper .post-nav-prev {
position: absolute;
margin-top: -10px;
top: 50%;
left: -18px;
}

.post-wrapper .post-nav-next a, .post-wrapper .post-nav-prev a {
display: block;
font-size: 15px;
}

.post-wrapper .post-nav-next a:hover, .post-wrapper .post-nav-prev a:hover {
color: #555;
text-decoration: none;
}

.post-wrapper .post-nav-link-lightbox {
border: 1px solid #ccc;
height: 32px;
line-height: 32px;
width: 32px;
-webkit-border-radius: 16px;
-moz-border-radius: 16px;
border-radius: 16px;
-webkit-text-shadow: 1px 1px #fff;
-moz-text-shadow: 1px 1px #fff;
text-shadow: 1px 1px #fff;
}

.post-wrapper .post-nav-link-lightbox i {
display: block;
line-height: 32px;
}

.post-wrapper .post-nav-next-lightbox, .post-wrapper .post-nav-prev-lightbox {
position: fixed;
}

.post-wrapper .post-nav-link-lightbox:hover {
border: 1px solid #aaa;
}

.post-wrapper .post-content {
margin: 25px;
}

.post-wrapper .post-content h1 {
font-size: 1em;
font-weight: normal;
line-height: 1.4em;
}

.post-wrapper .post-content .post-title-large {
font-size: 1.5em;
font-weight: bold;
line-height: 1em;
}

.post-wrapper .post-original-author {
color: #999;
font-size: 0.9em;
}

.post-wrapper .post-original-author a {
font-weight: bold;
}

.post-wrapper .post-content .thecontent img {
height: auto;
}

.post-wrapper .post-comments {
border-top: 1px solid #eee;
padding-top: 20px;
}

.post-wrapper .post-comments-wrapper {
margin: 0 25px;
}

.post-wrapper .post-board {
border-top: 1px solid #eee;
margin-bottom: 16px;
}

.post-wrapper .post-board-wrapper {
margin: 0 25px;
}

.post-wrapper .post-board-wrapper h4 {
font-size: 1.1em;
margin-top: 12px;
}

.post-wrapper .post-board-wrapper .follow {
font-weight: bold;
margin-top: -2px;
}

.post-wrapper .post-board-wrapper a {
font-weight: bold;
}

.post-wrapper .post-board-photo {
background: #fcfcfc;
border-right: 4px solid #fff;
border-bottom: 4px solid #fff;
float: left;
height: 48px;
overflow: hidden;
width: 48px;
}

.post-wrapper .post-board-photo:nth-child(n+8) {
border-left: 2px solid #fff;
border-right: 3px solid #fff;
}

.post-wrapper .post-board-photo:nth-child(10) {
border-right: none;
}

.post-wrapper .post-likes {
border-top: 1px solid #eee;
padding-top: 10px;
}

.post-wrapper .post-likes-wrapper {
margin: 0 25px 5px 25px;
}

.post-wrapper .post-likes-wrapper h4 {
float: left;
font-size: 1.1em;
margin-top: 12px;
}

.post-wrapper .post-likes-wrapper a {
display: inline-block;
margin: 0 0 6px 6px;
}

.post-wrapper .post-likes-wrapper .more-likes {
margin-left: 7px;
}

.post-wrapper .post-meta-top {
margin: 0 25px;
padding: 5px 0 15px 0;
}

.post-wrapper .post-likes-avatar {
margin-left: 55px;
}

.post-wrapper #post-repins {
border-top: 1px solid #eee;
padding: 10px 0;
}

.post-wrapper .post-repins-wrapper {
margin: 0 25px 5px 25px;
}

.post-wrapper .post-repins-wrapper h4 {
float: left;
font-size: 1.1em;
margin-top: 12px;
}

.post-wrapper .post-repins-wrapper ul {
list-style-type: none;
margin-left: 62px;
}

.post-wrapper .post-repins-wrapper li {
margin-bottom: 6px;
min-height: 50px;
}

.post-wrapper .post-repins-wrapper li.more-repins {
min-height: 1em;
}

.post-wrapper .post-repins-wrapper .post-repins-content {
line-height: 1.1em;
margin-left: 55px;
padding-top: 15px;
}

.post-wrapper .post-repins-wrapper a {
font-weight: bold;
}

.post-wrapper .post-repins-avatar {
margin-right: 4px;
}

.thetags {
margin-top: 6px;
padding: 0;
}

.thetags a {
border: 1px solid #e1e1e8;
display: inline-block;
margin-bottom: 5px;
max-width: 90%;
padding: 2px 5px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

.thetags a:hover {
background: #fcfcfc;
text-decoration: none;
}

#post-repin-box {
background: #f2f2f2;
left: 50%;
margin-left: -210px;
max-width: 420px;
position: absolute;
}

#post-repin-box .close {
margin: 3px 8px 0 0;
}

#post-repin-box .post-repin-box-photo {
background: #e1e1e1;
border: 1px solid #aaa;
margin: 5px 25px;
overflow: hidden;
text-align: center;
}

#post-repin-box .post-repin-box-photo img {
max-height: 300px;
}

#post-repin-box #repinform {
margin: 10px 25px 10px 25px;
}

#post-repin-box .input-prepend, #post-repin-box .input-append {
margin: 0 0 3px 0;
width: 100%;
}

#post-repin-box .add-on {
background-color: #fcfcfc;
color: #999;
font-size: 18px;
font-weight: bold;
height: 22px;
line-height: 22px;
margin: 3px -1px 0 -1px;
width: 13%;
}

#post-repin-box .input-prepend input, #post-repin-box .input-append input {
font-size: 18px;
height: 32px;
margin: 3px 0;
text-align: left;
width: 84%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

#post-repin-box .input-append input {
text-align: right;
}

#post-repin-box #repinform select {
font-size: 18px;
height: 32px;
margin: 3px 0 6px 0;
width: 65%;
background: rgb(252,252,252);
background: -moz-linear-gradient(top, rgba(252,252,252,1) 0%, rgba(241,241,241,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(252,252,252,1)), color-stop(100%,rgba(241,241,241,1)));
background: -webkit-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(241,241,241,1) 100%);
background: -o-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(241,241,241,1) 100%);
background: -ms-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(241,241,241,1) 100%);
background: linear-gradient(to bottom, rgba(252,252,252,1) 0%,rgba(241,241,241,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfcfc', endColorstr='#f1f1f1',GradientType=0 );
}

#post-repin-box #repinform #noboard select {
color: #999;
}

#post-repin-box #repinform #repinform-add-new-board {
margin-top: 3px;
padding: 6px 10px;
}

#post-repin-box #repinform #board-add-new {
display: none;
font-size: 18px;
font-weight: bold;
height: 21px;
margin: 5px 0 5px 0;
width: 61%;
}

#post-repin-box #repinform textarea {
font-size: 18px;
height: 4em;
resize: vertical;
text-align: center;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

#post-repin-box #repinform #pinit {
font-size: 1.2em;
font-weight: bold;
margin: 5px 0;
}

#post-repin-box #repinform .alert {
height: 18px;
}

#post-repin-box #repinnedmsg {
margin: 0 25px 15px 25px;
}

#post-zoom-overlay {
background: #000;
bottom: 0;
display: none;
left: 0;
position: fixed;
right: 0;
top: 0;
z-index: 1055;
opacity: 0.85;
filter: alpha(opacity=85);
}

#post-embed-overlay {
background: #fff;
bottom: 0;
display: none;
left: 0;
position: fixed;
right: 0;
top: 0;
z-index: 1055;
opacity: 0.92;
filter: alpha(opacity=92);
}

#post-embed-box {
z-index: 1060;
}

#post-embed-box .modal-footer {
text-align: left;
}

#post-embed-box .modal-footer .help-inline {
color: #aaa;
font-size: 1.3em;
margin-top: -10px;
}

#post-embed-box input {
font-size: 1.3em;
padding: 10px;
}

#post-embed-box .modal-footer textarea {
background-color: #f5f5f5;
font-size: 1.3em;
line-height: 1.2em;
height: 6em;
padding: 10px;
resize: none;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

#post-email-overlay, #post-email-board-overlay {
background: #fff;
bottom: 0;
display: none;
left: 0;
position: fixed;
right: 0;
top: 0;
z-index: 1055;
opacity: 0.92;
filter: alpha(opacity=92);
}

#post-email-box, #post-email-board-box {
z-index: 1060;
}

#post-email-box .modal-footer, #post-email-board-box .modal-footer {
text-align: left;
}

#post-email-box .modal-footer .help-inline, #post-email-board-box .modal-footer .help-inline {
color: #aaa;
font-size: 1.3em;
margin-top: -10px;
}

#post-email-box input, #post-email-board-box input {
font-size: 1.3em;
padding: 10px;
}

#post-email-box .modal-footer textarea, #post-email-board-box .modal-footer textarea {
font-size: 1.3em;
line-height: 1.2em;
height: 6em;
padding: 10px;
resize: none;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

#post-report-overlay {
background: #fff;
bottom: 0;
display: none;
left: 0;
position: fixed;
right: 0;
top: 0;
z-index: 1055;
opacity: 0.92;
filter: alpha(opacity=92);
}

#post-report-box {
z-index: 1060;
}

#post-report-box .modal-footer {
text-align: left;
}

#post-report-box .modal-footer .help-inline {
color: #aaa;
font-size: 1.3em;
margin-top: -10px;
}

#post-report-box input {
font-size: 1.3em;
padding: 10px;
}

#post-report-box .modal-footer textarea {
font-size: 1.3em;
line-height: 1.2em;
height: 6em;
padding: 10px;
resize: none;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

.subpage-title h1 {
font-size: 1.8em;
line-height: 1.2em;
padding-bottom: 0.6em;
margin-bottom: 5px;
text-align: center;
-webkit-text-shadow: 1px 1px #fff;
-moz-text-shadow: 1px 1px #fff;
text-shadow: 1px 1px #fff;
}

.subpage-title p {
border-top: 3px double #ccc;
padding: 8px 0;
text-align: center;
}

.grand-title-wrapper {
margin: 30px 0 60px 0;
text-align: center;
}

.grand-title-wrapper h1 {
border-bottom: 3px double #ccc;
font-size: 1.8em;
line-height: 1.2em;
padding-bottom: 0.6em;
margin-bottom: 5px;
-webkit-text-shadow: 1px 1px #fff;
-moz-text-shadow: 1px 1px #fff;
text-shadow: 1px 1px #fff;
}

.grand-title-wrapper h1 a {
font-weight: bold;
}

.grand-title-wrapper .grand-title-subheader {
border-bottom: 3px double #ccc;
padding: 4px 0 8px 0;
}

.grand-title-wrapper .grand-title-subheader .avatar {
height: 32px;
width: 32px;
}

.grand-title-wrapper .grand-title-subheader a {
color: #000;
font-weight: bold;
}

.grand-title-wrapper .grand-title-subheader .pull-left a {
margin-right: 5px;
}

.grand-title-wrapper .follow {
color: #000;
font-weight: bold;
}

/* Comments */
.post-comments .commentlist {
list-style-type: none;
margin: 0;
padding: 0;
}

.post-comments .commentlist li {
list-style: none;
padding-bottom: 1em;
}

.post-comments .commentlist ul.children li {
margin: 1em 0 0 0;
padding: 0;
}

.post-comments .comment-avatar {
float: left;
padding: 3px 10px 0 0;
}

.post-comments .comment .pull-right a {
padding: 2px 6px;
font-size: 0.8em;
line-height: 15px;
color: #888;
background-color: #f5f5f5;
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #e6e6e6;
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
border: 1px solid #ddd;
*border: 0;
border-bottom-color: #ccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
*margin-left: .3em;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.post-comments .comment .pull-right a:hover {
background-color: #e6e6e6;
*background-color: #d9d9d9;
background-position: 0 -15px;
text-decoration: none;
-webkit-transition: background-position 0.1s linear;
-moz-transition: background-position 0.1s linear;
-o-transition: background-position 0.1s linear;
transition: background-position 0.1s linear;
}

.post-comments .comment-content {
color: #333;
line-height: 1.3em;
margin-left: 60px;
padding-bottom: 5px;
width: 80%;
}

.post-comments span.bypostauthor a.url {
background-color: #aaa;
color: #fff;
margin-right: 5px;
padding: 0 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

.post-comments span.bypostauthor a.url:hover {
background-color: #990000;
text-decoration: none;
}

.post-comments #reply-title {
color: #666;
font-size: 18px;
margin: 0;
padding: 0;
}

.post-comments #cancel-comment-reply-link {
margin-left: 60px;
}

.post-comments blockquote p {
font-size: 1em;
}

#commentform .commentform-input {
color: #666;
margin-right: 14px;
width: 31%;
}

#commentform .commentform-input:nth-child(3) {
margin-right: 0;
}

#commentform .commentform-field {
width: 94%;
}

#commentform .textarea-wrapper {
margin-left: 60px;
}

#commentform textarea {
background: #fafafa;
height: 48px;
resize: vertical;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

/* Media Queries */
@media (min-width: 1200px) {
    #post-lightbox .post-wrapper {
    width: 570px;
    }

    #commentform .commentform-input {
    margin-right: 10px;
    width: 32%;
    }

    .sidebar .sidebar-left-single {
    width: 270px;
    }

    .sidebar-right-single {
    margin-left: 5px;
    }

    .board-mini {
    width: 270px;
    }

    .board-mini .board-photo-wrapper {
    height: 65.5px;
    width: 65.5px;
    }

    .board-domain .board-domain-wrapper {
    height: 55px;
    width: 55px;
    }

    .post-wrapper .post-share {
    margin-left: 320px;
    }

    .usercp-pins #pin-upload-postdata-wrapper form .input-prepend input, .usercp-pins #pin-upload-postdata-wrapper form .input-append input {
    width: 85%;
    }
}

@media (max-width: 979px) {
    body {
    padding-top: 0;
    }

    #post-lightbox .post-wrapper {
    width: 460px;
    }

    .sidebar {
    padding-top:0;
    }

    .sidebar .sidebar-left-single {
    width: 166px;
    }

    .board-mini {
    width: 166px;
    }

    .board-mini .board-photo-wrapper {
    height: 39.5px;
    width: 39.5px;
    }

    .board-domain .board-domain-wrapper {
    height: 29px;
    width: 29px;
    }

    .post-wrapper .post-share {
    margin-left: 260px;
    }

    .post-top-meta .pull-right {
    clear:both;
    float: none;
    padding-top: 10px;
    }

    #double-left-column {
    padding-bottom: 20px;
    }

    #scrolltotop {
    right: 5px
    }

    #scrolltotop a {
    padding: 5px 10px;
    }

    #commentform .commentform-input {
    margin-right: 14px;
    width: 100%;
    }

    #commentform .commentform-field {
    width: 98%;
    }
}

@media (min-width: 768px) and (max-width: 979px) {
    #pin-postdata-add-new-board {
    float: left;
    }
}

@media (max-width: 767px) {
    .sidebar .sidebar-left-single, .post-share {
    display: none;
    }

    .sidebar-right-single {
    margin-top: 0;
    margin-left: 0;
    }

    .post-wrapper .post-board {
    display: block;
    }

    .post-wrapper {
    margin-bottom: 5px;
    }

    .board-mini {
    width: 166px;
    }

    #userbar .nav {
    display: block;
    }

    .usercp-pins #pin-upload-postdata-wrapper form .input-prepend input, .usercp-pins #pin-upload-postdata-wrapper form .input-append input {
    width: 85%;
    }
}

@media (max-width: 480px) {

#shadowtop { margin-top: -5px;
}

    #masonry .thumb {
    width: 93%;
    }

    #masonry .featured-thumb {
    height: auto !important;
    width: 100% !important;
    }

    #masonry .masonry-actionbar-mobile {
    display: block;
    margin-bottom: 5px;
    text-align: center;
    }

    #post-repin-box {
    margin-left: 0;
    max-width: 100%;
    top: 10px;
    left: 10px;
    right: 10px;
    }

    #post-repin-box select {
    max-width: 50%;
    }

    #post-repin-box .post-repin-box-photo img {
    max-height: 150px;
    }

    .post-wrapper .post-board-photo:nth-child(n+8) {
    border-left: none;
    border-right: 4px solid #fff;
    }

    .post-wrapper .post-board-photo:nth-child(10) {
    border-right: none;
    }

    .post-wrapper .post-top-wrapper-header .follow {
    margin-top: -40px;
    }

    .post-wrapper .post-top-wrapper-header {
    clear: both;
    margin: 50px 0 0 0;
    }

    .board-mini {
    width: 88%;
    }

    .board-mini .board-photo-wrapper {
    height: auto;
    min-height: 35px;
    width: 24.5%;
    }

    #user-profile-follow .follow-wrapper {
    margin: 10px 0;
    width: 90%;
    }
}

@media (max-width: 480px) and (orientation:landscape) {
    #masonry .thumb {
    margin-left: 13px;
    margin-right: 13px;
    }

    #shadowtop { margin-top: -2px;
}

A: it was a Google Web fonts plugin that caused it. I disabled the plugin and the problem went away.
this is from the HTML source code:

                                                                                p {
margin-top: 269px; margin-bottom: 188px;
}


text:
Q: Wordcloud titles not showing/rendering in R So I performed a sentiment analysis using tidy principles. I would like to plot the results in a comparison cloud (positive VS negative sentiments).
This is my code:
library(reshape2)
library(tidytext)

dtm_tidy %>%
filter()
dtm_tidy %>%
inner_join(get_sentiments("bing"),by=c(term="word")) %>%
count(term, sentiment, sort=TRUE) %>%
acast(term ~ sentiment, value.var = "n", fill = 0) %>%
comparison.cloud(colors = c("darkred", "darkgreen"), max.words=300, scale = c(0.3, 0.3), random.order=FALSE, rot.per=0.25, title.size = 1)

However, something seems to go wrong, because the titles (positive & negative) are not shown or rendered. I already changed scales and title.size but nothing could solve this issue.
Anybody an idea?

A: I had a similar problem -- the titles were being cutoff on the top and the bottom of the rendered plot when I tried to save it as a pdf.
I was able to get the correct plot output by using "Portrait" orientation instead of "Landscape."  I'm not sure why that fixed the issue but it did when saving it as a pdf or an image.

A: I found the answer to my problem: if this issue occurs to you, use the fixed.asp=TRUEcommand. Something like this:
comparison.cloud(colors = c("darkred", "darkgreen"), max.words=300, scale = c(0.3, 0.3), random.order=FALSE, rot.per=0.25,fixed.asp=TRUE,title.size = 1)

This should do the trick! :)


text:
Q: Scala StringBuilder Is there an implicit method to convert scala.collection.mutable.StringBuilder to java.lang.StringBuilder?
I am using a Java library (JCommander) in which one of the methods (usage) takes a java.jang.StringBuilder argument.

A: Looking at the source code, it seems there's absolutely no way to get a java.lang.StringBuilder from a scala.collection.mutable.StringBuilder.
You can create a new java.lang.StringBuilder with Scala's, going through a conversion of some type (String or CharSequence).

A: You can't start with a Scala StringBuilder and then obtain the Java version.  You can, however, wrap a java.lang.StringBuilder in the Scala version.  So:
val jsb = new java.lang.StringBuilder();
val sb = new StringBuilder(jsb);
// Do Scala-y stuff with sb
JCommander.whatever.usage(jsb);
// Do more Scala-y stuff

Since--not a guarantee, but true in practice right now (2.8, 2.9)--the Scala wrapper doesn't store any state (instead just referring to the Java version), you're safe to mix and match usage of the two.

A: Use this implicit transform do do this:
    implicit def b2b(b: scala.collection.mutable.StringBuilder) =
        new java.lang.StringBuilder(b)


text:
Q: Execution time between functions with & without arguments C/C++ I'd just like to ask what's the difference in execution time when:
a) We have variables declared in main() and send them in functions using arguments
b) We have global variables and access them directly from functions with no arguments
The thing is I started writing few aps and just saw a few discussions about this, but I haven't yet written any application that makes the difference bigger then few ms.

A: Passing parameters to function involves usually one of two assembler instructions: push param (and later pop param) or mov ax, param. Since processor is able to do (a lot) more in a second, such "optimization" mostly probably will go unnoticed (a few ms on the whole program is below the error margin)
Using global variables in the place of function parameters will cause a huge mess in the code with almost unnoticeable or possibly no performance gain.

A: All of this depends on what CPU and compiler that are used.
When you pass a parameter to a function, one of the following could happen:

*

*The parameter is stored in a CPU register. This is very efficient.

*The parameter is stored on the stack. This is the most common. It involves some minor overhead of pushing/popping the parameter to/from the stack when the function is started/finished.

*The parameter isn't a new variable at all. Instead, the compiler inlines the function and uses the original variable for modifications. This is about as efficient as you can get.

Using a global variable is will be ever so slightly faster than using the stack. It will unlikley be faster than using a CPU register: inside the function the value might need to be loaded into such a register before calculations anyhow.
It should be noted we are talking about a few CPU ticks here and there.
My advise:

*

*You should never attempt any kind of manual optimizations unless you have in-depth hardware knowledge of the specific CPU used. If you have no such knowledge, the compiler will optimize the code better than you do in 99% of the cases. Because the compiler port was most likely written by an expert of the given system. The compiler also knows the overall performance picture, which the programmer does not, so the compiler is more suitable for doing the optimization.

*You should never attempt any kind of manual optimization unless you have actually performed formal benchmarking and found a bottleneck in the program.

*Global variables are incredibly bad and dangerous to use. They lead to spaghetti code and they are not thread-safe.

*If you are writing some kind of high-end desktop application, such as PC programs or phone apps, then using global variables to increase performance is complete nonsense. You are on a system which has non-existent real-time performance to begin with! At any given time, your OS might decide to chew up many billions of CPU ticks while giving your program the finger. So don't go chasing 1 or 2 CPU ticks.

*These kind of manual optimizations only make sense if you are developing embedded systems applications that are very close to the hardware, and at the same time have hard real-time requirements.

A: Stack operations are very efficient, and they are made even more efficient because the stack is likely to be in cache memory. That could make using the stack even faster than not using it.

A: Expect parameter passed variables to be a lot faster than global variables. In Modern ABIs, function parameters are passed mostly using CPU registers which are immediately available to the CPU.
Global variables must be read from (static) memory. Worse than that, static memory is allocated on its own memory page, which is generally far from your stack (or heap) memory. This means that cache misses are  more likely which in turn means that access can consume a large number of CPU cycles.
Obviously this depends a lot on your usage patterns.


text:
Q: Expected Value of consecutive results of coin flipping I'd very much appreciate your help in finding a solution to the following problem.
We take a fair coin, and flip it $n$ times. What would be the expected value of the longest
consecutive run of a certain result?
Thanks


text:
Q: Minimax Approximation to Sine Function on interval [-K, K] Let $p_{n,K}(x)$ be the polynomial of degree $n$ that minimizes $\epsilon_{n,K} = ||p_{n,K}(x) - sin(x)||_\infty$ on the interval $[-K, K]$. Question: what is the asymptotic behavior of $\epsilon_{n,K}$  where $n \to \infty$?

A: The rate of polynomial approximation
$$E_{n}(f,\mathcal{K}):=\inf\{\max_{z\in \mathcal{K}}|f(z)-P_{n}(z)|,~\text{deg}~P_{n}\leq n\}$$
to an entire function $f$ on a compact set $\mathcal{K}$ of the complex plane of positive capacity was derived by A. Batyrev in

Batyrev, A. V., On the best approximation of analytic functions by
  polynomials.  Doklady Akad. Nauk SSSR (N.S.) 76, (1951) 173--175.

His theorem states that
$$
\operatorname { limsup } _ { n \rightarrow \infty } n \left[ E _ { n } ( f , \mathcal{K} ) \right] ^ { \rho / n } = e \rho \tau ^ { \rho } \sigma.
$$
Here $\tau$ is the capacity of $\mathcal{K}$, $\rho$ and $\sigma$ are the order and type of $f$ respectively.
Since the segment $\mathcal{K}=[-K,K]$ has capacity $K/2$, and the sine function is of order 1 and type 1, one gets that $E_{n}(\sin,\mathcal{K})$ decreases like
$$\left(\frac{eK}{2n}\right)^{n},$$
as $n$ tends to infinity.
Another reference, possibly easier to get, is

Giroux A., Approximation of entire functions over bounded domains.  J.
  Approx. Theory 28 (1980), no. 1, 45-53.

which extends Batyrev's result to $L^p$ norms, $2\leq p\leq\infty$.


text:
Q: ASP .Net MVC 5 Get Attributes of properties of model in razor view Hi I manage to make my problem on dropdownlist work but still i encountered another issue. this is my new code;
@foreach (var props in mymodel.GetType().GetProperties().ToList())
        {
            <div class="editor-line">
                <label>@props.Name </label>
                @(Html.Kendo().DropDownList()
                    .Name("ddl1_" + @props.Name)
                    .OptionLabel("Select")
                    .DataTextField("Text")
                    .DataValueField("Value")
                    .AutoBind(false)
                    .Events(e => e.Change("onSelect"))
                    .HtmlAttributes(new { style = "width: 25%" })
                )
            </div>
        }

and here's how i populate them, sorry for the bad practice.
@foreach (var props in mymodel.GetType().GetProperties().ToList())
            {
                <text>
                    var ddl = $('#ddl1_' + "@props.Name").data("kendoDropDownList");
                    ddl.setDataSource(ddlSource);
                </text>
            }

now my problem is the .Events(e => e.Change("onSelect")) code is not working, it makes may page fail to load because it cannot find the onSelect function.
here is the code in javsacript
function onSelect(e) {
        debugger;
        if (e.item) {
            var dataItem = this.dataItem(e.item);
            var elementId = e.sender.element[0].id
            console.log(elementId);
            console.log("event :: select (" + dataItem.Text + " : " + dataItem.Value + ")");
        } else {
            console.log("event :: select");
        }
    }


text:
Q: How to restrict the user from creating more than one doc in firestore database? I have a form on my flutter app where the userr can submit his personal info:

try {
      await FirebaseFirestore.instance
          .collection('users')
          .doc(userID).collection('personalInfo')
          .add(_insertProfInfoToDBToDB.toJson());

This function is triggered by a sunmit button, now the problem is that if the user doesnt have an internet connection for example and he submit this form, then he will get an error that there is no internet connection which is coming from another function

Future<void> _tryConnection() async {
    try {
      final response = await InternetAddress.lookup('Example.com');

      setState(() {
        _isConnectionSuccessful = response.isNotEmpty;
      });
    } on SocketException catch (e) {
      print(e);
      setState(() {
        _isConnectionSuccessful = false;
      });
    }
    if (_isConnectionSuccessful != true){
      Utils.showSnackBar("Please check your internet connection");
    }
  }

but this doesnt restric him from pressing the submit button again and again and again...
So what is happening is that once the user gets an internet connection, there will be multiple docs created at the same time inside the 'personalInfo' collection.
My question is how to restrict the user from creating more than one doc inside a collection?

A: Use setData
Firestore.instance.
  collection('users').
  document('userID').collection('collection name').document('docId')
  set(data, merge: true)

Now this will create a new entry if it doesnt exist and update it if its existing
From the docs

setData(Map<String, dynamic> data, {bool merge: false}) → Future
Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created.
.If merge is true, the provided data will be merged into an existing document instead of overwriting.>


text:
Q: Rails: Ruby Code That Can Scan Ruby Code I'm starting a project with several contributors. We want to keep track of who wrote what code, as well as to get a count of how many methods, controller actions, and views a contributor has written. This necessitates a level of meta-programming that none of us are familiar with.
So far, the best idea we've come up with is to add a comment before each snippet of code with the contributor's username and a short, consistent phrase. For instance:
# method by RacerX
def a_useful_method
  . . .
end

# method by MysteryProgrammer123
def another_useful_method
  . . .
end

# action by MysteryProgrammer123
def new
  . . .
end

Then we'd run a method to count all instances of action by and method by and view by that each user has written throughout the project. Unfortunately, we don't know how to write Ruby code that can inspect other Ruby code. It might not even be possible. If it is possible, though, how is it done?
Alternatively, there might be a better approach that we're not considering.

A: You should prefer your source control system to track who wrote what.  git blame, for instance, can produce an annotated listing showing author and source line.
Identifying views should be easy, they're in the view directory.  Static method definitions can generally be found with regexp /\bdef\s+(?:\w+\.)?(\w+)\b/. Distinguishing "actions" from other methods probably involves filtering method names against common action names and other names discovered by examining your routes.

A: Rather than reinventing the wheel, use a ready-made tool. And if it does not come to your mind how to implement such code, then you probably will not be able to write such code. A documentation tool such as YARD may be useful. The way this works is that you add explanations as comments before method definitions. Usually this is for writing the documentation to be read by the users, but you can depart from its intended use and write things like the programmers name, or whatever other information you like.


text:
Q: Shortcode to Strip Tags of Custom Fields Based on Shortcode attribute Question Background
I created a group of custom fields, e.g. person-given-name, person-last-name and person-job-title. These custom fields contain html. I want to show their content as plain text in a specific place on my webpage. The custom fields are created by a plugin called Toolset Types and the plugin has a built-in function to display the contents of the custom field: types_render_field( "custom-field-slug", array());
To do so effectively, I wanted to create a shortcode with an attribute, whereby when I add the field name in the attribute, the strip_tags will be applied to that custom field, and return the plain text content of the custom field.
Initial Function
The following function works for one field only.
function add_person_data() {
    if( function_exists( 'types_render_field' ) ){
        $input = types_render_field( "person-job-title", array());
        $a = strip_tags($input);
    return $a;
    }
}
    add_shortcode( 'add-person-data', 'add_person_data');

Updated Function
I tried to expand the function to have a shortcode attribute, where I can specify which custom field I want to apply strip_tags on and display.
The function did not give errors in the php-error.log, but does not return any values. This is the shortcode I used [add-person-data field="givenname"].
function add_person_data($atts) {
    $atts = shortcode_atts(
        array(
            'field' => '',
        ),
        $atts
    );

    if( function_exists( 'types_render_field' ) ){

        $person_info = array_filter( array (
                    'givenname'       => types_render_field( "person-given-name", array () ),
                    'familyname'      => types_render_field( "person-family-name", array () ),
                    'jobtitle'      => types_render_field( "person-honorific-suffix", array () ),
                    ) );
        foreach ( $person_info as $prop => $value ) {
                    $a = strip_tags($person_info['field']);
                    }
        return $a;
    }
}
    add_shortcode( 'add-person-data', 'add_person_data');

Can someone please point me to the mistakes I am doing, so I can fix the code?
Thanks in advance.

A: Try use code below:
function add_person_data($atts) {
    $atts = shortcode_atts(
        array(
            'field' => 'givenname',
        ),
        $atts
    );

    $a = '';

    if( function_exists( 'types_render_field' ) ){

        $person_info = array_filter( array (
            'givenname'       => types_render_field( "person-given-name", array () ),
            'familyname'      => types_render_field( "person-family-name", array () ),
            'jobtitle'      => types_render_field( "person-honorific-suffix", array () ),
        ) );
        $a = $person_info[$atts['field']];
        $b = strip_tags($a);
        return $b;
    }
}
add_shortcode( 'add-person-data', 'add_person_data');


text:
Q: Mapping a POCO Class to MVC Model I am new to MVC as well as EF. Following some Nice Tutorials I finally created my POCO Classes.
I am trying to create a MVC Model with the help of POCO Classes in a layered architecture. Where My POCO class sits in Class Library project called Entities.
And my MVC4 application is a Web Project which references Entities.
I query database and have content in Entities and want to map 3-4 POCO classes to a single Model so i can create a strongly typed view.
Am not sure how to proceed. Assist me on this.

A: Check out the ASP.NET MVC in Action book.. It has an entire chapter dedicated to this topic.  They suggest and show how to use AutoMapper to map domain entities to ViewModels.
I also have an example here.
In the BootStrapper:
 Mapper.CreateMap<Building, BuildingDisplay>()
                .ForMember(dst => dst.TypeName, opt => opt.MapFrom(src => src.BuildingType.Name));

In the controller:
  public ActionResult Details(int id)
        {
            var building = _db.Buildings.Find(id);

            if (building == null)
            {
                ViewBag.Message = "Building not found.";
                return View("NotFound");
            }

            var buildingDisplay = Mapper.Map<Building, BuildingDisplay>(building);
            buildingDisplay.BinList = Mapper.Map<ICollection<Bin>, List<BinList>>(building.Bins);

            return View(buildingDisplay);
        }

A: i have answer such type of question once before, if you want to see it , here is the link
http://stackoverflow.com/questions/15432246/creating-a-mvc-viewmodels-for-my-data/15436044#15436044

But inform me back if you need more help :D
here is your viewmodel
public class CategoryViewModel
{
    [Key]
    public int CategoryId { get; set; }
    [Required(ErrorMessage="* required")]
    [Display(Name="Name")]
    public string CategoryName { get; set; }
    [Display(Name = "Description")]
    public string CategoryDescription { get; set; }
    public ICollection<SubCategory> SubCategories { get; set; }
}

Now for mapping use projection in linq;
public List<CategoryViewModel> GetAllCategories()
{
    using (var db =new Entities())
    {
        var categoriesList = db .Categories
            .Select(c => new CategoryViewModel() // here is projection to your view model
            {
                CategoryId = c.CategoryId,
                CategoryName = c.Name,
                CategoryDescription = c.Description
            });
        return categoriesList.ToList<CategoryViewModel>();
    };
 }

now your controller;
ICategoryRepository _catRepo;
    public CategoryController(ICategoryRepository catRepo)
    {
        //note that i have also used the dependancy injection. so i'm skiping that
        _catRepo = catRepo;
    }
    public ActionResult Index()
    {
        //ViewBag.CategoriesList = _catRepo.GetAllCategories();
           or
        return View(_catRepo.GetAllCategories());
    }

And lastly your view;
@model IEnumerable<CategoryViewModel>
@foreach (var item in Model)
{
    <h1>@item.CategoryName</h1>
}


text:
Q: How to write sphinx queries with OR condition I need to create a sphinx query in my project with OR condition. But giving an OR condition like
select cost FROM transactionsChart WHERE cost=25 OR cost=5;

is not working. It returns an error like
ERROR 1064 (42000): sphinxql: syntax error, unexpected OR, expecting $end near 'OR cost=5'

Can anybody help me....
Thanks in advance

A: Sphinx doesnt support OR in the WHERE clause, only AND.
For your specific example, could use IN syntax,
sphinxql> SELECT cost FROM transactionsChart WHERE cost IN (5,25);

or a more general solution is to use a virtual attribute
sphinxql> SELECT cost, IF(cost=25 OR cost=5,1,0) AS filter
      FROM transactionsChart WHERE filter = 1;

A: Try with
select cost FROM transactionsChart WHERE cost=25 | cost=5;

Source - Official Documentation


text:
Q: Group $G$ such that $[G : Z(G)] = 4$ Let $G$ be a group, let $Z(G)$ be the center of $G$, and suppose that $[G : Z(G)] = 4$.
(a) Prove that $x^2 \in Z(G)$ for every $x \in G$.
(b) Prove that $Z(G)$ contains an element of order two.
Here are my thoughts so far:
Recall that $Z(G)$ is a normal subgroup of $G$. Thus, $G/Z(G)$ has a group structure. By the fact that $[G : Z(G)] = 4$, we have that $|G/Z(G)| = 4$. This gives that $G/Z(G)$ is either isomorphic to $\mathbb{Z}/4\mathbb{Z}$ or $\mathbb{Z}/2\mathbb{Z} \times \mathbb{Z}/2\mathbb{Z}$. But, $G/Z(G)$ cannot be isomorphic to $\mathbb{Z}/4\mathbb{Z}$; this would mean that $G/Z(G)$ is cyclic $\Rightarrow$ $G$ abelian $\Rightarrow$ $G = Z(G)$, which contradicts the index of $Z(G)$ in $G$ being equal to $4$.
Thus, so far I know that $G/Z(G)$ is isomorphic to $\mathbb{Z}/2\mathbb{Z} \times \mathbb{Z}/2\mathbb{Z}$. I also know that $G/Z(G) \cong Inn(G)$, the inner automorphism group of $G$. How can I use these facts to  prove the desired facts ?
Here's one attempt to use that $G/Z(G) \cong Inn(G)$ for part (b). If this is the case, we have that $Inn(G) \cong \mathbb{Z}/2\mathbb{Z} \times \mathbb{Z}/2\mathbb{Z}$ $\Rightarrow$ $Inn(G)$ necessarily contains an element of order $2$. Thus, the map $\phi: G \longrightarrow G : h \longmapsto ghg^{-1}$ for some $g \in G$, where $\phi$ is not the identity map, has order $2$ $\Rightarrow$ $g^2hg^{-2} = h$ $\Rightarrow$ $g^2h = hg^{2}$. It looks like I have a commutativity relation here -- how can I relate this to $Z(G)$ having an element of order $2$ ?
For part (a), is the right idea to look at the order of the cosets $G/Z(G)$ ? I suppose all cosets that aren't the identity are of order $2$, since $G/Z(G) \cong \mathbb{Z}/2\mathbb{Z} \times \mathbb{Z}/2\mathbb{Z}$. Is this the right route to take?
Thanks for all of your help. (=

A: For the second part of the question we proceed as follows.Since $G/Z(G) \cong C_2 \times C_2$, $G$ is not abelian. Let $x \in G-Z(G)$, then observe that for the centralizer: $Z(G) \subsetneq C_G(x) \subsetneq G$, so $|G:C_G(x)|=2=|C_G(x):Z(G)|$. Hence every conjugacy class has cardinality at most $2$.
In case $G$ is finite, put $l=|G|-|Z(G)|$, then the class formula yields
$$|G|=\underbrace{1 + 1 + \cdots +1}_{|Z(G)| \text{ times}}+\underbrace{2+2+ \cdots +2}_{l\text{ times}}$$ whence $4|Z(G)|=|Z(G)|+2l$, so $3|Z(G)|=2l$. It follows that $2$ divides $|Z(G)|$ and owing to Cauchy's Theorem, $Z(G)$ has an element of order 2. In fact, from the above calculation, one can derive that the number of conjugacy classes of $G$ is $k(G)=2\frac{1}{2}|Z(G)|=\frac{5}{8}|G|$.
Let us consider the general case. We already observed that every conjugacy class has order at most $2$. We will show that this implies that $|G'|=2$. Since $G/Z(G)$ is abelian and thus $G' \subseteq Z(G)$, this shows that $Z(G)$ has an element of order $2$.

Now, for each $x \in G$ there exists a unique $f(x) \in G$ such that $\{gxg^{-1}x^{-1}:=[g,x]: g \in G\}=\{1,f(x)\}$, so that the conjugacy class of $x$ is $\{x,f(x)x\}$. Hence this defines a map $f: G \rightarrow G'$ and $G'=\langle f(G) \rangle$. We will show that the image of $f$ has cardinality $2$ and consists of elements of order at most $2$. Note that $f(z)=1$ for each $z \in Z(G)$.

Firstly, if $x$ and $y$ do not commute, $f(x)$ nor $f(y)$ is the identity element: since $yxy^{-1} \neq x, yxy^{-1}=f(x)x$ and likewise, $xyx^{-1}\neq y$ gives $xyx^{-1}=f(y)y$.
Next, observe that if $x,y$ do not commute, $xy$ does not commute with $x$ or $y$. It follows that $f(x)=f(y)$:
$$f(x)=[xy,x]=[x,xy]^{-1}=f(xy)^{-1}=[y,xy]^{-1}=[xy,y]=f(y)$$
and in addition,
$$f(x)=[y,x]=[x,y]^{-1}=f(y)^{-1}.$$
From this it follows that $f(x)=f(y)$ has order $2$. We already saw that $f$ takes the value $1$ on $Z(G)$. To finish the proof, we will show that $f$ is also constant on $G-Z(G)$ and takes the value of an element of order $2$. Let $x,y \in G-Z(G)$, hence $C_G(x)$ and $C_G(y)$ are both proper subgroups of index $2$ and it it well known that their union cannot be the whole group: $C_G(x) \cup C_G(y) \subsetneq G$. So we can find a $g \in G$ that neither commutes with $x$ or $y$, implying $f(x)=f(g)=f(y)$, and this element is of order $2$. So outside $Z(G)$, $f$ is constant and takes the value of an element of order $2$.$\square$


text:
Q: View the results of Behat tests in the browser like Jasmine So Jasmine has a page that runs the js tests and shows the results.

Is there anything similar for Behat, that runs the tests and shows the results.
Basically I want a non tech to be able to visit a page to see if the project is hitting the requirements.

A: Behat 2.x has an html formatter. You can use it to generate an html page and publish it somewhere, so others could see the results.
Behat 3 doesn't have a built in html formatter just yet (see https://github.com/Behat/Behat/issues/359). However, there's a third party extension - emuse/behat-html-formatter. It not only allows you to generate the classic Behat 2 style report, but has an additional one.


text:
Q: to replace NA value from results of zoo::rollmean I am working with a data recently, part of it showed as followed.
    SID1A   day1    day2    pci TRTREG1C    ladcc
1   1000_00001  0   1   0   A   98
2   1000_00001  1   2   0   A   95
3   1000_00001  2   3   0   A   94
4   1000_00001  3   4   0   A   99
5   1000_00001  4   5   0   A   97
6   1000_00002  0   1   0   B   98
7   1000_00002  1   2   0   B   94
8   1000_00002  2   3   0   B   97
9   1000_00002  3   4   0   B   96
10  1000_00003  0   1   0   A   101
11  1000_00003  1   2   0   A   99
12  1000_00004  0   1   0   B   89
13  1000_00004  1   2   0   B   88

What I am trying to get is the roll mean of ladcc by SID1A by the width of 3. So I tried the function rollmean from zoo and expression from dplyr.
    dt <- dt %>% group_by(SID1A)%>%
          mutate(adcc_av3 = rollmean(x=ladcc, min(3, length(ladcc)), partial = T,
          na.pad = T, fill=NA, align = 'right'))

It gives me result as followed.
   SID1A    day1    day2    pci TRTREG1C    ladcc   adcc_av30
1   1000_00001  0   1   0   A   98  NA
2   1000_00001  1   2   0   A   95  NA
3   1000_00001  2   3   0   A   94  95.66666667
4   1000_00001  3   4   0   A   99  96
5   1000_00001  4   5   0   A   97  96.66666667
6   1000_00002  0   1   0   B   98  NA
7   1000_00002  1   2   0   B   94  NA
8   1000_00002  2   3   0   B   97  96.33333333
9   1000_00002  3   4   0   B   96  95.66666667
10  1000_00003  0   1   0   A   101 NA
11  1000_00003  1   2   0   A   99  100
12  1000_00004  0   1   0   B   89  NA
13  1000_00004  1   2   0   B   88  88.5

What I want from the result is
   SID1A    day1    day2    pci TRTREG1C    ladcc   adcc_av30
1   1000_00001  0   1   0   A   98  98
2   1000_00001  1   2   0   A   95  96.5
3   1000_00001  2   3   0   A   94  95.66666667
4   1000_00001  3   4   0   A   99  96
5   1000_00001  4   5   0   A   97  96.66666667
6   1000_00002  0   1   0   B   98  98
7   1000_00002  1   2   0   B   94  96
8   1000_00002  2   3   0   B   97  96.33333333
9   1000_00002  3   4   0   B   96  95.66666667
10  1000_00003  0   1   0   A   101 101
11  1000_00003  1   2   0   A   99  100
12  1000_00004  0   1   0   B   89  89
13  1000_00004  1   2   0   B   88  88.5

Which is rollmean(ladcc, k = min(3, **number of rows before this row**)), I tried  rollmean(ladcc, k = min(3, day2)), but it don't work and gave me error of "k <= n is not true". So the manipulation of data in dplyr is not performed row by row? Thank you very much in advance.

A: I have got a way to deliver the result as I wanted. rollmean seems powerless here since the width(k) is not changeable among groups.
I used pracma::movavg and dplyr.
Here's the code:
adcc_final_temp1 <- adcc_final_temp1 %>% group_by(SID1A)%>%
                    mutate(adcc_av30 = movavg(ladcc, min(30, length(ladcc)-1), type = 's'))

It's similar to the original one, just different function/package.

A: Use rollapplyr with partial = TRUE
library(zoo)

roll <- function(x) rollapplyr(x, 3, mean, partial = TRUE)
transform(DF, avg = ave(ladcc, SID1A, FUN = roll))

giving:
        SID1A day1 day2 pci TRTREG1C ladcc       avg
1  1000_00001    0    1   0        A    98  98.00000
2  1000_00001    1    2   0        A    95  96.50000
3  1000_00001    2    3   0        A    94  95.66667
4  1000_00001    3    4   0        A    99  96.00000
5  1000_00001    4    5   0        A    97  96.66667
6  1000_00002    0    1   0        B    98  98.00000
7  1000_00002    1    2   0        B    94  96.00000
8  1000_00002    2    3   0        B    97  96.33333
9  1000_00002    3    4   0        B    96  95.66667
10 1000_00003    0    1   0        A   101 101.00000
11 1000_00003    1    2   0        A    99 100.00000
12 1000_00004    0    1   0        B    89  89.00000
13 1000_00004    1    2   0        B    88  88.50000

Note: The input used in reproducible form is:
Lines <- "    SID1A   day1    day2    pci TRTREG1C    ladcc
1   1000_00001  0   1   0   A   98
2   1000_00001  1   2   0   A   95
3   1000_00001  2   3   0   A   94
4   1000_00001  3   4   0   A   99
5   1000_00001  4   5   0   A   97
6   1000_00002  0   1   0   B   98
7   1000_00002  1   2   0   B   94
8   1000_00002  2   3   0   B   97
9   1000_00002  3   4   0   B   96
10  1000_00003  0   1   0   A   101
11  1000_00003  1   2   0   A   99
12  1000_00004  0   1   0   B   89
13  1000_00004  1   2   0   B   88"
DF <- read.table(text = Lines, header = TRUE)


text:
Q: Given two sets of strings wherein the first set's parent element is a descendant of the second set's parent element, how do I get the second set? How do I get the "grab me" text in HTML using vanilla javascript? I have some thoughts below, but I am looking for a better way.
HTML

H1 here

    grab me

Javascript
let firstSetString = document.querySelector("h1").innerHTML;
let BothSetString = document.querySelector("div").innerText.replace("\n","")
let secondSetString = BothSetString.replace(firstSetString,"")
console.log(secondSetString)// returns grab me

A: The div has 3 child nodes: a text node, an h1 node, and another text node. The last child node contains the text to grab:

const div = document.body.querySelector("div");
const text = div.childNodes[div.childNodes.length - 1].textContent;
console.log(text.trim());

H1 here

  grab me

A: Use regular expression

const div = document.querySelector("div");
const texts = div.innerHTML.split(/\r|\r\n|\n/);
console.log(texts[2].trim());

H1 here

    grab me

Use childNodes to filter

const div = document.querySelector("div");

for(let i = 0; i < div.childNodes.length; i++){
  const childNode = div.childNodes[i];
  if(isEmpty(childNode.nodeValue) && childNode.nodeName == '#text'){
    console.log(childNode.nodeValue.trim());
  }
}

function isEmpty(val){
  return val ? val.trim() : true;
}

H1 here

    grab me


text:
Q: solr phrase frequency count Hi all is there any way to find frequency of a phrase in a document in solr.
i have a document like below
i need to find how many times the phrase is repeating in the document.
sample input:
1) "Text messaging, or texting, is the act of composing and sending electronic messages"
2) "35 U.S.C. § 271(e)(2)(A)"
output : count of the phrase in the document
`
{
    "id":1,
    "filecontent": "Text messaging, or texting, is the act of composing and sending electronic messages, typically consisting of alphabetic and numeric characters, between two or more users of mobile phones, tablets, desktops/laptops, or other devices. Text messages may be sent over a cellular network, or may also be sent via an Internet connection.
The term originally referred to messages sent using the Short Message Service (SMS). It has grown beyond alphanumeric text to include multimedia messages (known as MMS) containing digital images, videos, and sound content, as well as ideograms known as emoji (happy faces, sad faces, and other icons).
As of 2017, text messages ABC are used by youth and adults for personal, family and social purposes and in business. Governmental and non-governmental organizations use text messaging for communication between colleagues. As with emailing, in the 2010s, the sending of short informal messages has become an accepted part of many cultures.[1] This makes texting a quick and easy way to communicate with friends and colleagues, including in contexts where a call would be impolite or inappropriate (e.g., calling very late at night or when one knows the other person is busy with family or work activities). Like e-mail and voice mail, and unlike calls (in which the caller hopes to speak directly with the recipient), texting does not require the caller and recipient to both be free at the same moment; this permits communication even between busy individuals. Text messages can also be used to interact with automated systems, for example, to order products or services from e-commerce websites, or to participate 35 U.S.C. § 271(e)(2)(A) in online contests. Advertisers and service providers use direct text marketing to send messages to mobile users about promotions, payment due dates, and other notifications instead of using postal mail, email, or voicemail. by youth and adults for personal, by youth and adults for personal, by youth and adults for personal, messaging , textx"
}`

A: put debug=results at the end of solr url
it will give you the phrase freq also.
special thanks to matslindh


text:
Q: Concat digits into xxx-xxx form Example, I get data from eclipse and insert into 'abc' table.
so, now how I can get the data from the 'abc' table and concat the digit?
Example: I enter 123456 then in SQL need to concat into format 123-456
I created procedure and alter procedure.
I can insert but I can't select and concat and insert.
I want it to be in a column.
this is create procedure
USE abc
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE TEST

    @cd VARCHAR(14)

AS
BEGIN
    SET NOCOUNT ON;

    INSERT INTO abc (a) VALUES (@cd)

FROM abc

END
GO

here is the alter procedure
USE [abc]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[abc]

    @cd VARCHAR(14)

AS
BEGIN

    SET NOCOUNT ON;

    INSERT INTO abc(a) VALUES (@cd)
     Select CONCAT(SUBSTRING(abc, 1,3), '-',
    SUBSTRING(abc,4,3)
from abc

END
GO

A: I'm a little confused about what you're really trying to do.
Your INSERT procedure has a rogue FROM abc in it which would error. Your INSERT statement should simply be:
INSERT INTO abc (a) VALUES (@cd);

Now, if you're wanting to change the data that's already the table, use UPDATE.
 UPDATE abc SET a = CONCAT(SUBSTRING(a, 1,3), '-', SUBSTRING(a,4,3));

Or if you're wanting to insert a new row that's concatenated, use the variable:
INSERT INTO abc (a) VALUES (CONCAT(SUBSTRING(@cd, 1,3), '-', SUBSTRING(@cd,4,3)));

or
INSERT INTO abc (a)
CONCAT(SUBSTRING(a, 1,3), '-', SUBSTRING(a,4,3));


text:
Q: Referencing shell32 again, C# Visual Studio Hmmm. Okay after revisiting PInvoke, I'm sure that I don't quite get it :-/ (just asked this question)
Let me illustrate the code I need to handle. It works when I use "Add Reference --> COM --> Microsoft Shell Controls and Automatation" ... but sadly it places a reference in my project that looks like this: "C:\Users\Tim\Documents\Visual Studio 2008\Projects\Wing\FileWing\obj\Debug\Interop.Shell32.dll"
I'm digging though the recycling bin and seek for a item that I want to recover. Is there any way NOT fighting through the PInvoke to get this done? Or to get a reference to the system32/shell32.dll that lets me use this code at runtime?
private void recoverRecyclerBinEntry(string fileName, int size)
{
    try
    {
        Shell Shl = new Shell();
        Folder Recycler = Shl.NameSpace(10);

        // scans through all the recyclers entries till the one to recover has been found
        for (int i = 0; i < Recycler.Items().Count; i++)
        {
            FolderItem FI = Recycler.Items().Item(i);
            string FileName = Recycler.GetDetailsOf(FI, 0);
            if (Path.GetExtension(FileName) == "")
                FileName += Path.GetExtension(FI.Path);
            //Necessary for systems with hidden file extensions.

            string FilePath = Recycler.GetDetailsOf(FI, 1);
            string combinedPath = Path.Combine(FilePath, FileName);

            if (size == FI.Size && fileName == combinedPath)
            {
                Debug.Write("Match found. Restoring " + combinedPath + "...");
                Undelete(FI);
                Debug.WriteLine("done.");
            }
            else
            {
                Debug.WriteLine("No match");
            }
        }
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex.Message);
        Debug.WriteLine(ex.StackTrace);
    }
}

private bool Undelete(FolderItem Item)
{
    try
    {
        foreach (FolderItemVerb FIVerb in Item.Verbs())
        {
            if (
                (FIVerb.Name.ToUpper().Contains("WIEDERHERSTELLEN")) ||
                (FIVerb.Name.ToUpper().Contains("ESTORE")) ||
                (FIVerb.Name.ToUpper().Contains("NDELETE"))
                )
            {
                FIVerb.DoIt();
                return true;
            }
        }
        //execute the first one:
        Item.Verbs().Item(0).DoIt();
        return true;
    }
    catch (Exception)
    {
        Debug.WriteLine("ERROR undeleting");
        return false;
    }
}

A: Right now you're mixing 2 different concepts: PInvoke and COM Interop.
PInvoke allows you to access native C functions from within managed code.  It works by defining a marshal compatible signature of the native method in managed code and marking it with the DllImport attribute.  It requires, and cannot have, a metadata reference to the native DLL.  The DLL is discovered at runtime using normal loading rules for a Win32 DLL.
COM Interop allows you to access COM compatible objects from managed code.  This is done by getting a marshal compatible managed definition of the COM interface and then gaining a referece to the object in one of several ways.  Getting the managed definition is often accomplished by means of adding a metadata reference to the PIA (primary interop assembly) for the COM component.  Until C# 4.0, this reference cannot be removed, without a lot of work, and must be deployed with your application.
In this particular example you are using COM interop and not PInvoke.


text:
Q: Is this async or blocking code? Is this blocking code if I have JSON.stringify inside writeFile.Lets say it is big file. Is this why I am getting error conection refused when I push button multiple times in second which triggers this api endpoint?
 app.patch('/', function(req, res) {
...some query
fs.writeFile(path.join(__dirname, "../../") + 'Data/deals.json', JSON.stringify(tickets), function (err) {
        if (err) {
            console.log(err);
            return res.status(400).json({error: err});
        }
        return res.status(200).json({success: true, message: 'Deal Updated successfully'});
    });
})

A: Edit #1:
JSON.stringify parsing object to string synchronously. but you missing that you called JSON.stringify inside the patch function and not inside the writeFIle.
Original:
It's Async. if you want to write a file synchronously you have to use writeFileSync.
For more information visit Node.js fs Docs
Example
// Async callback will called after finish
// Non-Blocking
fs.writeFile(file, data[, options], callback)

// write to file with return the result, may throw exception
// Blocking
fs.writeFileSync(file, data[, options])


text:
Q: Angular UI-router - Not populating params despite $stateParams get object Im using angular and angular router-ui. I want to make use of dynamic url params.
This is how Im using it:
          .state('index.domain', {
            url: '/domain',
            template: "<div ui-view> Home Domain page </div>"
          })

            .state('index.domain.id', {
              url: '/:domainId',
              resolve: {
                domainId: function($stateParams){
                  return $stateParams.domainId;
                }
              },
              templateUrl: "./development/administration/domain.html",
              controller: function(domainId){
                console.log(domainId);
              }
            })

Im calling the routing with the following invocation:
$state.go('index.domain.id', {"domainId": domainId});

It DOES execute the resolve and $stateParams get an object with domainId. Despite of that it does not get into the controller. The URL/:domainId does not changed either.
If I change in the browser the URL to point to URL/RANDOM_DOMAIN_ID (where RANDOM_ID is a domainId valid number) it executes the resolve and goes to the controller.
Am I missing something on the $state.go call?

A: There is a working plunker
I used the above state def as is:
.state('index', {
    url: '/index',
    template: "<div ui-view> Index </div>"
  })
.state('index.domain', {
    url: '/domain',
    template: "<div ui-view> Home Domain page </div>"
 })
.state('index.domain.id', {
  url: '/:domainId',
  resolve: {
    domainId: function($stateParams){
      return $stateParams.domainId;
    }
  },
  templateUrl: "development/administration/domain.html",
  controller: function(domainId){
    console.log(domainId);
  }
})

And made just few adjustments in the calling side - and this is working:
<a ui-sref="index.domain.id({domainId: 1})">...
<button ng-click="$state.go('index.domain.id', {domainId: 22});">...

Check it here


text:
Q: Text compare expr in Cloudsearch I am trying to add an expression into a cloudsearch query that compares a string and sets a value based on that.
It appears that cloudsearch can't do this on text fields.
According to the docs one of the ways you can run expressions is on "Integer, floating point, hex, and octal literals"
(http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-expressions.html)
So I have converted the string into an MD5, which should be a Hex number.
Put the value into a field set as type "literal"
but I get the error
Non-numeric field fieldname cannot be used in expression

What method can I use to run an expression to achieve what I am needing to do?

A: Expressions are configured to sort search results, but, first of all, you can

*

*define multiple terms in the query parser to penalize documents that
don't meet your criteria

*and also specify SortEnabled fields and assign weights to selected
fields

Examples of weighting and searching for literal strings
genres:'Sci-Fi'

or
q.options={fields:['title^2','plot^0.5']}

It's also possible to choose a bucket sort with multiple literal values like the following
facet.genres={buckets:["Action","Adventure","Sci-Fi"]}

Read more about bucketing facet information in the docs.
Finally, in configuring the Expression, you can use the document's relevance score (_score) that is based on how often the search terms appear in the document, as shown in the link you've already mentioned
(0.3*popularity)+(0.7*_score)

A: Because, as you say, expressions can only be defined on numeric fields, you can't use them directly in the sort order. But with a bit of effort you can make a structured search (q.parser=structured) give a boost to the _score value if your text field matches a given value.
I say it's a bit combersome, because you have to combine two versions of the query with an (or) - one with the boost and one without.
So to use the example in the other answer (where you want to give a boost where genre matches 'Sci-Fi') your query becomes (or (and <OLD_QUERY> (term field=genre boost=2.5 'Sci-Fi')) <OLD_QUERY>) - where <OLD_QUERY> could for example be (prefix 'Bladerun') or whatever the user is searching for.
In other words: EITHER a match for the original query where genre='Sci-Fi', boosted by 2.5, OR a match for that same query in any genre without a boost.
Painful, but it works!


text:
Q: Querying XML Child Nodes with WHERE clause via SQL Is it possible to write a WHERE clause to select values from XML based on the value of a child node?
Example XML
<Message>
   <PrimaryKeyValue>12345</PrimaryKeyValue>
   <Events>
      <UpdatedDefaultAddress>True</UpdatedDefaultAddress>
      <UpdatedCustomerName>False</UpdatedCustomerName>
   </Events>
</Message>
<Message>
   <PrimaryKeyValue>67890</PrimaryKeyValue>
   <Events>
      <UpdatedDefaultAddress>False</UpdatedDefaultAddress>
      <UpdatedCustomerName>True</UpdatedCustomerName>
   </Events>
</Message>

My Question
How would I construct a query to only select PrimaryKeyValues where the value of <UpdatedDefaultAddress> is 'True'?
My current code
SELECT
t.c.value('(PrimaryKeyValue)[1]', 'varchar(100)') AS PrimaryKeyValue
FROM @message_body.nodes('Message') as T(C)
WHERE t.c.exist('./Events/UpdateDefaultAddress') = 'True'

The problem with this is that I get both PrimaryKeyValues back in the result - I think the code is checking whether <UpdatedDefaultAddress> exists, rather than the value contained within it?

A: Use .value() instead of .exists()
DECLARE @message_body XML =N'<Message>
   <PrimaryKeyValue>12345</PrimaryKeyValue>
   <Events>
      <UpdatedDefaultAddress>True</UpdatedDefaultAddress>
      <UpdatedCustomerName>False</UpdatedCustomerName>
   </Events>
</Message>
<Message>
   <PrimaryKeyValue>67890</PrimaryKeyValue>
   <Events>
      <UpdatedDefaultAddress>False</UpdatedDefaultAddress>
      <UpdatedCustomerName>True</UpdatedCustomerName>
   </Events>
</Message>';

SELECT t.c.value('(PrimaryKeyValue)[1]', 'varchar(100)') AS PrimaryKeyValue
FROM @message_body.nodes('Message') as T(C)
WHERE  t.c.value('(./Events/UpdatedDefaultAddress)[1]', 'varchar(10)')='True';

Rextester Demo


text:
Q: java.lang.SecurityException for startActivity URL on some devices I am getting this crash on some devices and I can't figure out why, I can't reproduce it on my devices. This is my code:
String url = "https://www.google.com/"; // any URL
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
ResolveInfo result = getPackageManager().resolveActivity(intent, 0);
if (result != null) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); // crashes here on some devices
} else {
    showToast(getApplicationContext(), "No application found to handle the link.");
}

I am getting this error on some devices, Play Console won't show the devices anymore, so I have no idea which devices this happens on, but it doesn't happen on many:
Exception java.lang.SecurityException:
  at android.os.Parcel.createException (Parcel.java:1966)
  at android.os.Parcel.readException (Parcel.java:1934)
  at android.os.Parcel.readException (Parcel.java:1884)
  at android.app.IActivityManager$Stub$Proxy.startActivity (IActivityManager.java:3619)
  at android.app.Instrumentation.execStartActivity (Instrumentation.java:1669)
  at android.app.Activity.startActivityForResult (Activity.java:4689)
  at android.app.Activity.startActivityForResult (Activity.java:4647)
  at android.app.Activity.startActivity (Activity.java:5008)
  at android.app.Activity.startActivity (Activity.java:4976)

Does anyone know what could be the problem? I don't remember seeing this crash in the past and I didn't change anything in my app since then.
This happens on a few Android versions, from Android 7 to Android 11.

A: If you rewrite your code as:
String url = "https://www.google.com/"; // any URL
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

try {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); // crashes here on some devices
} catch (Throwable t) {
    showToast(getApplicationContext(), "No application found to handle the link.");
}

...now you handle any reason why you cannot start the activity. It also works on Android 11+ where you might need a <queries> element in your manifest for that resolveActivity() call.


text:
Q: Magento 2: Custom category attribute is missing scope In Magento 2.2.7 I have created a custom attribute (textarea, wysiwyg) for categories.
This is my InstallData
namespace MyVendor\Mods\Setup;

use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;

class InstallData implements InstallDataInterface
{
    private $eavSetupFactory;

    /**
     * Constructor
     *
     * @param \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
     */
    public function __construct(EavSetupFactory $eavSetupFactory)
    {
        $this->eavSetupFactory = $eavSetupFactory;
    }

    /**
     * {@inheritdoc}
     */
    public function install(
        ModuleDataSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Category::ENTITY,
            'long_description',
            [
                'type' => 'text',
                'label' => 'Long Description',
                'input' => 'textarea',
                'sort_order' => 5,
                'global' => 0,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => null,
                'group' => 'General Information',
                'searchable' => true,
                'is_html_allowed_on_front' => true,
                'wysiwyg_enabled' => true
            ]
        );
    }
}

The setup works fine, the field shows up in the backend and it saves the data I enter.
There are only two issues here and I sense they are connected:

*

*There is no scope. I cannot save different values for different storeviews. 'global' => 0 behaves identical to \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, I tried both. The value is always global, no matter what.

2. The value is not stored in the category flat tables. The field long_description does not show up in the flat tables at all.
I copied the field's setup from the catalog module's config for the description field (CategorySetup.php):
'description' => [
    'type' => 'text',
    'label' => 'Description',
    'input' => 'textarea',
    'required' => false,
    'sort_order' => 4,
    'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
    'wysiwyg_enabled' => true,
    'is_html_allowed_on_front' => true,
    'group' => 'General Information',
],

What am I missing?
Thank you
EDIT: The attribute shows up in the flat tables after I forced a reindex. I thought the running cronjob would take care of it. Still the scope issue remains.

A: Ok, this seems to be a bug: https://github.com/magento/magento2/issues/13440
Solution (worked for me): https://github.com/magento/magento2/issues/13440#issuecomment-436712363
\app\code\Vendor\Module\etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Model\Category\DataProvider">
        <plugin name="categoryCustomAttributes" type="Vendor\Module\Plugin\Model\Category\DataProvider" sortOrder="1" disabled="false"/>
    </type>
</config>

\app\code\Vendor\Module\Plugin\Model\Category\DataProvider.php:
namespace Vendor\Module\Plugin\Model\Category;

class DataProvider extends \Magento\Catalog\Model\Category\DataProvider
{
    public function __construct(\Magento\Eav\Model\Config $eavConfig)
    {
        // not sure this is right, as $this->eavConfig is private
          $this->eavConfig = $eavConfig;
    }

    public function afterPrepareMeta(\Magento\Catalog\Model\Category\DataProvider $subject, $result)
    {
        $meta = array_replace_recursive($result, $this->_prepareFieldsMeta(
            $this->_getFieldsMap(),
            $subject->getAttributesMeta($this->eavConfig->getEntityType('catalog_category'))
        ));
        return $meta;
    }

    public function _prepareFieldsMeta($fieldsMap, $fieldsMeta)
    {
        $result = [];
        foreach ($fieldsMap as $fieldSet => $fields) {
            foreach ($fields as $field) {
                if (isset($fieldsMeta[$field])) {
                    $result[$fieldSet]['children'][$field]['arguments']['data']['config'] = $fieldsMeta[$field];
                }
            }
        }
        return $result;
    }

    public function _getFieldsMap()
    {
        $fields = parent::getFieldsMap();
        // Adjust per your needs here
        $fields['content'][] = 'long_description';
        return $fields;
    }
}

Followed by a bin/magento setup:di:compile

A: You can try to add in your file Vendor/Module/view/adminhtml/ui_component/category_form.xml next code:
<settings>
     <scopeLabel>[STORE VIEW]</scopeLabel>
</settings>


text:
Q: Opening a website in default browser and pass to it POST data Imagine a "client-server" application. There are 2 different clients available which can log in to the database, one is a standard windows application, one is a web application. Most of the functionality is available from both clients, but some of the functionality is available just from the web client.
So right now if the user is using the windows client and he needs to do something in the web client, he needs to open his default browser, open the correct URL to get to the login page, input the correct username and password, and after logging in he can continue with his work. Well users are a bit lazy, so they came with a request to make it easier, they want to add something to the windows application - something like a clickable button so that after clicking it their default web browser opens and they get automatically logged in (I have the login data in the windows application).
Well a nice task for a newbie :) I found many ways how to either create POST requests and send them to the server OR how to open the default browser, but none about how to open the browser AND send to it my POST request.
So I had an idea - I create a temp html file "on the fly" in the user's temp folder (I delete it at the end), the file includes just a form which will be automatically submitted.
public void CreateFormFile(string url, string userName, string password)
{
  using (StreamWriter sw = new StreamWriter(FormFileName))
    {
      sw.WriteLine("");
      sw.WriteLine("<form id=\"frmRedirect\" action=\""+url+"\" method=\"post\">");
      sw.WriteLine("<input type=\"text\" name=\"userName\" id=\"userName\" value=\"" + userName + "\">");
      sw.WriteLine("<input type=\"text\" name=\"password\" id=\"password\" value=\"" + password+ "\">");
      //sw.WriteLine("<input type=\"submit\" name=\"submit\" value=\"submit\" id=\"submit\">");
      sw.WriteLine("");
      sw.WriteLine("</form>");
      sw.WriteLine("");
    }
  }

And then in the main program I just call
CreateFormFile(config.URL, config.UserName, config.Password);
Process.Start(FormFileName); //FormFileName is a string property containing the full path to the temp file

Well the problem is it doesn't work on the "other side."
I created a test aspx on the server
protected void Page_Load(object sender, EventArgs e)
  {
    string userName = HttpContext.Current.Request["userName"];
    string password = HttpContext.Current.Request["password"];
    Response.Write("userName = " + userName);
    Response.Write("
password = " + password);
  }

So now, when I click the button, my browser opens, it gets correctly redirected to the correct page, but the page simply returns
userName =
password =

Meaning the values are empty. When I was debugging it I found out that Request.HttpMethods is actually "GET" and not "POST" as it should be, and Request.InputStream is empty (Length == 0).
Any idea what am I doing wrong? I am testing it on localhost if it matters. Thanks for any help

A: I don't know you kind of database you have, but something like this...
When you log in (webapp or not) with the right user and password the server generates a random hash like (gbiaw783y98hdq98dgqod9pawhd) and stores it as a session somewhere on your database, only for that user. Also, returns this hash for you when you log in in the windows application. You store this string in some variable on the application and when the users clicks the button it opens the url where you supply the hash on GET method. The server then compares the hash you sent with the one that is one the database, if equals logs in the user, if not just echo some log in error.
Sorry if I was not clear enough


text:
Q: Does a Neural Network actually need an activation function or is that just for Back Propagation? I have a feed forward neural network (1 hidden layer with 10 neurons, 1 output layer with 1 neuron) with no activation function (only transfer by weight + bias) that can learn a really wonky sin wave (using a 2in1out window) with production usable accuracy trained via stochastic climbing in a couple seconds:
for (int d = 0; d < 10000; d++)
    data.Add((float)(Math.Sin((float)d * (1 / (1 + ((float)d / 300)))) + 1) / 2);

I'm probably just drunk, but if you don't use an activation function do you lose that universal function approximator status? Or is it just for gradient descent / back propagation etc. to act as a differentiable function?
Alternatively, have I probably just overlooked a bug and am actually secretly activating without knowing it?
source in C# (draws on a form)

A: If you don't have non-linear activation functions, then you end up with a network as powerful in its expressive power as a linear model. Simply view it as a linear algebra problem. Intuitively if you have linear transformation encoded by a matrix $A$ and you compose an initial vector $x$ with multiple linear transformation, then you still end up with a linear transformation:
$$ T_1( ... T_n(x) ) = A_1 \cdot ... \cdot A_n x $$
Essentially if you move points so the grids stay parallel and evenly spaced you can't randomly introduce a curve. So everything remains linear.

A: You built a multilayer neural network with a linear hidden layer. Linear units in the hidden layer negates the purpose of having a hidden layer. The weights between your inputs and the hidden layer, and the weights between the hidden layer and the output layer are effectively a single set of weights. A neural network with a single set of weights is a linear model performing regression.
Here's a vector of your linear hidden units
$$
H = [h_1, h_2,.. ,h_n]
$$
The equation the governs the forward propagation of $x$ through your network is then
$$
\bar{y} = W'(Hx) \Rightarrow (W'H)x
$$
Thus an n-layered feed forward neural network with linear hidden layers is equivalent to a output layer given by
$$
W=W'\prod_i H_i
$$
If you only have linear units then the hidden layer(s) are doing nothing. Hinton et al recommends rectified linear units, which are $\text{max}(0, x)$. It's simple and doesn't suffer the vanishing gradient problem of sigmoidal functions. Similarly you might choose soft-plus function, $\log(1 + e^x)$ which is a non-sparse smooth approximation.


text:
Q: Fixed Effect Model diagnostics using `fiest` package in R I recently noticed a wonderful R package fixest to run fixed effect estimation in R.
In conventional plm package, I know that we can run pFtest(), pbptest() and some diagnostics tests on estimated residuals. But, I was wondering to know whether it is possible to run the same diagnostic tests using the fixest package.
Thank you in advance.